Browse Source

Adds PagerTree Integration

pull/143/head
Austin 7 years ago
parent
commit
cb1eac50d9
10 changed files with 95 additions and 0 deletions
  1. +3
    -0
      hc/api/models.py
  2. +18
    -0
      hc/api/transports.py
  3. +1
    -0
      hc/front/urls.py
  4. BIN
      static/img/integrations/pagertree.png
  5. +12
    -0
      templates/front/channels.html
  6. +2
    -0
      templates/front/log.html
  7. +7
    -0
      templates/front/welcome.html
  8. +46
    -0
      templates/integrations/add_pagertree.html
  9. +5
    -0
      templates/integrations/pagertree_description.html
  10. +1
    -0
      templates/integrations/pagertree_title.html

+ 3
- 0
hc/api/models.py View File

@ -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":


+ 18
- 0
hc/api/transports.py View File

@ -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):


+ 1
- 0
hc/front/urls.py View File

@ -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"),


BIN
static/img/integrations/pagertree.png View File

Before After
Width: 133  |  Height: 133  |  Size: 4.4 KiB

+ 12
- 0
templates/front/channels.html View File

@ -50,6 +50,9 @@
{% endif %}
<span class="preposition">service key</span>
{{ ch.pd_service_key }}
{% elif ch.kind == "pagertree" %}
<span class="preposition">URL</span>
{{ ch.value }}
{% elif ch.kind == "opsgenie" %}
<span class="preposition">API key</span>
{{ ch.value }}
@ -227,6 +230,15 @@
<a href="{% url 'hc-add-pd' %}" class="btn btn-primary">Add Integration</a>
</li>
{% endif %}
<li>
<img src="{% static 'img/integrations/pagertree.png' %}"
class="icon" alt="PagerTree icon" />
<h2>PagerTree</h2>
<p>On-call. Simplified.</p>
<a href="{% url 'hc-add-pagertree' %}" class="btn btn-primary">Add Integration</a>
</li>
<li>
<img src="{% static 'img/integrations/hipchat.png' %}"
class="icon" alt="HipChat icon" />


+ 2
- 0
templates/front/log.html View File

@ -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" %}


+ 7
- 0
templates/front/welcome.html View File

@ -319,6 +319,13 @@
</tr>
{% endif %}
<tr>
<td>
<img width="22" height="22" alt="PagerTree icon" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAACW1BMVEVMaXEpr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Upr+Uor+Up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NDgzyVGMwaa3YF1MXPmr9qe0tB4ISYlBW++Z66DKae2QmJ61KKPJu2JSWVJaQeXJ1SVa/JYOAZ3OCTsONIaUf8pOKtC31b2/wjPOUY1Dw9vULyp8ZU+vvkLCk7vNHPy8vLUYJBwh4o3r8+d2WeT0RsWk0AKFyM+Rh49IHCRSc2xPn7RCbvDQsGCSszMzCI2QHFc/cdivLpjI0OAomaCADDhEPVFRh8UTsDlkWUFHgDRW0kGUFByKvl5ukVGhfZ21w6BShsLcMOCXBeRSvP0Nhwb7/ZUd4eppJssOhhEdWxcM/09AxxMFbhZ0KKTS5haSVdbXkJPhYIHwDXP44RDT0o3QAAAABJRU5ErkJggg==" />
</td>
<td>Open and resolve incidents in <a href="https://www.pagertreecom/">PagerTree</a>.</td>
</tr>
<tr>
<td>
<img width="22" height="22" alt="HipChat icon" src="data:image/gif;base64,R0lGODdhLAAsAMIIAAQyZSFOez9ljWKEooOetqa2ycvV4P3//CwAAAAALAAsAAAD/ni63P4wykmrNUSIEMQghiUeRiEAaKqiQhGOjzGsNB0ML6ycdU8POkNg1SG4GKXBhpijEFatJqQ0VBUqhdUVllURJl2WbmHgobYx77jxTEXMwHVjhgo8wnF5w/xtpOx6D39sKX2BDWFoB1UAhxBVeQaFjg90gAdhUpSYbgptjZsNkigvbQKhDilbpqh+KH1tl60Hqp6ds6MAL5mia1JhDCl5CgACmhJlsgeWDGZ7rxZtw4sow2GGClUBIFME2oSkDdpNZSodHgNKjMWig+1i4D6T4rUOcA4yZlDTCnTsacKmYCBA0MCxA2aUvYM3RoiKgwvCvII4RUuFXHVwiMgVPYCig3V1uCHB0KTeCG/yaBiiwy9aSiYkbo0xAdKHMR4KgxQoQJDgTgw2PQbyR0NooAwgjR4yyNPIrKetEgAAOw==" />


+ 46
- 0
templates/integrations/add_pagertree.html View File

@ -0,0 +1,46 @@
{% extends "base.html" %}
{% load compress humanize staticfiles hc_extras %}
{% block title %}Add PagerTree - {% site_name %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-sm-12">
<h1>PagerTree</h1>
<p>If your team uses <a href="https://pagertree.com">PagerTree</a>,
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.</p>
<h2>Integration Settings</h2>
<form method="post" class="form-horizontal" action="{% url 'hc-add-pagertree' %}">
{% csrf_token %}
<div class="form-group {{ form.value.css_classes }}">
<label for="post-url" class="col-sm-2 control-label">URL</label>
<div class="col-sm-10">
<input
id="post-url"
type="text"
class="form-control"
name="value"
placeholder="https://"
value="{{ form.value.value|default:"" }}">
{% if form.value.errors %}
<div class="help-block">
{{ form.value.errors|join:"" }}
</div>
{% endif %}
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">Save Integration</button>
</div>
</div>
</form>
</div>
</div>
{% endblock %}

+ 5
- 0
templates/integrations/pagertree_description.html View File

@ -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 %}

+ 1
- 0
templates/integrations/pagertree_title.html View File

@ -0,0 +1 @@
{{ check.name_then_code }} is {{ check.status }}

Loading…
Cancel
Save