Operations 5 min read

How to Push Zabbix Alerts to WeChat Using Service Account Templates

This guide explains how to configure a WeChat service account, enable template messages, deploy Python and shell scripts, and integrate them with Zabbix so that monitoring alerts are sent directly to WeChat users as template messages.

Efficient Ops
Efficient Ops
Efficient Ops
How to Push Zabbix Alerts to WeChat Using Service Account Templates

This article demonstrates a practical method to send Zabbix alerts through a WeChat service account using the platform’s template message feature.

1. Register and certify a WeChat service account

Follow the official WeChat guide to register a service account and complete the certification (requires company documents and a 300 CNY annual fee).

2. Enable template message function and select an alert template

In the WeChat public platform, add the “Template Message” feature.

Choose the “IT/Network Game – System Fault Alert Notification” template (or another appropriate alert template).

3. Download and deploy the alert script

# git clone https://github.com/vincihu/misc/
sudo mv misc/wxAlert /usr/lib/zabbix/alertscripts/
sudo mv /usr/lib/zabbix/alertscripts/{wxAlert/,}AlertWeixin.sh
sudo mkdir /usr/lib/zabbix/alertscripts/logs
sudo chmod u+x AlertWeixin.sh
sudo chown zabbix:zabbix /usr/lib/zabbix/alertscripts/{logs/,AlertWeixin.sh}
sudo pip install -U configparser requests simplejson

Edit wxAlert/wxAlert.conf and fill in the WeChat service account credentials:

[default]
appid = APPID
secret = SECRET
template_id = TEMPLATE_ID

4. Obtain subscriber OpenIDs

# python wxGetUserInfo.py 2>/dev/null
nickname: JasonQu
openid: AAAA
headimgurl: http://wx.qlogo.cn/mmopen/XXXX/0
nickname: 胡文西
openid: BBBB
headimgurl: http://wx.qlogo.cn/mmopen/YYYY/0

5. Configure Zabbix

Add a new media type:

Name: X. AlertWeixin
Type: Script
Script name: AlertWeixin.sh

Assign the media type to a user profile, using the subscriber’s OpenID as the “Send to” address.

6. Test the integration

Trigger a test alert in Zabbix; the message will be delivered to the WeChat user. Example screenshot:

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonOperationsWeChatshell scriptZabbixAlert Integration
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.