#!/bin/python
#coding=utf-8
import requests
import sys
import json
import time
msg=sys.argv[1]
with open('/tmp/log.txt','a+') as song:
song.write(time.strftime('%Y-%m-%d %H:%M:%S'))
song.write(msg)
song.write('\n')
data=eval(msg)
#{"hostname":"Zabbix server","trggier_name":"sos测试","ip":"127.0.0.1"}
alert={}
alert["source"] = data["hostname"]
alert["title"] = data["trggier_name"]
alert["section"] = data["section"]
alert["group"] = "network"
alert["content"] = data["content"]
alert=json.dumps(alert,ensure_ascii=False)
requests.post('http://dingtalk.com', data=alert)
ensure_ascii=False