diff --git a/hc/api/models.py b/hc/api/models.py index e5b2e53b..dadb3241 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -1,6 +1,7 @@ from datetime import timedelta as td import uuid +from django.conf import settings from django.contrib.auth.models import User from django.db import models @@ -17,3 +18,6 @@ class Check(models.Model): last_ping = models.DateTimeField(null=True, blank=True) alert_after = models.DateTimeField(null=True, blank=True, editable=False) status = models.CharField(max_length=6, choices=STATUSES, default="new") + + def url(self): + return settings.PING_ENDPOINT + str(self.code) diff --git a/hc/api/urls.py b/hc/api/urls.py index 35f2b894..71c41a42 100644 --- a/hc/api/urls.py +++ b/hc/api/urls.py @@ -4,4 +4,5 @@ from hc.api import views urlpatterns = [ url(r'^ping/([\w-]+)/$', views.ping, name="hc-ping"), + url(r'^ping/([\w-]+)$', views.ping, name="hc-ping"), ] diff --git a/hc/front/views.py b/hc/front/views.py index 10cc3f61..5b71a053 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -1,5 +1,6 @@ import json +from django.conf import settings from django.contrib.auth.decorators import login_required from django.contrib.humanize.templatetags.humanize import naturaltime from django.http import HttpResponse, HttpResponseForbidden @@ -33,7 +34,7 @@ def index(request): "check": check, "timer": timer, "timer_formatted": timer_formatted, - "ping_url": "http://healthchecks.io/ping/%s/" % check.code + "ping_url": check.url() } return render(request, "index.html", ctx) diff --git a/hc/settings.py b/hc/settings.py index 946ed862..d2f060a0 100644 --- a/hc/settings.py +++ b/hc/settings.py @@ -87,6 +87,7 @@ USE_L10N = True USE_TZ = True SITE_ROOT = "http://localhost:8000" +PING_ENDPOINT = SITE_ROOT + "/ping/" STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] STATIC_ROOT = os.path.join(BASE_DIR, 'static-collected') diff --git a/templates/docs.html b/templates/docs.html index f9fed8fd..c81ec32f 100644 --- a/templates/docs.html +++ b/templates/docs.html @@ -13,10 +13,10 @@ the "Last Ping" value of corresponding check is updated.

When a certain amount of time passes since last received ping, the - check is considered "late", and Health Checks sends an email notification. + check is considered "late", and Health Checks sends an email alert. It is all very simple, really.

-

Executing a ping

+

Executing a Ping

At the end of your batch job, add a bit of code to request one of your ping URLs. @@ -35,16 +35,16 @@ In bash scripts, you can use wget or curl to run the requests:

-wget https://healthchecks.io/ping/b2012751-c542-4deb-b054-ff51322102b9/ -O /dev/null
+curl http://healthchecks.io/ping/uuid-goes-here
 
-

When notifications are sent

+

When Alerts Are Sent

Each check has a configurable "Frequency" parameter, with default value of one day.

When time since last ping exceeds the configured amount, the check is considered late. - When a check is 1 hour late, Health Checks sends you an email notification. + When a check is 1 hour late, Health Checks sends you an email alert.

diff --git a/templates/front/index.html b/templates/front/index.html index 6505c799..5623cdf3 100644 --- a/templates/front/index.html +++ b/templates/front/index.html @@ -50,7 +50,7 @@ - http://healthchecks.io{% url 'hc-ping' check.code %} + {{ check.url }}
diff --git a/templates/pricing.html b/templates/pricing.html index 159f55f6..55cf184e 100644 --- a/templates/pricing.html +++ b/templates/pricing.html @@ -22,8 +22,8 @@