Bash http probe
A Little bash script that can notify whenever a site you own goes down.
Of course there are more sofisticated ways to achieve better results but this script is simple enough to be set up in a minute. You can pass a file containing all the sites to check with the -f flag, this is useful when used in a crontab for instance, instead if you want to rapidly do a loop on the command line you can pass a single site with the -s flag.
home='/path/to/homefolder' targetfile="$home/Desktop/SITES_NOT_RESPONDING" function checksite(){ HEAD "$1" > "$home/output" grep "^4[0-9][0-9]" < "$home/output" >> "$home/errors" grep "^5[0-9][0-9]" < "$home/output" >> "$home/errors" if [ -s errors ]; then /usr/bin/beep -f 1800 -l 200 -r 4 -d 500 echo "$1" >> "$targetfile" cat "$home/errors" >> "$targetfile" echo '' >> "$targetfile" notify-send -t 5000 "$1 is down!" rm "$home/output" "$home/errors" fi } function loopfile(){ while read line do checksite "$line" done < "$1" } while getopts s:f: options do case $options in f) loopfile $OPTARG;; s) checksite $OPTARG;; esac done
Get the source code here.