脚本写在zabbix-server端
安装钉钉和添加群还有机器人
shell脚本(记住token;关键字测试脚本要用)
#!/bin/bash
source /etc/profile
#PHONE=$1
#SUBJECT=$2
MESSAGE=$1
#echo "redis-> ${MESSAGE}" > /tmp/dingding.log
/usr/bin/curl -X "POST" 'https://oapi.dingtalk.com/robot/send?access_token=6b515c1c0e88282ce7af6bc8cac7ddbf111404a04952537dec02e0dd136a6456' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text",
"text": {
"content": "'${MESSAGE}'"
}
}'
python脚本
#!/usr/bin/python3
import sys
import requests
import json
#钉钉告警:
def info(msg):
url = 'https://oapi.dingtalk.com/robot/send?access_token=6b515c1c0e88282ce7af6bc8cac7ddbf111404a04952537dec02e0dd136a6456'
headers = {
'Content-Type': 'application/json;charset=