#!/bin/ksh # ----------------------------------------------------------------------- # Filename: webmon.ksh # Purpose: Check if a webserver is responding to requests # Author: Frank Naude, Oracle FAQ # ----------------------------------------------------------------------- WEBSERVER=www.yourhost.com WEBPORT=80 MAILTO=address\@domain.com telnet $WEBSERVER $WEBPORT 2>/dev/null |& # Open pipe to web server read -p CRAP 2>/dev/null # Ignore telnet headers read -p CRAP 2>/dev/null read -p CRAP 2>/dev/null print -p "get / http/1.0" 2>/dev/null # Send HTTP request to server print -p "" 2>/dev/null read -p LINE 2>/dev/null if [ "${LINE}" != "HTTP/1.0 200 OK" ]; then echo ERROR: Web Server is DOWN!!! /bin/mail $MAILTO <<-EOF Subject: $WEBSERVER: Web Server Down The Web server on $WEBSERVER doesn't respond to HTTP requests. Please investigate!!! EOF fi # Ensure the co-process is terminated exec 3>&p 3>&-