Commit 2a1333f4 by ChongmingDu

add dingding alert

parent d0ddf848
#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests
import json
import sys
import os
headers = {'Content-Type': 'application/json;charset=utf-8'}
api_url = ""#dingding token
def msg(text):
json_text= {
"msgtype": "text",
"at": {
"atMobiles": [
"13153669XXX"
],
"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)
\ No newline at end of file
...@@ -29,4 +29,16 @@ ...@@ -29,4 +29,16 @@
src: zabbix.conf src: zabbix.conf
dest: /etc/httpd/conf.d/zabbix.conf dest: /etc/httpd/conf.d/zabbix.conf
notify: notify:
- restart httpd - restart httpd
\ No newline at end of file
- name: "copy dingding robot python script"
copy:
src: dingdingrobot.py
dest: /usr/lib/zabbix/alertscripts/dingdingrobot.py
- name: "run dingding robot python script"
file:
path: /usr/lib/zabbix/alertscripts/dingdingrobot.py
owner: zabbix
group: zabbix
mode: 0775
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment