首先介绍一下大名鼎鼎的Pagerduty, Pagerduty是一套付费监控报警系统,经常作为SRE/运维人员的监控报警工具,可以和市面上常见的监控工具直接整合,例如和zabbix整合,我遇到的最多的场景还是和zabbix整合,当有服务器出现异常的时候,zabbix会通过pagerduty对当前设置的值班的人员进行短信+电话通知
官网地址:https://www.pagerduty.com
为什么要付费使用这套系统呢?个人认为最主要的原因是这套系统功能极其强大,特别是存在的层级的报警
短信报警->5分钟无人ack->打电话通知->5分钟后仍然无人ack->通知当前值班人员的上级manager->更高级
而且app支持的也非常强大….
当然,pagerduty作为一个付费的监控通知系统,api写的也是真的烂……,虽然可以通过app或者网页来ack报警,但是通过命令行无疑更快,直接上代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
def ack_incident(self,id): """Acknowledges a triggered incident using the customer's API access key and incident key.""" headers = { 'Accept': 'application/vnd.pagerduty+json;version=2', 'Authorization': 'Token token={0}'.format(self.API_ACCESS_KEY), 'Content-Type': 'application/json', 'From': 'maple_m@hotmail.com' } payload = { "incidents": [ { "id": id, "type": 'incident_reference', "status": 'acknowledged' } ]} r = requests.put('https://api.pagerduty.com/incidents', headers=headers, data=json.dumps(payload), ) print r.status_code |
两个核心的值API_ACCESS_KEY和id,传入对应的incident的id我们就可以通过上边的方法进行ack了
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021