欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

开发nagios插件监控/etc/passwd中文件变化

发布时间:2025/7/14 编程问答 29 豆豆
生活随笔 收集整理的这篇文章主要介绍了 开发nagios插件监控/etc/passwd中文件变化 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

环境:

nagios客户端:centos6.5

[root@long63 nagios]# uname -r 2.6.32-431.el6.x86_64 [root@long63 nagios]# ifconfig eth0|grep "inet addr"|awk -F '[ :]' '{print $13}' 192.168.200.63  

nagios服务端:centos6.5 

[root@long62 /]# uname -r 2.6.32-431.el6.x86_64 [root@long62 nagios]# ifconfig eth0|grep "inet addr"|awk -F '[ :]' '{print $13}' 192.168.200.62

操作步骤:

第一步:【客户端】开发脚本,并授权脚本

[root@long63 libexec]# cat check_md5_ps #!/bin/sh PROGNAME=`basename $0` PROGPATH=`dirname $0` . $PROGPATH/utils.sh OriMD5="d6f7ff0f80e82d8288cfb53f1be07808" CurrMd5=`md5sum /etc/passwd|cut -c 1-32` if [ "$OriMD5" == "$CurrMd5" ]thenecho "/etc/passwd:OK"exit 0 elseecho "/etc/passwd:flase"exit 2 fi

  

[root@long63 libexec]# chmod 755 check_md5_ps

  

第二步:【客户端】在nrpe.cfg里面添加一行

command[check_md5]=/usr/local/nagios/libexec/check_md5_ps

  

第三步:【客户端】重启nrpe

[root@long63 libexec]# ps -ef|grep nrpe nagios 4258 1 0 08:24 ? 00:00:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d root 4262 4133 0 08:25 pts/0 00:00:00 grep nrpe [root@long63 libexec]# pkill nrpe [root@long63 libexec]# ps -ef|grep nrpe root 4265 4133 0 08:25 pts/0 00:00:00 grep nrpe [root@long63 libexec]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d [root@long63 libexec]# ps -ef|grep nrpe nagios 4267 1 0 08:25 ? 00:00:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d root 4269 4133 0 08:25 pts/0 00:00:00 grep nrpe

  

第四步【服务端】services.cfg里面添加服务

define service{use generic-servicehost_name 063-client01check_command check_nrpe!check_md5service_description md5_etc_passwdmax_check_attempts 3normal_check_interval 10retry_check_interval 2contact_groups adminsnotification_options w,u,c,rnotification_interval 60notification_period 24x7check_period 24x7 }

  

第五步:【服务端】重启nagios服务

[root@long62 services]# /etc/init.d/nagios checkconfig Running configuration check... OK. [root@long62 services]# /etc/init.d/nagios reload Running configuration check...done. Reloading nagios configuration...done

结果验证

转载于:https://www.cnblogs.com/quanag/p/9137900.html

总结

以上是生活随笔为你收集整理的开发nagios插件监控/etc/passwd中文件变化的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。