NRPE的作用是在远程主机上运行Nagios插件,以便监控远程主机。
Ubuntu Server下安装NRPE很方便:
$ sudo apt-get install nagios-nrpe-server nagios-plugins
默认的几个检查命令(check_users, check_load等)都已经在/etc/naigos/nrpe.cfg和/etc/nagios/nrpe_local.cfg配置好了。在Nagios里配置监控服务使用类似如下的监控命令就可以了:
check_command check_nrpe!check_load
如果需要自定义监控命令,只需在/etc/nagios/nrpe_local.cfg里设置,重启NRPE服务,再在Nagios里配置监控服务即可。比如,要添加一个监控TCP各种状态的命令,步骤如下:
@remotehost
$ cd /usr/lib/nagios/plugins
$ sudo wget http://www.tuschy.com/nagios/plugins/check_tcp_count
$ sudo chmod +x check_tcp_count
$ cd /etc/nagios
$ sudo vi nrpe_local.cfg
command[check_tcp_count]=/usr/lib/nagios/plugins/check_tcp_count
$ sudo service nagios-nrpe-server restart
@nagioshost
$ sudo vi remotehost.cfg
define service{
use generic-service
host_name remotehostname
service_description Tcp count
check_command check_nrpe!check_tcp_count
}