diff --git a/hc/api/models.py b/hc/api/models.py index 44cc2143..51c70e54 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -32,6 +32,7 @@ CHANNEL_KINDS = (("email", "Email"), ("hipchat", "HipChat"), ("slack", "Slack"), ("pd", "PagerDuty"), + ("pagertree", "PagerTree"), ("po", "Pushover"), ("pushbullet", "Pushbullet"), ("opsgenie", "OpsGenie"), @@ -260,6 +261,8 @@ class Channel(models.Model): return transports.HipChat(self) elif self.kind == "pd": return transports.PagerDuty(self) + elif self.kind == "pagertree": + return transports.PagerTree(self) elif self.kind == "victorops": return transports.VictorOps(self) elif self.kind == "pushbullet": diff --git a/hc/api/transports.py b/hc/api/transports.py index faf06cc8..4b1088d0 100644 --- a/hc/api/transports.py +++ b/hc/api/transports.py @@ -230,6 +230,24 @@ class PagerDuty(HttpTransport): return self.post(self.URL, json=payload) +class PagerTree(HttpTransport): + def notify(self, check): + url = self.channel.value + headers = { + "Conent-Type": "application/json" + } + payload = { + "incident_key": str(check.code), + "event_type": "trigger" if check.status == "down" else "resolve", + "title": tmpl("pagertree_title.html", check=check) + "description": tmpl("pagertree_description.html", check=check), + "client": settings.SITE_NAME, + "client_url": settings.SITE_ROOT, + "tags": ",".join(check.tags_list()) + } + + return self.post(url, json=payload, headers=headers) + class Pushbullet(HttpTransport): def notify(self, check): diff --git a/hc/front/urls.py b/hc/front/urls.py index 4b209b57..5f5352df 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -17,6 +17,7 @@ channel_urls = [ url(r'^add_webhook/$', views.add_webhook, name="hc-add-webhook"), url(r'^add_pd/$', views.add_pd, name="hc-add-pd"), url(r'^add_pd/([\w]{12})/$', views.add_pd, name="hc-add-pd-state"), + url(r'^add_pagertree/$', views.add_pagertree, name="hc-add-pagertree"), url(r'^add_slack/$', views.add_slack, name="hc-add-slack"), url(r'^add_slack_btn/$', views.add_slack_btn, name="hc-add-slack-btn"), url(r'^add_hipchat/$', views.add_hipchat, name="hc-add-hipchat"), diff --git a/static/img/integrations/pagertree.png b/static/img/integrations/pagertree.png new file mode 100644 index 00000000..380f95f1 Binary files /dev/null and b/static/img/integrations/pagertree.png differ diff --git a/templates/front/channels.html b/templates/front/channels.html index f6f98b71..097ea24d 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -50,6 +50,9 @@ {% endif %} service key {{ ch.pd_service_key }} + {% elif ch.kind == "pagertree" %} + URL + {{ ch.value }} {% elif ch.kind == "opsgenie" %} API key {{ ch.value }} @@ -227,6 +230,15 @@ Add Integration {% endif %} +
On-call. Simplified.
+ + Add Integration +If your team uses PagerTree, + you can set up {% site_name %} to create a PagerTree incident when + a check goes down, and resolve it when a check goes back up.
+ +