WeChat alarm zabbix Implementation details

Source: Internet
Author: User
This article mainly introduces the relevant information about the zabbix method for alarms. For more information about the zabbix method for alarms, see the following article.

In a real production environment, we usually use emails and text messages to receive zabbix alarm information, but emails are often shelved by staff in the corner or even filtered out as spam. The company's SMS interface is too expensive. using short message alerts in complex environments will increase O & M costs a lot. A good third-party interface is provided. we can use alarms to reduce O & M costs.

The third-party interface requires us to apply for an enterprise number first -- portal: https://qy.weixin.qq.com/

Zabbix will pass three parameters to the script. $1 is the message receiving account, $2 alarm title, and $3 alarm content.

#! /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 & Cortana Cret = $ 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 application id local UserID = $1 Department member id in enterprise id, receiver local PartyID = 1 Department id defined in zabbix, the range is defined. all members in the group can receive the message local Msg =$ (echo "$ @" | cut-d ""-f3 -) filter out the third parameter 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 "content": "'" $ Msg "\" \ n "printf' \ t }, \ n' printf' \ t "safe ": "0" \ n' printf'} \ n'}/usr/bin/curl -- data-ascii "$ (body $1 $2 $3)" $ PURL

Why write a script like this?

The port opened by the Enterprise Account has fixed format restrictions.

Formats supported by enterprise: http://qydev.weixin.qq.com/wiki/index.php? Title message type and data format

The above is the information for alarm zabbix. we will continue to add relevant information in the future. thank you for your support for this site!

For more details about the implementation of zabbix alarms, please refer to the Chinese PHP website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.