zoukankan      html  css  js  c++  java
  • lnmp监控----nagios与飞信整合实现短信监控

    将飞信拷贝到nagios命令目录

    cp fetion /usr/local/nagios/libexec/
    chmod +x /usr/local/nagios/libexec/fetion
    tar zxf linuxso_20101113.tar.gz -C  /lib
    chown nagios.nagios /usr/local/nagios/libexec/fetion
    su - nagios
    中间可能用到的包
    yum install /lib/ld-linux.so.2
    发送飞信短信
    /usr/local/nagios/libexec/fetion --mobile=13679270227 --pwd=Yakexi007 --to=186***** --msg-utf8="hello"
    如果想要nagios发送短信需要
    cd /usr/local/nagios/libexec/
    vim fetion.sh
    在里面写入
    /usr/local/nagios/libexec/fetion --mobile=186***** --pwd=***** --to="$1" --msg-utf8="$2"
    之后修改其他文件
    cd /usr/local/nagios/etc/objects/
    vim commands.cfg
    添加一下内容
     
    # 'notify-host-by-fetion' command definition
    define command{ command_name    notify-host-by-fetion command_line    $USER1$/fetion.sh   $CONTACTPAGER$   "$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ " } # 'notify-service-by-fetion' command definition define command{ command_name    notify-service-by-fetion command_line    $USER1$/fetion.sh   $CONTACTPAGER$   "$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ " }
    //$USER1$/fetion.sh相当于/usr/local/nagios/libexec/fetion.sh
    //$CONTACTPAGER$ 是那个命令里面的$1
    //"$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ "是$2
    之后修改
    vim templates.cfg
    service_notification_commands   notify-service-by-email,notify-service-by-fetion
    host_notification_commands      notify-host-by-email,notify-host-by-fetion //在34,35行后面添加
    vim contacts.cfg
    添加
    pager                           186******                    //在36行添加联系人
    文件修改部分整体内容如下
    define contact{ contact_name                    nagiosadmin             ; Short name of user use                             generic-contact         ; Inherit default values from generic-contact template (defined above) alias                           Nagios Admin            ; Full name of useremail                           nagios@localhost        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******   pager                          186****** }
    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 做完之后一定要检查语法。并且重启服务
  • 相关阅读:
    55、分页查询employees表,每5行一页,返回第2页的数据
    54、查找排除当前最大、最小salary之后的员工的平均工资avg_salary
    53、按照分组拼接字段
    52、获取Employees中的first_name
    51、查找字符串'10,A,B' 中逗号','出现的次数cnt
    图片素材
    软件下载
    一款高效卸载软件
    《单独.17 人的困境》(摘抄)
    Markdown的简单使用
  • 原文地址:https://www.cnblogs.com/Seven-Wang/p/4451583.html
Copyright © 2011-2022 走看看