/usr/local/nagios/etc/objects/mylinux-client.cfg
define host{
use linux-server
host_name mylinux-client
alias mylinux
address 192.168.77.130
#小太阳图标画图
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service{
use generic-service
#使用的是/usr/local/nagios /etc/objects/templates.cfg中所定义的
host_name mylinux-client
service_description Swap Usage
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name mylinux-client
service_description Current Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name mylinux-client
service_description Partition Usage
check_command check_nrpe!check_disk
}
define service{
use generic-service
host_name mylinux-client
service_description Current Users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name mylinux-client
service_description Total Processes
check_command check_nrpe!check_total_procs
}
define service{
use generic-service
host_name mylinux-client
service_description PING
check_command check_nrpe!check_ping
}
define service{
use generic-service
host_name mylinux-client
service_description httpd
check_command check_http! -H 192.168.77.130
#此时ip为监控对方客户端ip!
}
5.2.2 Nagios的监控主机上的配置
因为之前监控主机上,已经将nagios运行起来了,现在要做的事情是:
1) 安装check_nrpe插件并测试与被监控linux主机的联通性
监控机使用check_nrpe与被监控机(192.168.77.130)运行的nrpedaemon之间的通信.
/usr/local/nagios/libexec/check_nrpe -H 192.168.77.130
注意:监控主机与被监控主机使用的nrpe版本要一致!
2) 在commands.cfg中创建check_nrpe的命令定义
因为只有在commands.cfg中定义过的命令才能在services.cfg中使用
vi /usr/local/nagios/etc/commands.cfg(确定是在nagios.cfg定义的)
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
3)在services.cfg文件中创建对被监控主机的监控项目
4)在被监控机上增加check_swap命令的定义
vi /usr/local/nagios/etc/nrpe.cfg
增加下面这一行
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
注意:如果你是以独立的daemon运行的nrpe,那么需要手动重启.如果你是在xinetd或者inetd下面运行的,则不需要.由于我们是xinetd下运行的,所以不需要重启服务