free_mb in gv$asm_diskgroup is raw free space. In a normal redundancy disk group every extent is written twice, and ASM also keeps room to re-mirror after losing a failure group, so the space you can actually use for new files is much lower. That number is usable_file_mb.
This script reports the smaller of the two as free space, so a mirrored disk group that's nearly full shows as nearly full. It also lists any rebalance in flight first, because a group mid-rebalance after adding or dropping disks will report shifting numbers.
Usage
SQL> @asm.sql
-- asm.sql: ASM disk group usage, counting what's really usable after mirroring
-- Copyright (c) HASHJOIN. MIT License (https://hashjoin.com/kb/license/)
-- https://hashjoin.com/kb/oracle/asm-diskgroup-usage/
--
-- Usage: @asm.sql
--
-- gv$asm_operation (rebalances in flight) only returns rows when run on the ASM instance.
set trims on
set pages 90
set lines 132
prompt Rebalance and resync operations in flight (ASM instance only)
select * from gv$asm_operation;
col name format a25
break on report
compute sum of total_mb on report
ttit "ASM Diskgroup Usage"
select distinct name, total_mb, least(free_mb, usable_file_mb) free_mb,
round(100 - (least(free_mb, usable_file_mb)*100/decode(total_mb,0,1,total_mb)),1) pct_used
from gv$asm_diskgroup
order by 4 desc;
ttit offcurl -O https://hashjoin.com/kb/oracle/asm-diskgroup-usage/asm.sql
Reading the output
PCT_USED is computed against total_mb, which is raw capacity, but with the free side taken from usable_file_mb. So for a mirrored group it climbs toward 100% as the space you can really use runs out, not at half raw capacity. Alert on FREE_MB (the usable figure) rather than the percentage when your disk groups differ in size.
usable_file_mb goes negative when the group no longer has enough free space to re-mirror after losing a failure group. The script then reports a percentage above 100. That means a disk failure would leave data with a single copy until you add space.
Gotchas
- Rebalance rows only show on the ASM instance. From a database instance,
gv$asm_operationreturns no rows even while a rebalance is running. Connect to+ASMto see it. DISTINCTis there on purpose. On RAC,gv$asm_diskgroupreturns one row per instance for each group.
What it reads
gv$asm_diskgroup gv$asm_operation
Related
Tired of fixing the same thing twice?
HASHJOIN turns the checks and fixes your on-call runs by hand into tooling that gives the same answer every time. Fixed scope, and you own all of the code.
New fixes and field notes by email, about once a month.