Last active
December 15, 2015 01:29
-
-
Save jakeasmith/5180095 to your computer and use it in GitHub Desktop.
I threw this together to monitor an intermittent LB issue tonight. It works beautifully.
This file contains hidden or 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 | |
# Usage: ./command.sh http://www.google.com | |
# Help: Returns the HTTP status code for a given URL every 2 seconds | |
txtred=$(tput setaf 1) # Red | |
txtgrn=$(tput setaf 2) # Green | |
txtylw=$(tput setaf 3) # Yellow | |
txtblu=$(tput setaf 4) # Blue | |
txtpur=$(tput setaf 5) # Purple | |
txtcyn=$(tput setaf 6) # Cyan | |
txtwht=$(tput setaf 7) # White | |
txtrst=$(tput sgr0) # Text reset. | |
while [ 1 ]; | |
do | |
response=$(curl -sL -w "%{http_code} %{url_effective}\\n" "$1" -o /dev/null) | |
if [[ "$response" == *"200"* ]] | |
then | |
echo "${txtgrn} $response ${txtrst} - $(date)" | |
else | |
echo "${txtred} $response ${txtrst} - $(date)" | |
fi | |
sleep 2; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I left the color codes in there in case someone wants to add more later.