利用nsca监控oracle的session数
环境:
192.168.9.130 监控服务器
192.168.9.142 testdb 监控的数据库及数据库testdb
检查脚本: check_session.sh
[oracle@test1 ~]:testdb> pwd
/home/oracle
[oracle@test1 ~]:testdb> ll
total 52
-rw-r--r--. 1 oracle oinstall 295 Jan 19 10:17 check_session.sh
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Desktop
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Documents
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Downloads
-rw-r--r--. 1 oracle oinstall 2157 Nov 5 09:47 marker_setup_set.txt
-rw-r--r--. 1 oracle oinstall 434 Nov 5 09:47 marker_setup_spool.txt
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Music
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Pictures
-rw-r--r--. 1 root root 771 Nov 6 10:17 prof_testdb
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Public
-rw-r--r--. 1 oracle oinstall 40 Jan 19 10:17 sesion_status.log
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Templates
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Videos
[oracle@test1 ~]:testdb>
[oracle@test1 ~]:testdb>
[oracle@test1 ~]:testdb> cat check_session.sh
IP=192.168.9.142
SID=TESTDB
status=`sqlplus -silent "/as sysdba" < set feedback off
set verify off
set heading off
set echo off
set pagesize 0
SELECT COUNT(*) FROM V\\$SESSION;
exit;
eof`
hostip=$IP
checkname="session_number_"$SID
echo -e "$hostip\t$checkname\t$status" > sesion_status.log
/usr/local/nagios/bin/send_nsca 192.168.9.130 -c /usr/local/nagios/etc/send_nsca.cfg < session_status.log
[oracle@test1 ~]:testdb>
写入的状态文件sesion_status.log
[oracle@test1 ~]:testdb> cat sesion_status.log
192.168.9.142 session_number_TESTDB 24
[oracle@test1 ~]:testdb>
环境:
192.168.9.130 监控服务器
192.168.9.142 testdb 监控的数据库及数据库testdb
检查脚本: check_session.sh
[oracle@test1 ~]:testdb> pwd
/home/oracle
[oracle@test1 ~]:testdb> ll
total 52
-rw-r--r--. 1 oracle oinstall 295 Jan 19 10:17 check_session.sh
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Desktop
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Documents
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Downloads
-rw-r--r--. 1 oracle oinstall 2157 Nov 5 09:47 marker_setup_set.txt
-rw-r--r--. 1 oracle oinstall 434 Nov 5 09:47 marker_setup_spool.txt
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Music
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Pictures
-rw-r--r--. 1 root root 771 Nov 6 10:17 prof_testdb
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Public
-rw-r--r--. 1 oracle oinstall 40 Jan 19 10:17 sesion_status.log
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Templates
drwxr-xr-x. 2 oracle oinstall 4096 Jul 10 2014 Videos
[oracle@test1 ~]:testdb>
[oracle@test1 ~]:testdb>
[oracle@test1 ~]:testdb> cat check_session.sh
IP=192.168.9.142
SID=TESTDB
status=`sqlplus -silent "/as sysdba" < set feedback off
set verify off
set heading off
set echo off
set pagesize 0
SELECT COUNT(*) FROM V\\$SESSION;
exit;
eof`
hostip=$IP
checkname="session_number_"$SID
echo -e "$hostip\t$checkname\t$status" > sesion_status.log
/usr/local/nagios/bin/send_nsca 192.168.9.130 -c /usr/local/nagios/etc/send_nsca.cfg < session_status.log
[oracle@test1 ~]:testdb>
写入的状态文件sesion_status.log
[oracle@test1 ~]:testdb> cat sesion_status.log
192.168.9.142 session_number_TESTDB 24
[oracle@test1 ~]:testdb>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29500582/viewspace-1406502/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29500582/viewspace-1406502/