Skip to content

Instantly share code, notes, and snippets.

@tomfanning
Last active March 20, 2018 17:06
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 tomfanning/95dd3d5a29e030ab44cb5a7b2bd7fb30 to your computer and use it in GitHub Desktop.
Save tomfanning/95dd3d5a29e030ab44cb5a7b2bd7fb30 to your computer and use it in GitHub Desktop.
#!/bin/bash
# called by influx-mon.sh which is called by cron every minute
curloutput=$(curl -A "influx-mon" -ss -L --connect-timeout 5 -w "\n%{http_code}" $1)
exitcode=$?
body=$(echo "$curloutput" | head -n -1)
httpcode=$(echo "$curloutput" | tail -n 1)
if [ $exitcode -ne 0 ]; then
echo down
exit 1
else
if [[ $httpcode = "200" ]]; then
if [[ $body = *"$2"* ]]; then
echo up and matched
exit 0
else
echo up but not matched
exit 2
fi
else
echo HTTP response was $httpcode
exit 3
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment