Skip to content

Instantly share code, notes, and snippets.

@Mononofu
Last active May 11, 2021 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mononofu/e4450d112f22ab14c9405f802da51aae to your computer and use it in GitHub Desktop.
Save Mononofu/e4450d112f22ab14c9405f802da51aae to your computer and use it in GitHub Desktop.
Helper script for https://healthchecks.io/ monitoring
#!/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}"
@Mononofu
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment