在CentOS 6.2上部署nagios-3.3.1(續)
九、監控oracle數據庫
1、在監控機10.100.10.11上添加一個check_nrpe的命令
# vi /usr/local/nagios/etc/objects/commands.cfg
define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
2、在監控機10.11上創建一個監控oracle服務的文件oracle.cfg。
# cd /usr/local/nagios/etc/objects
# vi oracle6.cfg
define host {
use linux-server
host_name ledbbackup01
alias Oracle 10g
address 10.100.10.6
}
define service {
use generic-service
host_name ledbbackup01
service_description TNS Check
check_command check_nrpe!check_oracle_tns
}
define service {
use generic-service
host_name ledbbackup01
service_description DB Check
check_command check_nrpe!check_oracle_db
}
define service {
use generic-service
host_name ledbbackup01
service_description Login Check
check_command check_nrpe!check_oracle_login
}
define service {
use generic-service
host_name ledbbackup01
service_description Cache Check
check_command check_nrpe!check_oracle_cache
}
define service {
use generic-service
host_name ledbbackup01
service_description Tablespace Check
check_command check_nrpe!check_oracle_tablespace
}
3、在nagios的配置文件里添加上這個監控的文件
# cd /usr/loca/nagios/etc
# vi nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/oracle6.cfg
4、在oracle服務器上安裝nrpe,具體步驟如上,不再詳述。
添加幾條監控的命令:
# vi /usr/local/nagios/etc/nrpe.cfg
command[check_oracle_tns]=/usr/local/nagios/libexec/check_oracle --tns legold01
command[check_oracle_db]=/usr/local/nagios/libexec/check_oracle --db legold01
command[check_oracle_login]=/usr/local/nagios/libexec/check_oracle --login legold01
command[check_oracle_cache]=/usr/local/nagios/libexec/check_oracle --cache legold01 nagios 123.com 80 90
command[check_oracle_tablespace]=/usr/local/nagios/libexec/check_oracle --tablespace legold01 nagios 123.com USERS 90 80
具體的命令格式可參考check_oracle的help文檔。
5、在oracle服務器上將check_oracle插件修改一下:將 $ORACLE_HOME 以及 $PATH 手動加入,避免出現問題。
export ORACLE_HOME=/home/oracle/app/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
此時,可以啟動nrpe服務了:
# service nrped start
對了,別忘記了在10.11監控機上將nagios服務重啟一下:
# service nagios restart
6此時,打開瀏覽器查看:
http://10.100.10.11/nagios
好像出錯了,仔細察看了一下nagios的錯誤日志,發現監控機10.11上沒有check_nrpe 的插件,所以還要進行如下步驟:
7、copy oracle服務器10.6上的check_nrpe 到10.11上
# scp check_nrpe root@10.100.10.11:/usr/local/nagios/libexec
在10.11上:
# cd /usr/local/nagios/libexec
# ./check_nrpe
./check_nrpe: error while loading shared libraries: libssl.so.6: cannot open shared object file: No such file or directory
沒有libssl.so.6的庫文件,
解決方法:
在10.6上:
# find / -name libssl.so.6
/lib64/libssl.so.6
/lib/libssl.so.6
# scp /lib64/libssl.so.6 root@10.100.0.8:/lib64
# scp /lib/libssl.so.6 root@10.100.0.8:/lib
8、在10.11上:
# cd /usr/local/nagios/libexec
# ./check_nrpe
./check_nrpe: error while loading shared libraries: libcrypto.so.6: cannot open shared object file: No such file or directory
還是缺少庫文件,不用怕,繼續到10.6上拷貝,這叫越挫越勇!
在10.6上:
# find / -name libcrypto.so.6
/lib64/libcrypto.so.6
/lib/libcrypto.so.6
# scp /lib/libcrypto.so.6 root@10.100.0.8:/lib
# scp /lib64/libcrypto.so.6 root@10.100.0.8:/lib64
9、好吧,再回到10.11上嘗試一下:
#./check_nrpe
Incorrect command line arguments supplied
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad (nagios@nagios.org)
Version: 2.13
Last Modified: 11-11-2011
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required
Usage: check_nrpe -H <host> [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]
Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line.
此時就說明check_nrpe可以用了!真的好難得哦!
# ./check_nrpe -H 10.100.10.6 -p 5666
NRPE v2.13
10、重新啟動nagios服務:
# service nagios restart
輸入ip地址查看一下:
http://10.100.10.11/nagios
好了,就先記錄到這里吧,作為以后的參考文檔。
歲月靜好,歲月靜好。
(*^__^*) 嘻嘻……