Last active
March 20, 2018 17:06
-
-
Save tomfanning/95dd3d5a29e030ab44cb5a7b2bd7fb30 to your computer and use it in GitHub Desktop.
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 | |
# 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