• zabbix调用微信接口报警


    1.下载微信接口

    git clone https://github.com/lealife/WeiXin-Private-API

    将微信接口移动至zabbix默认脚本路径

    zabbix默认脚本路径:/usr/lib/zabbix/alertscripts/

    [root@zabbix alertscripts]# vim WeiXin-Private-API/config.php

    <?php

    // 全局配置

    $G_ROOT = dirname(__FILE__);

    $G_CONFIG["weiXin"] = array(
    'account' => '3133187148@qq.com',  ###微信公众账号
    'password' => '微信公众账号密码',
    'cookiePath' => $G_ROOT. '/cache/cookie', // cookie缓存文件路径
    'webTokenPath' => $G_ROOT. '/cache/webToken', // webToken缓存文件路径
    );

    [root@zabbix alertscripts]# vim WeiXin-Private-API/test.php

    <?php
    require "config.php";
    require "include/WeiXin.php";

    $weiXin = new WeiXin($G_CONFIG['weiXin']);

    #$testFakeId = "oIzQiwod4i3VoLqTB5cgTQUUz76s";         
    $testFakeId = "$argv[1]";

    $msg="$argv[3]";


    #print_r($weiXin->send($testFakeId, "test"));
    echo "<pre>";
    print_r($weiXin->send($testFakeId, "$msg"));

    [root@zabbix alertscripts]# pwd
    /usr/lib/zabbix/alertscripts
    [root@zabbix alertscripts]# vim weixin.sh

    /usr/bin/php /usr/lib/zabbix/alertscripts/WeiXin-Private-API/test.php "$1" "$2" "$3"

    进行测试

    [root@zabbix alertscripts]# /usr/lib/zabbix/alertscripts/weixin.sh "oIzQiwod4i3VoLqTB5cgTQUUz76s" "" "hi"

    stdClass Object
    (
    [base_resp] => stdClass Object
    (
    [ret] => 0
    [err_msg] => ok
    )

    )

     测试成功!

    !!!注意:若遇到以下情况,清除缓存

    stdClass Object
    (
    [base_resp] => stdClass Object
    (
    [ret] => 200003
    [err_msg] => invalid session
    )

    )

    [root@zabbix alertscripts]# cd WeiXin-Private-API/
    [root@zabbix WeiXin-Private-API]# ls
    cache config.php include README.md test.php
    [root@zabbix WeiXin-Private-API]# cd cache/
    [root@zabbix cache]# ls
    cookie webToken
    [root@zabbix cache]# rm -fr *

    网页添加weixin报警媒介

  • 相关阅读:
    OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django'
    mac 安装pip
    同学公司倒闭了
    web开发中的字体选择(同事分享)
    svg 学习笔记
    用highchaarts做股票分时图
    highcharts,highStock 中文图表配置
    为什么使用 npm Scripts 构建项目
    JS 浮点型计算的精度问题 推荐的js 库 推荐的类库 Numeral.js 和 accounting.js
    HTML代码转换为JavaScript字符串
  • 原文地址:https://www.cnblogs.com/xfbc/p/5330121.html
Copyright © 2020-2023  润新知