日期:2014-05-17 浏览次数:20885 次
-- 下面是我的实现代码(当然,在写过程前,你得有你们的邮件服务器,且在oracle中配置好ACL)
-- 一、监控土豆北京Oracle数据库服务器各表空间的使用情况:
-- 在以上4台服务器的data_monitor用户中创建视图:
GRANT SELECT ON DBA_FREE_SPACE TO DATA_MONITOR;
GRANT SELECT ON DBA_DATA_FILES TO DATA_MONITOR;
GRANT CREATE VIEW TO DATA_MONITOR;
CREATE OR REPLACE VIEW data_monitor.tablespace_info
AS
SELECT a.tablespace_name as tablespace_name,
to_char(b.total/1024/1024,999999.99) as Total,
to_char((b.total-a.free)/1024/1024,'9999990D99') as Used,
to_char(a.free/1024/1024,'9999990D99') as Free,
to_char(round((total-free)/total,4)*100,'9999990D99')
------解决方案--------------------
'%' as Used_Rate
FROM (SELECT tablespace_name, sum(bytes) free FROM SYS.DBA_FREE_SPACE GROUP BY tablespace_name) a,
(SELECT tablespace_name, sum(bytes) total FROM SYS.DBA_DATA_FILES GROUP BY tablespace_name ) b
WHERE a.tablespace_name=b.tablespace_name
AND round((total-free)/total,4)*100 > 90
ORDER BY round((total-free)/total,4) DESC;
----------------------------------------
-- *1). 创建存储过程用以监控各表空间的使用情况
create or replace PROCEDURE pro_get_tbs_info
AS
/******************************************************************************