亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home WeChat Applet WeChat Development Detailed explanation of WeChat alarm zabbix implementation

Detailed explanation of WeChat alarm zabbix implementation

Feb 20, 2017 pm 02:33 PM

This article mainly introduces the relevant information on WeChat alarm zabbix method. Friends who need it can refer to it

In real production environment, we usually use email and SMS to receive zabbix alarm information, but email is often used by work Personnel are left in corners or even set to be filtered out as spam. The company's SMS interface is too expensive, and using SMS alarms in complex environments will increase operation and maintenance costs a lot. WeChat provides a good third-party interface. We can use WeChat to alarm in order to reduce operation and maintenance costs.

WeChat’s third-party interface requires us to apply for an enterprise account first - portal: https://qy.weixin.qq.com/

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

How to operate the enterprise account?

1. Add corporate members to the address book

We need to add member information to the organizational department in advance, required fields + mobile phone number or WeChat ID, so Only when others scan the QR code can they successfully follow the enterprise account.

Note: Here are two we need to use information, an ID of an organization department, the account number of a department member (the account is manually specified by itself, unlike WeChat, preferably the letter plus numbers)

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

#2. Create an application in the Application Center

We are going to create an application here because we need Send a message to department members through the application

Note: There is a value to remember here, the application ID

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

# #3. Set up an administrator for the department

Settings--->Function Settings---->Permission Management---->New management group

Administrators You must have followed the enterprise account in advance and set up your email address

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

Make sure the administrator can read the address book and use the app to send messages.

Note: We need the administrator’s CorpID and Secret

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

We need to prepare these things:

A WeChat enterprise account

The enterprise account has been followed by department members

There is an application in the enterprise account that can send messages

An authorized administrator can use the application to send messages to members

We want to get this information:

Member Account

Organization Department ID

Application ID

CropID

Secret

How to call the WeChat interface?

Calling the WeChat interface requires a certificate for calling the interface: access_token

Access_token can be obtained through: CropID and Secret, but the token obtained is valid for two minutes

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

??????? 微信企業(yè)號(hào)接口調(diào)試工具傳送門:http://qydev.weixin.qq.com/debug

Shell腳本原理

??????? 使用:

??????? curl -s -G? url?????????? 獲取 AccessToken

??????? 使用:

??????? curl --data? url???? 傳送憑證調(diào)用企業(yè)號(hào)接口


??????? zabbix會(huì)傳遞三個(gè)參數(shù)給腳本,$1是消息接收賬號(hào),$2報(bào)警標(biāo)題,$3報(bào)警內(nèi)容

#!/bin/bash
###SCRIPT_NAME:weixin.sh###
###send message from weixin for zabbix monitor###
###wuhf###
###V1-2015-08-25###

CropID=‘xxxxxx‘
Secret=‘xxxxxx‘
GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CropID&corpsecret=$Secret" 
Gtoken=$(/usr/bin/curl -s -G $GURL | awk -F\" ‘{print $4}‘)

PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken"

function body() {
    local int AppID=3            企業(yè)號(hào)中的應(yīng)用id
    local UserID=$1             部門成員id,zabbix中定義的微信接收者
    local PartyID=1             部門id,定義了范圍,組內(nèi)成員都可接收到消息
    local Msg=$(echo "$@" | cut -d" " -f3-) 過濾出zabbix中傳遞的第三個(gè)參數(shù)
    printf ‘{\n‘
    printf ‘\t"touser": "‘"$User"\"",\n"
    printf ‘\t"toparty": "‘"$PartyID"\"",\n"
    printf ‘\t"msgtype": "text",\n‘
    printf ‘\t"agentid": "‘" $AppID "\"",\n"
    printf ‘\t"text": {\n‘
    printf ‘\t\t"content": "‘"$Msg"\""\n"
    printf ‘\t},\n‘
    printf ‘\t"safe":"0"\n‘
    printf ‘}\n‘
}
/usr/bin/curl --data-ascii "$(body $1 $2 $3)" $PURL

為什么要這樣寫腳本?

????? 因?yàn)槲⑿牌髽I(yè)號(hào)開放的端口有固定的格式限制

????? 企業(yè)號(hào)支持的格式:http://qydev.weixin.qq.com/wiki/index.php?title消息類型及數(shù)據(jù)格式

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

將腳本放入zabbix默認(rèn)執(zhí)行路徑下

mv weixin.sh /usr/local/zabbix/share/zabbix/alertscripts
chown zabbix.zabbix /usr/local/zabbix/share/zabbix/alertscripts/weixin.sh
chmod +x /usr/local/zabbix/share/zabbix/alertscripts/weixin.sh

??????? 服務(wù)器端

?????? 1.創(chuàng)建媒介

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

??????? 2.創(chuàng)建用戶

微信報(bào)警 zabbix實(shí)現(xiàn)詳解


??????? 3.創(chuàng)建觸發(fā)器動(dòng)作發(fā)送內(nèi)容

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

??????? 4.設(shè)置觸發(fā)器動(dòng)作發(fā)送方式

微信報(bào)警 zabbix實(shí)現(xiàn)詳解

收到的微信消息:

微信報(bào)警 zabbix實(shí)現(xiàn)詳解?

以上就是微信報(bào)警 zabbix 的資料整理,后續(xù)繼續(xù)補(bǔ)充相關(guān)資料,謝謝大家對(duì)本站的支持!

更多微信報(bào)警 zabbix實(shí)現(xiàn)詳解相關(guān)文章請(qǐng)關(guān)注PHP中文網(wǎng)!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)