zoukankan      html  css  js  c++  java
  • 开发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" ]
      then
        echo "/etc/passwd:OK"
        exit 0
    else
        echo "/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-service
            host_name                       063-client01
            check_command                   check_nrpe!check_md5
            service_description             md5_etc_passwd
            max_check_attempts              3
            normal_check_interval           10
            retry_check_interval            2
            contact_groups                  admins
            notification_options            w,u,c,r
            notification_interval           60
            notification_period             24x7
            check_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
    

    结果验证

    对于一个有思想的人来说,没有地方是荒凉而遥远的
  • 相关阅读:
    [NOI2005]维护数列——Splay
    [Poi2000]病毒——补全AC自动机
    POJ1509 Glass Beads——SAM(后缀自动机)
    「NOI2011」阿狸的打字机——AC自动机+树状数组
    7.12Test——Graph Theory 1
    [BJWC2010]严格次小生成树
    7.09Test——DS1
    [SCOI2015]小凸想跑步——半平面交
    词频统计器(第三版)
    四则运算(测试)
  • 原文地址:https://www.cnblogs.com/quanag/p/9137900.html
Copyright © 2011-2022 走看看