nagios安装:http://blog.youkuaiyun.com/cwg_1992/article/details/16967239
nagios配置:http://blog.youkuaiyun.com/cwg_1992/article/details/16984365
外部插件nrpe的安装,监控oracle
1~4步被监控的主机上执行
1.获取nrpe
http://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
2.安装nagios插件
异步至nagios安装:http://blog.youkuaiyun.com/cwg_1992/article/details/16967239
# cd /usr/src/
# tar -zxvf nagios-plugins-1.5.tar.gz
# cd nagios-plugins-1.5
# ./configure --prefix=/usr/local/nagios
# useradd -s /sbin/nologin nagios
# make && make install
3.安装NRPE插件
# pwd
/usr/src
# tar -zxvf nrpe-2.15.tar.gz
# cd nrpe-2.15
# ./configure
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
4.配置和启动nrpe
# cd /usr/local/nagios/etc/
# cat nrpe.cfg
log_facility=daemon
pid_file=/var/run/nrpe.pid
server_port=5666
nrpe_user=oracle
nrpe_group=oinstall
allowed_hosts=192.168.10.166
dont_blame_nrpe=0
allow_bash_command_substitution=0
debug=0
command_timeout=60
connection_timeout=300
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10 //定义的子命令 详情执行/usr/local/nagios/libexec/commond --help获得
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_cache]=/usr/local/nagios/libexec/check_oracle --cache TEST system test system //检测表空间cache
command[check_tabsp]=/usr/local/nagios/libexec/check_oracle --tablespace TEST system test system 90 80 //检测表空间
command[check_db]=/usr/local/nagios/libexec/check_oracle --db TEST //检测实例
command[check_login]=/usr/local/nagios/libexec/check_oracle --login TEST //检测登录
# /usr/local/nagios/bin/nrpe -4 -d -c /usr/local/nagios/etc/nrpe.cfg //启动服务
测试nrpe子命令的配置
例子:
[root@RAC1 etc]# /usr/local/nagios/libexec/check_oracle --cache TEST system test system
/usr/local/nagios/libexec/check_oracle: line 206: [: system: unary operator expected
/usr/local/nagios/libexec/check_oracle: line 244: [: system: integer expression expected
/usr/local/nagios/libexec/check_oracle: line 248: [: -o: integer expression expected
TEST OK - Cache Hit Rates: 99.20% Lib -- 98.80% Buff|lib=99.20%;;system;0;100 buffer=98.80%;;system;0;100
[root@RAC1 etc]# /usr/local/nagios/libexec/check_oracle --tablespace TEST system test system 90 80
/usr/local/nagios/libexec/check_oracle: line 284: [: : integer expression expected
/usr/local/nagios/libexec/check_oracle: line 288: [: : integer expression expected
/usr/local/nagios/libexec/check_oracle: line 292: [: : integer expression expected
TEST : system OK - % used [ / MB available ]|system=%;80;90;0;100
[root@RAC1 etc]# /usr/local/nagios/libexec/check_oracle --db TEST
TEST Database is DOWN
[root@RAC1 etc]# /usr/local/nagios/libexec/check_oracle --db TEST3
TEST3 OK - 1 PMON process(es) running
以防万一修改check_oracle脚本加上oracle-home和SID
# sed -n '12p;13p' /usr/local/nagios/libexec/check_oracle //在12行和第13上加上如下内容
ORACLE_HOME=/oracle/ora/12.0.1
ORACLE_SID=TEST3
7.测试NRPE
在监控服务器上(nagios服务器)
/usr/local/nagios/libexec/check_nrpe -H 192.168.10.168 -c check_tabsp //命令格式-H指定主机 -c指定子命令 nrpe.cfg 中指定的
TEST : system OK - % used [ / MB available ]|system=%;80;90;0;100
6.配置nagios
# pwd
/usr/local/nagios/etc //加上如下内容
# tail -4 objects/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
# cat objects/service.cfg
#############OGG_MASTER######################
define service{
use oracleogg
host_name OGG_master
service_description NRPE
check_command check_nrpe!check_load
notifications_enabled 0
}
#############OGG_SLAVE######################
define service{
use oracleogg
host_name OGG_slave
service_description NRPE
check_command check_nrpe!check_load
notifications_enabled 0
}
# cat objects/hosts.cfg //定义主机
define host{
use oggnode
host_name OGG_master
alias GGmaster
address 127.0.0.1
}
define host{
use oggnode
host_name OGG_slave
alias GGslave
address 192.168.10.168
}
define hostgroup{
hostgroup_name oracle_ogg
alias goldenget
members OGG_master,OGG_slave
}
7.重启服务收工
# /etc/init.d/nagios restart
# /etc/init.d/httpd restart
打完收工
##############################
本文由笔者原创
作者:john
转载请注明出处