• 开发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
    

    结果验证

    对于一个有思想的人来说,没有地方是荒凉而遥远的
  • 相关阅读:
    Python上下文管理器
    面向对象(三)【类的特殊成员及高级特性】
    面向对象(二)【类的成员及修饰符】
    面向对象(一)【“类与对象”的概念及特性】
    leetcode【14题】Longest Common Prefix
    Spring Cloud之Zuul
    Spring Cloud之Hystrix
    SpringCloud之Eureka、Ribbon
    synchronized块中的wait()、nofity()、nofityAll()方法
    IP的分类以及子网划分、网络设置
  • 原文地址:https://www.cnblogs.com/quanag/p/9137900.html
Copyright © 2020-2023  润新知