This repository has been archived on 2024-11-01. You can view files and clone it, but cannot push or open issues or pull requests.
services/healthcheck/http

47 lines
1 KiB
Bash
Executable file

#!/usr/bin/sh
set -e
cd /opt/ || exit
hc_url="https://hc-ping.com/$HTTP_HC_UID"
error=""
alias curl_hc='curl -LA "$USER_AGENT" --retry 3'
check_url ()
{
url="https://$1"
echo "checking url $url ..."
dig A "$1" >/dev/null
if curl_hc -sSf "$url" >/dev/null 2>&1
then
echo "... good"
else
result=$(curl -Lv "$url" 2>&1)
error=$(printf "%s\n==========\n%s:\n%s" "$error" "$url" "$result")
echo "... bad"
fi
}
check_url "analytics.serguzim.me"
check_url "auth.serguzim.me"
check_url "ci.serguzim.me"
check_url "cloud.serguzim.me"
check_url "git.serguzim.me"
check_url "graph.serguzim.me"
check_url "hook.serguzim.me"
check_url "mail.serguzim.me"
check_url "msrg.cc"
check_url "prometheus.serguzim.me/-/healthy"
check_url "registry.serguzim.me"
check_url "rss.serguzim.me"
check_url "serguzim.me"
check_url "wiki.serguzim.me"
check_url "www.reitanlage-oranienburg.de"
if [ "$error" = "" ]
then
curl_hc "$hc_url" >/dev/null 2>&1
else
curl_hc --data-raw "$error" "$hc_url/fail" >/dev/null 2>&1
fi