1.首先下载所需要的nagios被监控端的插件:
wget
wget
wget
在这里感谢 石头编写的脚本。
2.配置snmp
我这里是用centos 的yum安装的
yum -y install net-snmp*
修改/etc/snmp/snmp.conf
改为
改为
去掉前面的注释
改完保存退出
snmp.conf文件在附件中也可以去下载
server snmpd restart
2.安装nrpe和nagios-plugin
先创建nagios用户
useradd -m nagios
tar zxvf nrpe-2.8.tar.gz
cd nrpe-2.8
./confiugre
make all
make install
make install-daemon-config
make install-daemon
make install-plugin
tar zxvf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure --with-mysql=/usr/local/webserver/mysql
make
make install
cd nrpe-2.8
./confiugre
make all
make install
make install-daemon-config
make install-daemon
make install-plugin
tar zxvf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure --with-mysql=/usr/local/webserver/mysql
make
make install
3.编辑nrpe.cfg
拷贝check_traffic.sh到/usr/local/nagios/libexec
首先查看能监听到的网卡
vi /usr/local/nagios/etc/nrpe.cfg
添加
command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C nagios -H localhost -I 3 -w 12,30 -c 15,35 -M -b -6
注:-w -c选项为阀值
别忘了添加权限
chown -R nagios /var/tmp/
否则监控端无法获取数据
启动nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
添加启动项echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >>/etc/rc.local 查看是否端口在监听,端口是5666
4.监控端的配置
编辑servers.cfg
define service {
host_name tc-169.194
use local-service,srv-pnp
service_description traffic
check_period 24x7
max_check_attempts 4
normal_check_interval 1
retry_check_interval 1
contact_groups nagcmd
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_traffic
}
host_name tc-169.194
use local-service,srv-pnp
service_description traffic
check_period 24x7
max_check_attempts 4
normal_check_interval 1
retry_check_interval 1
contact_groups nagcmd
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_traffic
}
然后重启nagios
5.验证效果
由于我添加了pnp插件,有图像绘制的效果。 下次准备写一篇关于nagios+pnp的文章