• 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 做完之后一定要检查语法。并且重启服务
  • 相关阅读:
    Fastjson
    react 使用createContext、Consumer 及 useContext 、Class.contextType父子组件共享数据
    使用useReducer 实现 todoList
    react中 useMemo与useCallback使用
    react17 函数组件 使用 better-scroll2.0 封装方法 及 使用
    react 执行 yarn build ,无法直接打开dist文件下的index
    react-redux 持久数据存储
    document.body.removeChild 获取到 symbol 标签
    react嵌套路由,并设置默认子路由
    Vagrant环境下配置node_exporter、mysqld_exporter、prometheus、grafana
  • 原文地址:https://www.cnblogs.com/Seven-Wang/p/4451583.html
Copyright © 2020-2023  润新知