监控和安全运维 1.6 nagios监控客户端-2
6. 继续添加服务
服务端
vim /etc/nagios/objects/commands.cfg
增加:
define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
继续编辑
vim /etc/nagios/conf.d/192.168.1.111.cfg
define service{
use generic-service
host_name 192.168.1.111
service_description check_load
check_command check_nrpe!check_load
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name 192.168.1.111
service_description check_disk_sda1
check_command check_nrpe!check_hda1
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name 192.168.1.111
service_description check_disk_sda3
check_command check_nrpe!check_hda3
max_check_attempts 5
normal_check_interval 1
}
check_nrpe!check_load :这里的check_nrpe就是在commands.cfg刚刚定义的,check_load是远程主机上的一个检测脚本
客户端
在远程主机上
vim /etc/nagios/nrpe.cfg
搜索check_load,这行就是在服务端上要执行的脚本了,我们可以手动执行这个脚本
把check_hda1更改一下: /dev/hda1 改为 /dev/sda1 再加一行 command[check_hda3]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda3
客户端上重启一下nrpe服务:
service nrpe restart
服务端也重启一下nagios服务:
nagios -v /etc/nagios/nagios.cfg
service nagios restart
查看服务端日志
tail /var/log/nagios/nagios.log