#!/bin/sh # web_serve_check # called by ~jhs crontab with eg: # /usr/home/jhs/public_html/bin/.sh/web_serve_check # Now also works from internal hosts via proxy. cd ; cd tmp || exit 1 # Ensure line is up. /sbin/ping -q -c 1 www1.berklix.org 2> /dev/null 2> /dev/null # 2> to swallow the error if line is down. # Echo a blank line # Space in case if line down & redirect fails, report: # PING www1.berklix.org (83.236.223.115): 56 data bytes # --- www1.berklix.org ping statistics --- # 1 packets transmitted, 0 packets received, 100% packet loss echo # None of the following block are needed when called live by jhs, # as inherited from my csh env. # FTP_PASSIVE_MODE=YES # FTPSERVER=gate.js.berklix.net # ftp_proxy=ftp://gate.js.berklix.net:21 # FTP_PASSWORD=jhs@berklix._________net # FTP_LOGIN=ftp # all_proxy=http://gate.js.berklix.net # no_proxy=localhost,js.berklix.net # export FTP_PASSIVE_MODE # export FTPSERVER # export ftp_proxy # export FTP_PASSWORD # export FTP_LOGIN # export all_proxy # export no_proxy # But if a different Bourne shell user calls this direct, # then the 2 uncommented lines Are needed. http_proxy=http://gate.js.berklix.net:80 export http_proxy servers="www1.berklix.com www2.berklix.org www3.berklix.net" domains="www.berklix.com www.surfacevision.com bsdpie.com" # Test a combination of remote hosts & domains. for i in $servers $domains do fetch -o web_serve_check.tmp.$i http://$i/~jhs/index.html || \ echo "$0 failed on host $i" | \ mail -s "Cron $0" jhs # Keep subjest same as default below to unify filtering in # ~/.procmailrc.system.logs` # I''ve seen this mail me when thin httpd died 2006.12.01. done diff3 \ web_serve_check.tmp.www1.berklix.com \ web_serve_check.tmp.www2.berklix.org \ web_serve_check.tmp.www3.berklix.net \ && echo "web_serve_check successful" \ || echo "web_serve_check failed on diff3" rm -f web_serve_check.tmp.* # I don't check content of site top pages, as content varies. # Cron sends me a default mail on success with: # Subject: Cron /home/jhs/bin/.sh/web_serve_check