From 3e2ae023880858ba5a89479a299e0dbc31c8993c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C4=93teris=20Caune?= SITE_NAME ping endpoints accept HTTP HEAD, GET and POST request methods. When using HTTP POST, you can include arbitrary payload in the request body.
+If the request body looks like a UTF-8 string, SITE_NAME will log the first 10 kilobytes of
+the request body, so you can inspect it later. In this example, we run We can extend the previous example and signal either success or failure
+depending on the exit code: Finally, all of the above can be packaged in a single line. The one-line
+version can be put directly in crontab, without using a wrapper script.Attaching Logs
+Logging Command Output
+certbot renew
, capture its output, and submit
+the captured output to SITE_NAME:#!/bin/sh
+
+m=$(/usr/bin/certbot renew 2>&1)
+curl -fsS --retry 3 -X POST --data-raw "$m" PING_URL
+
In Combination with the
+/fail
Endpoint#!/bin/sh
+
+url=PING_URL
+
+m=$(/usr/bin/certbot renew 2>&1)
+
+if [ $? -ne 0 ]; then url=$url/fail; fi
+curl -fsS --retry 3 -X POST --data-raw "$m" $url
+
As One-Liner
+m=$(/usr/bin/certbot renew 2>&1); curl -fsS -X POST --data-raw "$m" "PING_URL$([ $? -ne 0 ] && echo -n /fail)"
+
/fail
URL will immediately mark the check as "down".
You can use this feature to minimize the delay from your monitored service failing
to you getting a notification.
Below is a skeleton code example in Python which signals a failure when the work function returns an unexpected value or throws an exception:
import requests
diff --git a/templates/docs/signalling_failures.md b/templates/docs/signalling_failures.md
index 49fe04f9..45e2b0dd 100644
--- a/templates/docs/signalling_failures.md
+++ b/templates/docs/signalling_failures.md
@@ -5,6 +5,8 @@ Requesting the `/fail` URL will immediately mark the check as "down".
You can use this feature to minimize the delay from your monitored service failing
to you getting a notification.
+## Python
+
Below is a skeleton code example in Python which signals a failure when the
work function returns an unexpected value or throws an exception:
diff --git a/templates/front/base_docs.html b/templates/front/base_docs.html
index 2a727a2f..fe4645d1 100644
--- a/templates/front/base_docs.html
+++ b/templates/front/base_docs.html
@@ -14,6 +14,7 @@
{% include "front/docs_nav_item.html" with slug="monitoring_cron_jobs" title="Monitoring cron jobs" %}
{% include "front/docs_nav_item.html" with slug="signalling_failures" title="Signalling failures" %}
{% include "front/docs_nav_item.html" with slug="measuring_script_run_time" title="Measuring script run time" %}
+ {% include "front/docs_nav_item.html" with slug="attaching_logs" title="Attaching logs" %}