Last active
February 9, 2017 01:38
-
-
Save maolopez/e0b5962eb653d13dde83c5ee1a651a68 to your computer and use it in GitHub Desktop.
Monitor any http by issuing a curl and creating a error log in case that http != 200
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/sh | |
location=$1 | |
If [ -z "$location" ] | |
then | |
echo "please provide the location argument without http://" | |
exit | |
fi | |
res=`curl -s -L -I $location | grep HTTP/1.1 | awk '/200/ {count++} END{print count}'` | |
if [ "$res" = "0" ] | |
then | |
mkdir /home/user/scripts/$location | |
cd /home/user/scripts/$location | |
wget -drc --tries=2 http://$location/ -o log | |
cat /home/user/scripts/$location | grep -i "error" | echo "ACTION REQUIRED: $location is down" | |
fi | |
echo "DONE! $res" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment