每天发送邮件监控oracle的存储过程.把这个sp加入到job里面

CREATE OR REPLACE PROCEDURE CheckSpace
IS

used number;
free number;
total number;
hit number;
pins number;
reloads number;
lib number;
smem number;
sdisk number;
para varchar2(4000);
pbytes number;
err number;
BEGIN

 select sum(usedmb),sum(freemb),sum(totalmb)
 into used,free,total
 from
 (
  select usedmb,freemb,totalmb
   from ts_used_free
   where to_char(check_date,'yyyymmdd')=to_char(sysdate,'yyyymmdd')
 );
 SELECT 1 - (phy.value / (cur.value + con.value))
 into Hit FROM v$sysstat cur, v$sysstat con, v$sysstat phy
 WHERE cur.name = 'db block gets' AND con.name = 'consistent gets'
 AND phy.name = 'physical reads';

 select sum(pins) "Total Pins", sum(reloads) "Total Reloads",
     sum(reloads)/sum(pins) *100 libcache
     into pins,reloads,lib
     from v$librarycache;

 
 SELECT  value  into smem
  FROM v$sysstat WHERE name IN ('sorts (memory)');
 SELECT  value  into sdisk
  FROM v$sysstat WHERE name IN ('sorts (disk)');


 select bytes  into pbytes
 from v$sgastat where pool='shared pool' and name ='free memory';


 select count(*) into err
  from alert_tab  WHERE text LIKE '%ORA-%' ;


 para := 'Oracle Pirmary Server Used MB '||'  '
 || to_char(used) || ' ' || ' Free MB' ||'  '
 || to_char(free) || '   ' || ' Total MB'||'  '
 || to_char(total)|| '   ' ||' Data buffer cache Hit Ratio Value is '||'  '
 || to_char(hit)||' ' ||' Share Pool cache Hit Ratio should less than 1%,and the value is  '
 ||'  '
 || to_char(lib)||' ' || '  Memory Sort is '||' '||to_char(smem)||'     Disk Sort is'||'  '
 || to_char(sdisk) ||' '|| 'The Disk/Mem ,the less the better'||'  '
 || 'Share Pool Free Memory bytes:'||' '||to_char(pbytes)  ||'  '
 || 'The ORA- error number in alert log is'|| '  '|| to_char(err);
 
 procsendemail(para) ;
  send_email('shenjie@akey.net.cn',para);  
  send_email('shenjie@itownet.cn',para);  
  send_email('shenjie7810@163.com',para);  
  send_email('luowuhong@itownet.cn',para);  
  /* */
 send_email('suhuilin@itownet.cn',para);  
 send_email('yangyongbing@itownet.cn',para); 
 

END;
/



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9408/viewspace-102254/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9408/viewspace-102254/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值