服务器:centos 5.5 172.24.0.1 nagios nagios-plugis nrpe
客户端:centos 5.5 172.24.0.2 nagios-plugins nrpe
因为监控都是依靠插件去完成的,而监控linux主要使用nrpe插件
服务器端
1、安装nrpe
# tar -zxvf nagios-nrpe_2.8.1.orig.tar.gz -C /usr/src/
# rpm -qa | grep ssl
openssl-0.9.8e-12.el5_4.6
# cd /usr/src/nrpe-2.8.1/
# ./configure --enable-ssl --with-ssl-lib=/lib/
configure: error: Cannot find ssl libraries |
解决方法:# yum -y install openssl-devel
# make all
# make install-plugin
# vim /usr/local/nagios/etc/objects/commands.cfg
# 添加
#check nrpe
define command{
command_name check_nrpe
command_line $US ER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
# vim /usr/local/nagios/etc/nagios.cfg 配置要监控的linux主机
添加:37 cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg
# vim /usr/local/nagios/etc/objects/mylinux.cfg 新建监控内容
define host{
use linux-server
host_name mylinux
alias mylinux
address 192.168.0.21(客户端IP既被监控的IP)
}
define service{
use generic-service
host_name mylinux
service_description check-swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name mylinux
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name mylinux
service_description check-disk
check_command check_nrpe!check_had1
}
define service{
use generic-service
host_name mylinux
service_description check-users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name mylinux
service_description otal_procs
check_command check_nrpe!check_total_procs
}
# service nagios restart
客户端配置
# useradd nagios
# passwd nagios
1、安装nagios-plugins
# tar -zxvf nagios-plugins-1.4.14.tar.gz -C /usr/src/
# cd /usr/src/nagios-plugins-1.4.14/
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
# chown -R nagios.nagios /usr/local/nagios/
# cd /usr/local/nagios/
2、安装nagios-nrpe
# tar -zxvf nagios-nrpe_2.8.1.orig.tar.gz -C /usr/src/
# cd /usr/src/nrpe-2.8.1/
# ./configure --enable-ssl --with-ssl-lib=/usr/lib
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# vim /usr/local/nagios/etc/nrpe.cfg
72 allowed_hosts=172.24.0.1
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d 启动nrpe
# netstat -tulnp | grep 5666 验证nrpe
服务器测试
# /usr/local/nagios/libexec/check_nrpe -H 172.24.0.2
NRPE v2.8.1
客户端配置监控对象
# vim /usr/local/nagios/etc/nrpe.cfg
这一步是关键,如果nagios服务器想要监控客户机swap分区,但客户机nrpe.cfg文件没有swap监控对像,这时监控服务器就是报错(NRPE command ‘check_swap’no defined)
至此,查看nagios监控。客户端已经被加入进来。
本文出自 “ 扯、” 博客,转载请与作者联系!