被监控机安装nrpe
准备工作:
apt-get install openssl
apt-get install libcurl3-openssl-dev
apt-get install xinetd下载:
http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
tar -zxf nrpe-2.13.tar.gz
cd nrpe-2.13开始安装:
./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu(可能64位和32位有所不同)
make all && make install-plugin && make install-daemon && make install-daemon-config
make install-xinetd编辑 /etc/xinetd.d/nrpe 将nagios的服务器ip添加进去
将NRPE进程端口加到/etc/services中
nrpe 5666/tcp
重新启动xinetd服务
service xinetd restart确认nrpe是否在xinetd下运行
netstat -at |grep nrpe测试nrpe是否工作
/usr/local/nagios/libexec/check_nrpe -H localhost
服务器配置:
同样安装nrpe.
检查命令行是否可查到被监控主机nrpe信息:
/usr/local/nagios/libexec/check_nrpe -H 192.168.0.被监控1:创建command定义
编辑/usr/local/nagios/etc/objects/commands.cfg增加以下配置信息
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}2:定义主机和服务设定
先建立一个模板用于之后的主机监控的继承设定(在/usr/local/nagios/etc/objects/templates.cfg已经有添加了这个模板规则,只是notification_period不一样而已,关于这个的解释也非常有意思可以自己看看)
define host{
name linux-server ; Name of this template
use generic-host ; Inherit default values
check_period 24×7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24×7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS – ITS A TEMPLATE
}3:编辑/usr/local/nagios/etc/objects/localhost.cfg(也可以自己创建文件,只要在nagios.cfg中添加对应配置)
增加被监控的主机对象define host{
use linux-server
host_name web-server ;nrpe check host
alias ubuntu server (WWW)
address 192.168.200.244
}增加监控远程服务器的服务对象
define service{
use generic-service
host_name web-server
service_description CPU Load
check_command check_nrpe!check_load
}define service{
use generic-service
host_name web-server
service_description Current Users
check_command check_nrpe!check_users
}磁盘监控需要确认自己的硬盘是hda 还是sda,nrpe安装的默认配置是check_hda1,所以需要你手动修改被监控服务器的/usr/local/nagios/etc/nrpe.cfg,将hda修改为sda。并重新启动xinetd服务
define service{
use generic-service
host_name web-server
service_description /dev/sda1 Free Space
check_command check_nrpe!check_sda1
}define service{
use generic-service
host_name web-server
service_description Total Processes
check_command check_nrpe!check_total_procs
}define service{
use generic-service
host_name web-server
service_description Zombie Processes
check_command check_nrpe!check_zombie_procs
}
配置完成后,运行/etc/init.d/nagios checkconfig
或
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
本文出自 “技术交流” 博客,请务必保留此出处http://chenshengang.blog.51cto.com/4399161/1357315
原文:http://chenshengang.blog.51cto.com/4399161/1357315