Skip to content

Instantly share code, notes, and snippets.

@cuu508
Last active September 26, 2018 08:06
Show Gist options
  • Save cuu508/8c215049f287825748b1c1a1e236bb2c to your computer and use it in GitHub Desktop.
Save cuu508/8c215049f287825748b1c1a1e236bb2c to your computer and use it in GitHub Desktop.
Report load average to Healthchecks.io. If it's above the configured threshold, use the "/fail" endpoint
# Run this from cron every minute:
# * * * * * checkloadavg.sh
CODE=ca75b1df-4f4e-4711-8dc0-f21eeb4b0dac
AVG=$(cat /proc/loadavg | cut -d " " -f 1)
THRESHOLD=0.5
if (( $(echo "$AVG > $THRESHOLD" | bc -l) )); then
curl --retry 3 -d "Load average: $AVG" -X POST https://hc-ping.com/$CODE/fail
else
curl --retry 3 -d "Load average: $AVG" -X POST https://hc-ping.com/$CODE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment