Image

Image

Search This Blog

Monday, November 03, 2008

hp notifier

open source version :)

#!/bin/bash

# hp/compaq notifier. to be run from cron. require psp

#define addresses where warnings will be sent

recipient1=service@XXXXXXXXX.com

recipient2=sxxxxxx@XXXXXXX.com

#let’s check if we have events in the ILO log

/sbin/hplog -v | grep -B 1 -E ‘Error|Failure|Screen|ASR’ >> /tmp/ciss2.$$

set `wc /tmp/ciss2.$$`

if [ $1 -eq 0 ]

then

#if the ILO log is empty get out

exit 0

fi

#if there is something in the log, check if we have a previous logfile

if [ ! -f /var/log/ciss.log ]

then

#create one if we don’t have it yet

touch /var/log/ciss.log

fi

#compare the newly readed infos from ILO with those from previous logfile

grep -v -f /var/log/ciss.log /tmp/ciss2.$$ > /tmp/ciss3.$$

#if there are differences

if [ -s /tmp/ciss3.$$ ]

then

#replace previous log with the new one

cat /tmp/ciss2.$$ > /var/log/ciss.log

#add some cosmetic informations

echo -en “End of report on: ” >> /tmp/ciss2.$$

date >> /tmp/ciss2.$$

#and warn the administrators

#
cat /tmp/ciss2.$$ | /bin/mail -s ‘Error on $HOSTNAME’ $recipient1
# cat /tmp/ciss2.$$ | /bin/mail -s ‘Error on $HOSTNAME’ $recipient2

echo “comment this line and uncomment the line before” ; cat /tmp/ciss2.$$ fi

#then let’s do some cleanup

rm -f /tmp/ciss*

exit 0

PS: the script is modified a bit, as blogger.com does not allow some strings such as: < followed by /location/file...

No comments:

Post a Comment

Blog Archive