Created
November 23, 2015 20:36
-
-
Save josemalcher/113384537ee57a6ee70a 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 | |
SITES=("www.seusite.com.br" "www.seusite1.com.br") | |
EMAILRECEBIMENTO="[email protected];[email protected]" | |
STATUSCODE=("200" "201" "202" "203" "204" "205" "206" "207") | |
i=0 | |
j=0 | |
CONTROLE=0 | |
RESPOSTASITE=0 | |
while [ $i -lt ${#SITES[@]} ]; do | |
let RESPOSTASITE="$(wget --spider -S ${SITES[$i]} 2>&1 | grep "HTTP/" | awk '{print $2}')" | |
let CONTROLE=0 | |
let j=0 | |
while [ $j -lt ${#STATUSCODE[@]} ]; do | |
if [ "$RESPOSTASITE" == "" ] || [ $RESPOSTASITE -eq ${STATUSCODE[$j]} ]; then | |
date | |
echo "Site ON" | |
let CONTROLE=1 | |
fi | |
let j++ | |
done | |
if [ $CONTROLE = 0 ]; then | |
date | |
$RESPOSTASITE >> /var/log/pingdown2.log | |
echo "Site OFF" | |
echo "***** SITE FORA DO AR **** ${SITES[$i]} " | mutt -s "***** SITE FORA DO AR ******* ${SITES[$i]} *****" $EMAILRECEBIMENTO | |
fi | |
let i++ | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment