Zabbix监控进程(进程消失后钉钉报警)
用于python报警的脚本如下:(钉钉机器人的连接需要修改)
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: aiker@gdedu.ml
# My blog http://m51cto.51cto.blog.com
import requests
import json
import sys
import os
headers = {'Content-Type': 'application/json;charset=utf-8'}
api_url = "https://oapi.dingtalk.com/robot/send?access_token=aca883885b587f8f186bebb1dd66fbfd99d656d763a85cc0cf7ab87fa403"
def msg(text):
json_text= {
"msgtype": "text",
"at": {
"atMobiles": [
"13720167036"
],
"isAtAll": False
},
"text": {
"content": text
}
}
print (requests.post(api_url,json.dumps(json_text),headers=headers).content)
if __name__ == '__main__':
text = sys.argv[1]
msg(text)
第一:首选创建监控项:
第二:创建触发器