c语言sscanf函数的用法是什么
248
2022-11-22
cdh6.3.0组件健康检查的告警脚本
#!/bin/env python# -*- coding:utf-8 -*-from dingtalkchatbot.chatbot import DingtalkChatbotimport jsonimport requestsimport datetimeheaders = {'Content-Type': 'application/json;charset=utf-8'}dd_url="钉钉token"def alert_title(msg): return '' + msg + '' + '\n\n 'def set_text(title, msg): return "" + title + ":" + " " \ + "" + msg + " \n\n "def get_web_data(n_time, bf_time): url = "+ bf_time + ";timeReceived=lt=" + n_time + ";" r = requests.get(url, auth=('admin', 'admin')) r.encoding = 'utf8' page = r.text page = json.loads(page) items = page['items'] ntime = str(datetime.datetime.now().replace(microsecond=0).isoformat()) + "Z" for bulk in items: content = (bulk['content']) title = alert_title('集群告警') send_text = title + \ set_text('告警等级', '紧急处理') \ + set_text('集群地址', '\ + set_text('告警时间', ntime) \ + set_text('告警信息', content) at_mobiles = ["+86-13937000000"] dingMsg = DingtalkChatbot(dd_url) result=dingMsg.send_markdown(title='大数据组件告警', text=send_text,at_mobiles=at_mobiles) print (result)if __name__ == '__main__': diff_time = datetime.timedelta(days=0, seconds=300, microseconds=0) n_time = str(datetime.datetime.utcnow().replace(microsecond=0).isoformat()) + "Z" five_min_time = str((datetime.datetime.utcnow() - diff_time).replace(microsecond=0).isoformat()) + "Z" get_web_data(n_time, five_min_time)
效果:
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~