-
Notifications
You must be signed in to change notification settings - Fork 29
/
asm_arch_size.sql
147 lines (136 loc) · 4.88 KB
/
asm_arch_size.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
REM
REM Script: asm_arch_size.sql
REM Author: Quanwen Zhao
REM Dated: Jan 25, 2023
REM Updated: Feb 26, 2023
REM
REM Last tested:
REM 11.2.0.4
REM 12.2.0.1
REM 19.3.0.0
REM
REM Purpose:
REM Checking archive log occupied asm disk size and used rate on oracle database.
REM
with al as
(select substr(name, 2, instr(name, '/', 1)-2) as disk_name,
round((sum(blocks*block_size)/1024/1024/1024), 2) as arc_used_gb
from v$archived_log
where standby_dest = 'NO'
and deleted = 'NO'
and name like '+%'
group by substr(name, 2, instr(name, '/', 1)-2)
),
atg as
(select ad.name,
al.arc_used_gb,
case type
when 'EXTERN' then round(ad.total_mb/1024, 2)
when 'NORMAL' then round(ad.total_mb/1024/2, 2)
when 'HIGH' then round(ad.total_mb/1024/3, 2)
end act_total_gb
from v$asm_diskgroup ad, al
where ad.name = al.disk_name
)
select name as ASM_DISK_NAME,
arc_used_gb as ARC_USED_GB,
round(arc_used_gb/act_total_gb, 4)*100 as PERCENT_SPACE_USED
from atg
;
ASM_DISK_NAME ARC_USED_GB PERCENT_SPACE_USED
------------------------------ ----------- ------------------
DATA 15.85 31.7
with af as
(select group_number,
case redundancy
when 'HIGH' then round(sum(space)/1024/1024/1024, 2)/3
when 'MIRROR' then round(sum(space)/1024/1024/1024, 2)/2
when 'UNPROT' then round(sum(space)/1024/1024/1024, 2)
end act_used_gb,
round(sum(space)/1024/1024/1024, 2)used_gb
from v$asm_file
where type in ('ARCHIVELOG')
group by group_number,
case redundancy
when 'HIGH' then round(sum(space)/1024/1024/1024, 2)/3
when 'MIRROR' then round(sum(space)/1024/1024/1024, 2)/2
when 'UNPROT' then round(sum(space)/1024/1024/1024, 2)
end
)
select ad.name as ASM_DISK_NAME,
af.act_used_gb as ARC_USED_GB,
round(af.used_gb/(ad.total_mb/1024), 4)*100 as PERCENT_SPACE_USED
from v$asm_diskgroup ad, af
where ad.group_number = af.group_number;
when 'HIGH' then round(sum(space)/1024/1024/1024, 2)/3
*
ERROR at line 13:
ORA-00934: group function is not allowed here
with af as
(select group_number,
decode(redundancy, 'HIGH', round(sum(space)/1024/1024/1024, 2)/3, 'MIRROR', round(sum(space)/1024/1024/1024, 2)/2, 'UNPROT', round(sum(space)/1024/1024/1024, 2)) act_used_gb,
round(sum(space)/1024/1024/1024, 2) used_gb
from v$asm_file
where type in ('ARCHIVELOG')
group by group_number,
decode(redundancy, 'HIGH', round(sum(space)/1024/1024/1024, 2)/3, 'MIRROR', round(sum(space)/1024/1024/1024, 2)/2, 'UNPROT', round(sum(space)/1024/1024/1024, 2))
)
select ad.name as ASM_DISK_NAME,
af.act_used_gb as ARC_USED_GB,
round(af.used_gb/(ad.total_mb/1024), 4)*100 as PERCENT_SPACE_USED
from v$asm_diskgroup ad, af
where ad.group_number = af.group_number;
decode(redundancy, 'HIGH', round(sum(space)/1024/1024/1024, 2)/3, 'MIRROR', round(sum(space)/1024/1024/1024, 2)/2, 'UNPROT', round(sum(space)/1024/1024/1024, 2))
*
ERROR at line 8:
ORA-00934: group function is not allowed here
with af as
(select group_number,
redundancy,
round(sum(space)/1024/1024/1024, 2) used_gb
from v$asm_file
where type in ('ARCHIVELOG')
group by group_number,
redundancy
),
aug as
(select af.group_number,
case af.redundancy
when 'HIGH' then af.used_gb/3
when 'MIRROR' then af.used_gb/2
when 'UNPROT' then af.used_gb
end act_used_gb
from af
)
select ad.name as ASM_DISK_NAME,
aug.act_used_gb as ARC_USED_GB,
round(af.used_gb/(ad.total_mb/1024), 4)*100 as PERCENT_SPACE_USED
from v$asm_diskgroup ad, af, aug
where ad.group_number = af.group_number
and af.group_number = aug.group_number;
ASM_DISK_NAME ARC_USED_GB PERCENT_SPACE_USED
------------------------------ ----------- ------------------
DATA 16.045 32.09
with af as
(select group_number,
redundancy,
round(sum(space)/1024/1024/1024, 2) used_gb
from v$asm_file
where type in ('ARCHIVELOG')
group by group_number,
redundancy
),
aug as
(select af.group_number,
decode(af.redundancy, 'HIGH', af.used_gb/3, 'MIRROR', af.used_gb/2, 'UNPROT', af.used_gb) act_used_gb
from af
)
select ad.name as ASM_DISK_NAME,
aug.act_used_gb as ARC_USED_GB,
round(af.used_gb/(ad.total_mb/1024), 4)*100 as PERCENT_SPACE_USED
from v$asm_diskgroup ad, af, aug
where ad.group_number = af.group_number
and af.group_number = aug.group_number;
ASM_DISK_NAME ARC_USED_GB PERCENT_SPACE_USED
------------------------------ ----------- ------------------
DATA 16.045 32.09