commit - 618bc9a04d57ec3d64fba2d464838bd00cfc9f8f
commit + 0eadf7a1279636fa702f0e8e17ec252171808291
blob - 64e04821860b950ef1e808fdc66c05e82ab93b89
blob + 26c863c37a915c1b71e4400d45bb88f6f5d649e8
--- tg-webcheck
+++ tg-webcheck
## CHANGEME
CHAT_ID="391821769"
MSG="The Site ${WEB} is DOWN"
+MSG_UP="The Site ${WEB} is UP"
+DOWN=$(echo ${WEB} | awk -F/ '{print $3}')
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
CODE=$(curl -s -o /dev/null -w "%{http_code}" $WEB)
PING=$(ping -c1 -w1 google.com | wc -l)
echo "${DATE} - ${WEB} - ${CODE}" >> ${LOG}
if [ ${CODE} -eq '200' ]; then
- printf "[+] ${WEB} is UP!\\n"
+ if [ -e /tmp/${DOWN}.down ]; then
+ rm /tmp/${DOWN}.down
+ curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$MSG_UP"
+ fi
rm ${LOCK}
exit
else
- curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$MSG"
- rm ${LOCK}
+ if [ -e /tmp/${DOWN}.down ]; then
+ rm ${LOCK}
+ else
+ curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$MSG"
+ touch /tmp/${DOWN}.down
+ rm ${LOCK}
+ fi
fi
}