{SOLVED] - Server_check script

Forum rules
Before you post please read this

{SOLVED] - Server_check script

Postby Habitual on Tue Dec 27, 2011 10:00 pm

Hello Fellow bash enthusiasts...

I am stuck on this local script and could use some fresh eyes on this code.
Code: Select all
#!/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
Code: Select all
curl -Is http://xxx.xxx.xxx.xxx | \grep -E '^Server' | cut -c9-

which returns "Microsoft-IIS/7.5"

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.

Feel free to toss something useful in my direction.

Thanks.

Happy New Year!
Last edited by Habitual on Thu Dec 29, 2011 11:42 pm, edited 1 time in total.
What's a landing but a take off in reverse?
My DorkBlog
User avatar
Habitual
Level 8
Level 8
 
Posts: 2031
Joined: Sun Nov 21, 2010 8:31 pm
Location: Undecided

Linux Mint is funded by ads and donations.
 

Re: Server_check script

Postby Habitual on Thu Dec 29, 2011 11:41 pm

Code: Select all
#!/bin/bash
# Written by jj@domain.com
# Monitors an IIS server and emails the Admin if the
# server reports anything other than "Microsoft-IIS"
# http://bashscripts.org/forum/viewtopic.php?f=16&t=1522
# Last Edited on Thu Dec 29, 2011 - 10:11:40 PM EST
###
# set -x # debug method
MAIL_ME="jj@domain.com"
MAIL_SUBJECT="Norveld_Server_needs_attention"
SERVER_DATE=$(TZ=PST8PDT date "+%a %b %d %I:%M:%S %p %Z")
LOCAL_DATE=$(date +%c)

# store this in a variable
IIS=$(curl -Is http://xxx.xxx.xxx.xxx | \grep -E '^Server' | cut -c9-21)
echo "$SERVER_DATE" - Web Server Check = "$IIS" >> /home/jj/Documents/cirrhus9/Accounts/Norveld/3WeekTest/norveld.test

if [ "$IIS" = "Microsoft-IIS" ] ; then
exit 0
else
 echo "Norveld_Server_Check - FAILED" on "$LOCAL_DATE" | mail "$MAIL_ME" -s "$MAIL_SUBJECT"
 exit 1
fi
#EOF


Set this cron:
Code: Select all
*/1 * * * * /home/jj/Documents/cirrhus9/Accounts/Norveld/3WeekTest/norveldchk2.sh > /dev/null 2>&1


Take THAT Evil Doers!
What's a landing but a take off in reverse?
My DorkBlog
User avatar
Habitual
Level 8
Level 8
 
Posts: 2031
Joined: Sun Nov 21, 2010 8:31 pm
Location: Undecided


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 1 guest