@ -0,0 +1,19 @@ | |||||
# -*- coding: utf-8 -*- | |||||
from __future__ import unicode_literals | |||||
from django.db import models, migrations | |||||
class Migration(migrations.Migration): | |||||
dependencies = [ | |||||
('api', '0012_auto_20150930_1922'), | |||||
] | |||||
operations = [ | |||||
migrations.AlterField( | |||||
model_name='channel', | |||||
name='kind', | |||||
field=models.CharField(max_length=20, choices=[('email', 'Email'), ('webhook', 'Webhook'), ('hipchat', 'HipChat'), ('slack', 'Slack'), ('pd', 'PagerDuty')]), | |||||
), | |||||
] |
@ -20,6 +20,7 @@ STATUSES = (("up", "Up"), ("down", "Down"), ("new", "New")) | |||||
DEFAULT_TIMEOUT = td(days=1) | DEFAULT_TIMEOUT = td(days=1) | ||||
DEFAULT_GRACE = td(hours=1) | DEFAULT_GRACE = td(hours=1) | ||||
CHANNEL_KINDS = (("email", "Email"), ("webhook", "Webhook"), | CHANNEL_KINDS = (("email", "Email"), ("webhook", "Webhook"), | ||||
("hipchat", "HipChat"), | |||||
("slack", "Slack"), ("pd", "PagerDuty")) | ("slack", "Slack"), ("pd", "PagerDuty")) | ||||
@ -132,7 +133,18 @@ class Channel(models.Model): | |||||
"icon_url": "https://healthchecks.io/static/img/[email protected]" | "icon_url": "https://healthchecks.io/static/img/[email protected]" | ||||
} | } | ||||
r = requests.post(self.value, data=json.dumps(payload)) | |||||
r = requests.post(self.value, json=payload) | |||||
n.status = r.status_code | |||||
n.save() | |||||
elif self.kind == "hipchat": | |||||
text = render_to_string("hipchat_message.html", {"check": check}) | |||||
payload = { | |||||
"message": text, | |||||
"color": "green" if check.status == "up" else "red", | |||||
} | |||||
r = requests.post(self.value, json=payload) | |||||
n.status = r.status_code | n.status = r.status_code | ||||
n.save() | n.save() | ||||
@ -3,16 +3,17 @@ $(function() { | |||||
email: "[email protected]", | email: "[email protected]", | ||||
webhook: "http://", | webhook: "http://", | ||||
slack: "https://hooks.slack.com/...", | slack: "https://hooks.slack.com/...", | ||||
hipchat: "https://api.hipchat.com/...", | |||||
pd: "service key" | pd: "service key" | ||||
} | } | ||||
$("#add-check-kind").change(function() { | |||||
$("#add-channel-kind").change(function() { | |||||
$(".channels-add-help p").hide(); | $(".channels-add-help p").hide(); | ||||
var v = $("#add-check-kind").val(); | |||||
var v = $("#add-channel-kind").val(); | |||||
$(".channels-add-help p." + v).show(); | $(".channels-add-help p." + v).show(); | ||||
$("#add-check-value").attr("placeholder", placeholders[v]); | |||||
$("#add-channel-value").attr("placeholder", placeholders[v]); | |||||
}); | }); | ||||
$(".edit-checks").click(function() { | $(".edit-checks").click(function() { | ||||
@ -0,0 +1,8 @@ | |||||
{% load humanize %} | |||||
{% if check.status == "down" %} | |||||
The check "{{ check.name_then_code }}" is DOWN. | |||||
Last ping was {{ check.last_ping|naturaltime }} | |||||
{% else %} | |||||
The check "{{ check.name_then_code }}" received a ping and is now UP. | |||||
{% endif %} |