forked from GithubBackups/healthchecks
Nicer HipChat alerts.
This commit is contained in:
parent
bef71c0acc
commit
40bc11782e
@ -170,12 +170,8 @@ class Slack(HttpTransport):
|
||||
|
||||
class HipChat(HttpTransport):
|
||||
def notify(self, check):
|
||||
text = tmpl("hipchat_message.html", check=check)
|
||||
payload = {
|
||||
"message": text,
|
||||
"color": "green" if check.status == "up" else "red",
|
||||
}
|
||||
|
||||
text = tmpl("hipchat_message.json", check=check)
|
||||
payload = json.loads(text)
|
||||
self.channel.refresh_hipchat_access_token()
|
||||
return self.post(self.channel.hipchat_webhook_url, json=payload)
|
||||
|
||||
|
@ -569,30 +569,8 @@ def add_hipchat(request):
|
||||
|
||||
|
||||
def hipchat_capabilities(request):
|
||||
return JsonResponse({
|
||||
"name": settings.SITE_NAME,
|
||||
"description": "Get Notified When Your Cron Jobs Fail",
|
||||
"key": "io.healthchecks.hipchat",
|
||||
"links": {
|
||||
"homepage": settings.SITE_ROOT,
|
||||
"self": settings.SITE_ROOT + reverse("hc-hipchat-capabilities")
|
||||
},
|
||||
"capabilities": {
|
||||
"installable": {
|
||||
"allowGlobal": False,
|
||||
"allowRoom": True,
|
||||
"callbackUrl":
|
||||
settings.SITE_ROOT + reverse("hc-hipchat-callback"),
|
||||
"installedUrl":
|
||||
settings.SITE_ROOT + reverse("hc-channels") + "?added=hipchat"
|
||||
},
|
||||
"hipchatApiConsumer": {
|
||||
"scopes": [
|
||||
"send_notification"
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
return render(request, "integrations/hipchat_capabilities.json", {},
|
||||
content_type="application/json")
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
|
BIN
static/img/down.png
Normal file
BIN
static/img/down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 8.3 KiB |
BIN
static/img/up.png
Normal file
BIN
static/img/up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
24
templates/integrations/hipchat_capabilities.json
Normal file
24
templates/integrations/hipchat_capabilities.json
Normal file
@ -0,0 +1,24 @@
|
||||
{% load hc_extras staticfiles %}
|
||||
{
|
||||
"name": "{% site_name %}",
|
||||
"description": "Get Notified When Your Cron Jobs Fail",
|
||||
"key": "io.healthchecks.hipchat",
|
||||
"links": {
|
||||
"homepage": "{% site_root %}",
|
||||
"self": "{% site_root %}{% url 'hc-hipchat-capabilities' %}"
|
||||
},
|
||||
"capabilities": {
|
||||
"installable": {
|
||||
"allowGlobal": false,
|
||||
"allowRoom": true,
|
||||
"callbackUrl": "{% site_root %}{% url 'hc-hipchat-callback'%}",
|
||||
"installedUrl": "{% site_root %}{% url 'hc-channels'%}?added=hipchat"
|
||||
},
|
||||
"hipchatApiConsumer": {
|
||||
"avatar": "{% site_root %}{% static 'img/logo-512-green.png' %}",
|
||||
"scopes": [
|
||||
"send_notification"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{% 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 %}
|
55
templates/integrations/hipchat_message.json
Normal file
55
templates/integrations/hipchat_message.json
Normal file
@ -0,0 +1,55 @@
|
||||
{% load hc_extras humanize staticfiles %}
|
||||
{
|
||||
"message": "“{{ check.name_then_code|escapejs }}” is {{ check.status|upper }}.",
|
||||
{% if check.status == "up" %}
|
||||
"color": "green",
|
||||
{% else %}
|
||||
"color": "red",
|
||||
{% endif %}
|
||||
"card": {
|
||||
"style": "application",
|
||||
"url": "{% site_root %}{% url 'hc-log' check.code %}",
|
||||
"format": "medium",
|
||||
"id": "{{ check.code }}",
|
||||
"title": "{{ check.name_then_code|escapejs }}",
|
||||
"icon": {
|
||||
{% if check.status == "up" %}
|
||||
"url": "{% site_root %}{% static 'img/up.png' %}"
|
||||
{% else %}
|
||||
"url": "{% site_root %}{% static 'img/down.png' %}"
|
||||
{% endif %}
|
||||
},
|
||||
"attributes": [
|
||||
{% if check.kind == "simple" %}
|
||||
{"label": "Period",
|
||||
"value": {"label": "{{ check.timeout|hc_duration }}"}
|
||||
},
|
||||
{% elif check.kind == "cron" %}
|
||||
{"label": "Schedule",
|
||||
"value": {"label": "{{ check.schedule|escapejs }}"}
|
||||
},
|
||||
{% endif %}
|
||||
|
||||
{"label": "Last Ping",
|
||||
{% if check.last_ping %}
|
||||
"value": {"label": "{{ check.last_ping|naturaltime }}"}
|
||||
{% else %}
|
||||
"value": {"label": "Never"}
|
||||
{% endif %}
|
||||
},
|
||||
|
||||
{% if check.tags_list %}
|
||||
{"label": "Tags",
|
||||
"value": {"label": "{{ check.tags_list|join:", " }}"}
|
||||
},
|
||||
{% endif %}
|
||||
|
||||
{"label": "Total Pings",
|
||||
"value": {"label": "{{ check.n_pings }}"}
|
||||
}
|
||||
],
|
||||
"activity": {
|
||||
"html": "“{{ check.name_then_code|escapejs }}” is {{ check.status|upper }}."
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user