From 84a8d2a7528b571d61ec9b2d78628acf1f7f155d Mon Sep 17 00:00:00 2001 From: Marc-Pascal Clement Date: Sun, 27 Sep 2026 09:51:04 +0200 Subject: [PATCH] Add Healthchecks.io notify hook (#7282) * Add Healthchecks.io notify hook Co-Authored-By: Claude Opus 5 * notify/healthchecks: require an exact "OK" response hc-ping.com answers HTTP 200 "OK (not found)" for an unknown UUID, so the prefix match reported success for a mistyped or deleted check, including the --set-notify test ping. Only treat an exact "OK" body as success. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5 --- notify/healthchecks.sh | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 notify/healthchecks.sh diff --git a/notify/healthchecks.sh b/notify/healthchecks.sh new file mode 100644 index 00000000..90d37a0b --- /dev/null +++ b/notify/healthchecks.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env sh + +#Support Healthchecks.io (hosted or self-hosted) +#https://healthchecks.io/docs/http_api/ + +#Required: +#HEALTHCHECKS_URL="https://hc-ping.com/your-uuid" + +#Use with --notify-level 3, so a ping is sent on every cron run, even when +#all certs are skipped. Otherwise Healthchecks reports the check as down. + +healthchecks_send() { + _subject="$1" + _content="$2" + _statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped + _debug "_subject" "$_subject" + _debug "_content" "$_content" + _debug "_statusCode" "$_statusCode" + + HEALTHCHECKS_URL="${HEALTHCHECKS_URL:-$(_readaccountconf_mutable HEALTHCHECKS_URL)}" + if [ -z "$HEALTHCHECKS_URL" ]; then + HEALTHCHECKS_URL="" + _err "You didn't specify the Healthchecks.io ping url HEALTHCHECKS_URL yet." + _err "Example: export HEALTHCHECKS_URL=\"https://hc-ping.com/your-uuid\"" + return 1 + fi + _saveaccountconf_mutable HEALTHCHECKS_URL "$HEALTHCHECKS_URL" + + _hc_url="${HEALTHCHECKS_URL%/}" + case "$_statusCode" in + 0 | 2) ;; + 1) + _hc_url="$_hc_url/fail" + ;; + *) + _hc_url="$_hc_url/log" + ;; + esac + + _data="$_subject + +$_content" + + response="$(_post "$_data" "$_hc_url" "" "POST" "text/plain")" + + if [ "$?" = "0" ] && [ "$response" = "OK" ]; then + _info "healthchecks ping success." + return 0 + fi + _err "healthchecks ping error." + _err "$response" + return 1 +}