这篇文章主要介绍nagios如何监控linux客户端主机,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
nagios监控linux主机
1.客户端自定义监控服务的插件
cat /usr/local/nagios/libexec/3.py
#!/usr/bin/env python
#coding=utf-8
import os,sys
(d1, d2, d3) = os.getloadavg()
if d1 >= 5.0:
print "GETLOADAVG CRITICAL: Load average is %.2f" % (d1)
sys.exit(2)
elif d1 >= 2.0:
print "GETLOADAVG WARNING: Load average is %.2f" % (d1)
sys.exit(1)
else:
# print "GETLOADAVG OK: Load average is %.2f" % (d1)
print "负载OK
2.编辑vi /usr/local/nagios/etc/nrpe.cfg 最下面添加
command[check_py]=/usr/local/nagios/libexec/3.py [check_py]中名字可以随便定义
3.然后到服务器端调用NRPE测试
/libexec/check_nrpe -H 124.193.179.154 -c check_py #必须和客户端自定义的名字一样
4.在command.cfg里添加外部构件nrpe
vi /usr/local/nagios/etc/objects/commands.cfg
添加
#check nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
5.配置被监控主机:
vim /usr/local/nagios/etc/nagios.cfg
添加:
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
6 编辑配置文件
[root@kimsoo ~]# cat /usr/local/nagios/etc/objects/hosts.cfg
define host{
use linux-server
host_name mylinux
alias mylinux
address 121.54.175.238
}
[root@kimsoo ~]# cat /usr/local/nagios/etc/objects/services.cfg
define service{
use generic-service
host_name mylinux
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name mylinux
service_description check-users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name mylinux
service_description check_total_procs
check_command check_nrpe!check_total_procs
}
7检查配置文件
/usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg
8、重新加载nagios服务
以上是“nagios如何监控linux客户端主机”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。