Master Zabbix Alerts: Email, Phone, SMS, WeChat & More with Code Samples
This article explains the most common Zabbix alert methods—including email, phone call, SMS, WeChat, and other channels—detailing their implementation ideas, required parameters, action configurations, and providing Python code snippets to retrieve performance graphs and send notifications.
Email Alert (0x01)
Email is the most common Zabbix alert method and essential for beginners. The article shows how to embed performance graphs in email notifications by constructing a URL with parameters such as period, itemids[0], type, profileIdx, and width. Required parameters are:
{
"period": "3600",
"itemids[0]": itemID,
"type": "0",
"profileIdx": "web.item.graph",
"width": "700"
}Action configuration example:
HOST.HOST1:{HOST.HOST1}|HOST.IP1:{HOST.IP1}|EVENT.DATE:{EVENT.DATE}|EVENT.TIME:{EVENT.TIME}|TRIGGER.SEVERITY:{TRIGGER.SEVERITY}|TRIGGER.NAME:{TRIGGER.NAME}|ITEM.KEY1:{ITEM.KEY1}|ITEM.NAME1:{ITEM.NAME1}|ITEM.VALUE1:{ITEM.VALUE1}|ITEM.ID:{ITEM.ID}|TRIGGER.STATUS:{TRIGGER.STATUS}Python script to fetch the graph and attach it to the email:
import requests
def GetGraph(itemID, pName=None):
try:
loginUrl = "http://%s/zabbix/index.php" % HOST
loginHeaders = {"Host": HOST, "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"}
playLoad = {"name": USER, "password": PASSWD, "autologin": "1", "enter": "Sign in"}
res = requests.post(loginUrl, headers=loginHeaders, data=playLoad)
testUrl = "http://%s/zabbix/chart.php" % HOST
testUrlplayLoad = {"period": "3600", "itemids[0]": itemID, "type": "0", "profileIdx": "web.item.graph", "width": "700"}
testGraph = requests.get(url=testUrl, params=testUrlplayLoad)
IMAGEPATH = os.path.join('/tmp', pName)
with open(IMAGEPATH, 'wb') as f:
f.write(testGraph.content)
return pName
except Exception as e:
print(e)
return False
finally:
requests.Session().close()Phone Call Alert (0x02)
Phone alerts are suitable for the most critical incidents. Costs depend on the provider; unanswered calls are usually free. Challenges include policy restrictions on voice‑to‑text conversion, latency in generating voice messages, and the need to handle urgent alerts manually.
Implementation idea: trigger a phone‑call script based on severity level.
SMS Alert (0x03)
SMS alerts use provider APIs and typically cost 0.03–0.05 CNY per message, suitable for medium to high severity incidents.
Implementation idea: trigger an SMS script according to severity.
WeChat Alert (0x04)
WeChat public‑account alerts require a registered public account.
Implementation idea: trigger a WeChat script based on severity.
Other Alerts (0x05)
Other channels such as QQ, RTX, DingTalk can be integrated by writing custom scripts that call their respective APIs.
Example GitHub projects:
QQ https://github.com/pandolia/qqbot
Wechat https://github.com/liuwons/wxBot
RTX https://github.com/rainfiel/rtx
...Summary
Comparison of various alert methods is illustrated in the following chart:
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
