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 %} +
  • + PagerTree icon + +

    PagerTree

    +

    On-call. Simplified.

    + + Add Integration +
  • HipChat icon diff --git a/templates/front/log.html b/templates/front/log.html index 42422737..5f302e29 100644 --- a/templates/front/log.html +++ b/templates/front/log.html @@ -89,6 +89,8 @@ {% endif %} {% elif event.channel.kind == "pd" %} Sent alert to PagerDuty + {% elif event.channel.kind == "pagertree" %} + Sent alert to PagerTree {% elif event.channel.kind == "opsgenie" %} Sent alert to OpsGenie {% elif event.channel.kind == "hipchat" %} diff --git a/templates/front/welcome.html b/templates/front/welcome.html index 75b70e13..3cb0f625 100644 --- a/templates/front/welcome.html +++ b/templates/front/welcome.html @@ -319,6 +319,13 @@ {% endif %} + + + PagerTree icon + + Open and resolve incidents in PagerTree. + + HipChat icon diff --git a/templates/integrations/add_pagertree.html b/templates/integrations/add_pagertree.html new file mode 100644 index 00000000..f3d161c9 --- /dev/null +++ b/templates/integrations/add_pagertree.html @@ -0,0 +1,46 @@ +{% extends "base.html" %} +{% load compress humanize staticfiles hc_extras %} + +{% block title %}Add PagerTree - {% site_name %}{% endblock %} + + +{% block content %} +
    +
    +

    PagerTree

    + +

    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.

    + +

    Integration Settings

    + +
    + {% csrf_token %} +
    + +
    + + + {% if form.value.errors %} +
    + {{ form.value.errors|join:"" }} +
    + {% endif %} +
    +
    +
    +
    + +
    +
    +
    +
    +
    +{% endblock %} diff --git a/templates/integrations/pagertree_description.html b/templates/integrations/pagertree_description.html new file mode 100644 index 00000000..11718355 --- /dev/null +++ b/templates/integrations/pagertree_description.html @@ -0,0 +1,5 @@ +{% load humanize %} +{{ check.name_then_code }} is {{ check.status }}. +{% if check.status == "down" %} +Last ping was {{ check.last_ping|naturaltime }} +{% endif %} diff --git a/templates/integrations/pagertree_title.html b/templates/integrations/pagertree_title.html new file mode 100644 index 00000000..b537551e --- /dev/null +++ b/templates/integrations/pagertree_title.html @@ -0,0 +1 @@ +{{ check.name_then_code }} is {{ check.status }}