* Add Healthchecks.io notify hook Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * 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 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
54 lines
1.3 KiB
Bash
54 lines
1.3 KiB
Bash
#!/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
|
|
}
|