create or replace
procedure Check_Disk_Size (vCC_List varChar2)
-- grant select on V$ASM_DISKGROUP to <user>;
-- grant select on v$database to <user>;
-- grant execute on utl_mail to <user>;
/*
execute DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => '/sys/acls/outbound_mail.xml',
principal => '<user>',
is_grant => true,
privilege => 'connect');
*/
as
vMessage varChar2(32000) := '';
vSubject varChar2(80) := '';
vMail_List varChar2(32000) :=’<email>’;
cursor get_diskspace is
select name, trunc(total_mb/1024) "TOTAL", trunc(free_mb/1024) "FREE"
from V$ASM_DISKGROUP;
DiskSpace get_diskspace%ROWTYPE;
begin
select 'Disk Usage ' || upper(name) || ' DB'
into vSubject
from v$database;
vMessage := 'ASM Disk Usage' || chr(10) || chr(13);
for DiskSpace in get_diskspace
loop
vMessage := vMessage || 'Disk Name: ' || DiskSpace.name || ' Total: ' || DiskSpace.TOTAL || ' FREE: ' || DiskSpace.FREE || chr(10) || chr(13);
end loop;
utl_mail.send(‘<email>’, vMail_List, vcc_List, NULL, vSubject, vMessage, 'text/plain; charset=us-ascii', NULL);
commit;
exception
when others then
dbms_output.put_line(substr(sqlerrm,1,255));
end;