前提:把check_mem.sh放到/usr/local/nagios/libexec下,并赋予执行权限
chmod 755 check_mem.sh
一,监控本地(监控端本身)内存使用:
#修改commands配置
vim /usr/local/nagios/etc/objects/commands.cfg
#增加以下内容
define command{
command_name check_mem
command_line $USER1$/check_mem.sh -w $ARG1$ -c $ARG2$
}
#增加以下内容
define command{
command_name check_mem
command_line $USER1$/check_mem.sh -w $ARG1$ -c $ARG2$
}
#修改localhost.cfg
vim /usr/local/nagios/etc/objects/localhost.cfg
#增加以下内容
define service{
use local-service
host_name localhost
service_description memory
check_command check_mem!20!10!
}
#增加以下内容
define service{
use local-service
host_name localhost
service_description memory
check_command check_mem!20!10!
}
二,监控客户端内存使用情况:
1,#修改客户端配置文件
vim /usr/local/nagios/etc/nrpe.cfg
#增加以下内容
command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w 20 -c 10
2,#修改主控制端相关配置文件
vim /usr/local/nagios/etc/service/liguxk.cfg #主控端定义的被控端的配置文件
#增加以下内容
define service{
use generic-service
host_name liguxk
service_description Memory
check_command check_nrpe!check_mem
}
三,总结
监控本地资源的调用流程为:
localhost.cfg—>command.cfg—>libexec
监控客户端流程:
liguxk.cfg—>服务器nrpe——>客户端nrpe.cfg—>客户端libexec
转载于:https://blog.51cto.com/liguxk/236845