oracle會話監控shell指令碼

kidking2010發表於2012-06-19
#####################
#dbsessioncheck.sh###
#create date:2012-05-17
#####################
#!/bin/bash
#source /oracle/.bash_profile
sqlplus -s "/as sysdba" << EOF_A
spool /oracle/count_session_values.log
set head off
set feedback off
select count(*) from v\$session;
spool off
spool /oracle/install_set_values.log
set head off
set feedback off
select value from v\$parameter where name='processes';
spool off
exit
EOF_A
for i in `cat count_session_values.log  | sed '/^$/d'`;do echo $i;done > 11
for i in `cat install_set_values.log  | sed '/^$/d'`;do echo $i;done > 22
if [ `cat 11` -lt `cat 22` ];then echo "db link session is normal!"
else
echo "`date +%N`|YY|31|資料庫連線session數超過設定值|101|資料庫連線session數超過設定值|`date +"%Y-%m-%d %H:%M:%S"`|3|當前會話數:`cat 11`設定值:`cat 22`|資料庫連線session數超過設定值">>/oracle/db_status_alert.log
fi

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23141985/viewspace-733244/,如需轉載,請註明出處,否則將追究法律責任。

相關文章