您好,登录后才能下订单哦!
NRPE扩展插件包含两个部分:
a)check_nrpe插件,在监测主机上运行
b)NRPE守护进程,运行在远程机器上,用于监测远程Linux/Unix机器
当Nagios需要监测远程主机的服务资源时:
a)Nagios将执行check_nrpe插件并告诉它需要监测的服务
b)check_nrpe插件通过受保护的加密方式(可选)来连接远程主机上的NRPE守护进程
c)NRPE守护进程通过运行相应的Nagios插件来监测本机上的服务或资源
d)来自NRPE守护进程的服务监测结果被反馈给监测主机上的check_nrpe插件,这一监测结果表示Nagios进程的监测结果。
注意:NRPE守护进程要求远程Linux/Unix主机必须安装Nagios插件,否则,守护进程发挥不了任何作用。
为了完成以下安装操作,你必须要:
a)以root身份来访问远程Linux/Unix主机
b)以nagios用户账户来访问监测主机
/usr/sbin/useradd nagios –s /sbin/nologin
passwd nagios
wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
tar xvf nagios-plugins-2.0.tar.gz
cd nagios-plugins-2.0
./configure && make && makeinstall
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios/usr/local/nagios/libexec
yum install xinetd
#解压
tar xvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
vim /etc/xinetd.d/nrpe
only_from = 127.0.0.1<nagios_ip_address>
#我修改的内容如下(逗号之间没有空格)
only_from =127.0.0.1,10.10.54.111,10.10.54.112
vim /etc/services
nrpe 5666/tcp # NRPE
service xinetd restart
netstat -at | grep nrpe #显示下面的结果是正确的
tcp 0 0 *:nrpe *:* LISTEN
如果不正确,请确定您已经完成了一下内容:
– You added the nrpe entry to your /etc/services file
– The only_from directive in the /etc/xinetd.d/nrpe file contains anentry for "127.0.0.1"
– xinetd is installed and started
– Check the system log files for references about xinetd or nrpe andfix any problems that are reported
/usr/local/nagios/libexec/check_nrpe -Hlocalhost #出现下面的结果不要担心,试试下一条命令
CHECK_NRPE: Error - Could not complete SSLhandshake. #我没有解决这个问题
/usr/local/nagios/libexec/check_nrpe -H127.0.0.1 #下面的结果是正确的,安装成功
NRPE v2.15
/usr/local/nagios/libexec/check_nrpe -H10.10.54.112 #下面的结果是正确的,安装成功
NRPE v2.15
iptables -I RH-Firewall-1-INPUT -p tcp -mtcp –dport 5666 -j ACCEPT
service iptables save
vim /usr/local/nagios/etc/nrpe.cfg
command[check_users]=/usr/local/nagios/libexec/check_users-w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load-w 15,10,5 -c 30,25,20
#被我注释掉的这个命令没有用了,因为现在的磁盘不是/dev/hda1的了
#command[check_hda1]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /dev/hda1
#下面这个命令是我添加的,经测试,有效
command[check_sda1]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /dev/sda1
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
#测试我刚才自定义的命令
/usr/local/nagios/libexec/check_disk -w 20%-c 10% -p /dev/sda1
DISK OK - free space: /boot 158 MB (86%inode=99%);| /boot=25MB;154;173;0;193
/usr/local/nagios/bin/nrpe -c/usr/local/nagios/etc/nrpe.cfg –d
– Install the check_nrpe plugin
– Create a Nagios command definition for using the check_nrpe plugin
– Create Nagios host and service definitions for monitoring theremote host
wget http://ncu.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar xvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
/usr/local/nagios/libexec/check_nrpe -H 10.10.54.112
NRPE v2.15
vim /usr/local/nagios/etc/objects/commands.cfg
#添加以下内容
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#定义host
define host{
name linux-box ; Name of this template
use generic-host ; Inherit default values
check_ period 24x7
check_ interval 5
retry_ interval 1
max_check_ attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS ATEMPLATE
}
#定义service
#监测CPU
define service{
use generic-service
host_name remotehost
service_description CPU Load
check_command check_nrpe!check_load
}
#监测在线用户
define service{
use generic-service
host_name remotehost
service_description Current Users
check_command check_nrpe!check_users
}
#检测/dev/sda1的空间
define service{
use generic-service
host_name remotehost
service_description /dev/sda1 Free Space
check_command check_nrpe!check_sda1
}
#监测进程数
define service{
use generic-service
host_name remotehost
service_description Total Processes
check_command check_nrpe!check_total_procs
}
#监测僵尸进程
define service{
use generic-service
host_name remotehost
service_description ZombieProcesses
check_command check_nrpe!check_zombie_procs
}
/usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg
Things look okay - No serious problems weredetected during the pre-flight check
service nagios restart
在浏览器输入http://10.10.54.111/nagios查看
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。