If this is off-topic please feel free to move it.
My goal was to determine if the server is up using curl to ask for the Webserver Software version.
It should be and is "Microsoft-IIS"
Using "set -x" in my script showed me it may be "Microsoft-IIS"
Code:
#!/bin/bash
# set -x
MAIL_ME="jj"
MAIL_SUBJECT="Norveld_Server_needs_attention"
SERVER_DATE=$(TZ=PST8PDT date +%c)
LOCAL_DATE=$(date +%c)
# store this in a variable
temp=$(curl -Is http://xxx.xxx.xxx.xxx | \grep -E '^Server' | cut -c9-21)
echo $(TZ=PST8PDT date) - Web Server Check = $temp >> /home/jj/Documents/cirrhus9/Accounts/Norveld/3WeekTest/norveld.test
if [ $temp = "Microsoft-IIS/7.5\r" ] ; then
echo "Norveld_Server_Check - FAILED" on $LOCAL_DATE | mail $MAIL_ME -s $MAIL_SUBJECT
exit 0
fi
The source of my current amusement is what appears to be the backwards logic in my "if" statement.
But trust me, in this case, it does opposite what it should?
Pseudo-code:
Ask server for version
If the string IS Microsoft-IIS/7.5\r ; then
write log file
exit 0
else
If the string is NOT Microsoft-IIS ; then
write log file
mail me
but if I change the IP to an Apache server, I don't get an email...
Code:
$ /home/jj/Documents/cirrhus9/Accounts/Norveld/3WeekTest/norveldchk.sh && mail
Thu Dec 29 13:57:23 PST 2011 - Web Server Check = Microsoft-IIS/7.5
No mail for jj
$ /home/jj/Documents/cirrhus9/Accounts/Norveld/3WeekTest/norveldchk.sh && mail
Thu Dec 29 13:57:33 PST 2011 - Web Server Check = Apache
No mail for jj
Any light to be shed on this would greatly be appreciated!
Or some real keyboard KungFu...
Ping is NOT an option for this script since the server will ping,
but the machine is in fact, unresponsive through normal channels.
Thanks and Happy New Year!