You can use wget or curl for this. Both are command line tools to get web pages and have options to examine the return codes.
For example:
webmarc@plato:~$ wget http://www.google.com/ -S -O /dev/null 2>&1 | grep HTTP\/ HTTP/1.1 200 OK
Here -S
tells wget to print the server headers, -O
saves the resultant file to /dev/null because I'm not interested in the contents, just the status code. The 2>&1
is required because wget prints this all on stderr. And finally, just piping this to grep for part of the string that is in every response code (HTTP/1.1 is part of every status code these days, but I left the version out so that it will work with v1.2 or 2.0).
You could setup a bash shell script along the lines of
$RESULT=`pi@kali:~$ wget http://www.google.com/ -S -O /dev/null 2>&1 | grep HTTP\/` if [[ $RESULT != " HTTP/1.1 200 OK" ]] then fix_teh_broken.sh fi
Stick something like that in cron on a 1 or 5 minute schedule and you're good to go.
Obviously, substitute the URL you want to monitor for google.