![]()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#++++++++++++++++++++++
#
#++++++++++++++++++++++
#运维监控预警:${time},微服务[${microsvc}]异常,请及时关注。
import requests
import json
import datetime
import os
dt = datetime.datetime.now()
print(dt)
payload={
"accessKey":"dbc2d8,
"accessSecret":"5d830dee4d2e6894a0707706824656",
"c"storedValueTemplateCode":"BuliBSfO"
}
rket.juncdt.com/smartmarket/msgService/sendMessageToMulti"
#res=requests.post(url,data=json.dumps(payload))
#print(dir(res))
#print(res)
#print(res.text)
'''for i in {auth,admix,payPlatform,base,ih,cons,assets,pda};do echo http://172.uator/health/;curl -I -o /dev/null -s -w %{http_code} http://172.16.4.6:9999/$i/actuator/health/;echo "\n";done'''y:9999/base/actuator/health/")
#resCode = str(chk).split('[')[1].split(']')[0]
#print(resCode)
#print(dir(chk))
#print(chk.text)
errx = ""
#baseUrl = "http://17microSvc}/actuator/health/"
baseUrl = "http://1or/health/"
#for i in {'auth','admatform','base','ih','cons','assets','pda'}:
for i in {'auth','adm,'cons','pda'}:
#for i in {'auth','adminx','ih','cons','assets','pda'}:
#print(i)
endUrl = baseUrl.format(microSvc = i)
#print(endUrl)
x = requests.get(endUrl)
if str(x).split('[')[1].split(']')[0] == "200":
resOk = "服务:" + i + " 正常"
else:
resError = "|服务:" + i + " 异常|"
errx = errx + resError + "、"
#print(x)
#print(errx)
if errx == "":
print("门诊系统正常。")
else:
#os.system("curl \'https://qyapi application/json' -d '{"msgtype": "text","text": {"content": "测试"}}'"""")
print("pre->门诊系统故障," + errx)
errx2 = "pre->门诊系统故障," + errx
os.system("curl \'http68d4de155ca\' -H \'Content-Type: application/json\' -d \'{\"msgtype\": \"text\",\"text\": {\"content\": %s}}\'"%{errx}
#print(x)
#os.system(x)