Hello Fellow bash enthusiasts...
I am stuck on this local script and could use some fresh eyes on this code.
#!/bin/bash
MAIL_ME="jj@uberdork.com"
MAIL_SUBJECT="Norveld_Server_needs_attention"
SERVER_DATE=$(TZ=PST8PDT date)
echo $(ServerTZ=PST8PDT date) - Web Server Check = $(curl -Is http://xxx.xxx.xxx.xxx | \grep -E '^Server' | cut -c9-) >> /home/jj/Documents/cirrhus9/Accounts/Norveld/3WeekTest/norveld.test
if [ $? -eq 0 ] ; then
exit 0
else
if [ $? -eq 1 ] ; then
echo "Norveld_Server_Check - FAILED" on $SERVER_DATE | mail $MAIL_ME -s $MAIL_SUBJECT
exit 1
fi
fi
done
#EOF
PING IS NOT AN OPTION'
Server when it's borked will ping,
but be unresponsive, so I ask the Webserver what software it's using with
curl -Is http://xxx.xxx.xxx.xxx | \grep -E '^Server' | cut -c9-
which returns "Microsoft-IIS/7.5" and works even if the server is unresponsive through usual means.
This runs under my cron every minute.
There's only 1 problem, server has been up/down for awhile and I NEVER get an email.
telnet xxx.xxx.xxx.xxxx 80
is an option, but I have zero experience with how to handle the response from the server. or
wget xxx.xxx.xxx.xxx/index.html
Whatever method I use to check for responsiveness, I have to get an email as the desired email address.
local: GNU bash, version 4.1.10(1)-release (i586-suse-linux-gnu)
Remote: Windows Server 2008 R2 (64bit) with IIS.
Thanks.
Happy New Year!