Last active
May 11, 2021 18:26
-
-
Save Mononofu/e4450d112f22ab14c9405f802da51aae to your computer and use it in GitHub Desktop.
Helper script for https://healthchecks.io/ monitoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: health_checked.sh $UUID your command --with=args | |
UUID="$1" | |
PING_URL="https://hc-ping.com/${UUID}" | |
curl -fsS -m 10 --retry 5 -o /dev/null "${PING_URL}/start" | |
OUTPUT=$("${@:2}" 2>&1) | |
STATUS="$?" | |
BREAK=$'\n\n' | |
BODY="Command: ${@:2}$BREAK$OUTPUT" | |
curl -fsS -m 10 --retry 5 -o /dev/null --data-raw "$BODY" "${PING_URL}/${STATUS}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: for exit status / failure reporting to work correctly, "set -e" must not be called, as this would abort the script immediately when the command fails.