Created
June 25, 2018 16:25
-
-
Save simbalinux/db3d6297c5d221f0638e3a6ba6d21aa0 to your computer and use it in GitHub Desktop.
check uptime of sites
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 | |
SITESFILE=sites.txt #list the sites you want to monitor in this file | |
#EMAILS="[email protected],[email protected]" #list of email addresses to receive alerts (comma separated) | |
while read site; do | |
if [ ! -z "${site}" ]; then | |
CURL=$(curl -s --head $site) | |
if echo $CURL | grep "200 OK" > /dev/null | |
then | |
echo "The HTTP server on ${site} is up!" | |
else | |
MESSAGE="This is an alert that your site ${site} has failed to respond 200 OK." | |
echo "${MESSAGE}" | |
# for EMAIL in $(echo $EMAILS | tr "," " "); do | |
# SUBJECT="$site (http) Failed" | |
# echo "$MESSAGE" | mail -s "$SUBJECT" $EMAIL | |
# echo $SUBJECT | |
# echo "Alert sent to $EMAIL" | |
# done | |
fi | |
fi | |
done < $SITESFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment