Created
December 17, 2015 07:13
-
-
Save linusfoldemo/6c9384d8414d3d5fbdb6 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 | |
URL_TO_VERIFY=$1 | |
EXPECTED_HTTP_CODE="200" | |
echo "Verifying '${URL_TO_VERIFY}' on $(hostname)" | |
RESULT=$(wget -O/dev/null --retry-connrefused -S "${URL_TO_VERIFY}" 2>&1 | grep "HTTP/" | cut -d' ' -f4) | |
if [ "$?" -ne "0" ]; then | |
echo "Unable to connect to '${URL_TO_VERIFY}" | |
exit 10 | |
fi | |
if [ -z ${RESULT} ] || [ "${RESULT}" -ne ${EXPECTED_HTTP_CODE} ]; then | |
echo "Verify '${URL_TO_VERIFY}' failed, http return code was '${RESULT}' expected '${EXPECTED_HTTP_CODE}'\n" | |
exit 20 | |
fi | |
echo "Verified ${URL_TO_VERIFY} with success!" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment