jingshen 发表于 2018-8-5 06:17:54

python之钉钉机器人zabbix报警

#!/usr/bin/python  
# -*- 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;'}
  
api_url = "https://oapi.dingtalk.com/robot/send?access_token=37e23308d1b84eb4ac34566e03c4c4e74bxxxxxxxxxxxxxx"
  

  
def msg(text):
  
    json_text= {
  
   "msgtype": "text",
  
      "at": {
  
            "atMobiles": [
  
                "13xxxxxxx80"
  
            ],
  
            "isAtAll": False
  
      },
  
      "text": {
  
            "content": text
  
      }
  
    }
  
    print requests.post(api_url,json.dumps(json_text),headers=headers).content
  

  
if __name__ == '__main__':
  
    text = sys.argv
  
    msg(text)
页: [1]
查看完整版本: python之钉钉机器人zabbix报警