[hobbit] monitoring text file

Ryan Sclanders merlin_rbs at hotmail.com
Fri Apr 24 11:17:53 CEST 2009




Not sure if this helps but one of the client side scripts I created checks log files for certain expressions and reports back to xymon if the error count is greater than the last report.

The script is a shell script running in cygwin and look
something like:

#!/bin/sh

 

##############################################################################

## The script was written sh to be used in cygwin in
conjunction with BBWin

## The script checks the Application logs for errors or
exceptions

## Requirements:

## BBWin, Cygwin (Base install)

##############################################################################

 

CLEAR="clear"

RED="red"

YELLOW="yellow"

GREEN="green"

UNKNOWN="purple"

 

BB=BBWinCmd.exe

BBDISP=<BBWINSERVER>

MACHINE=`hostname`

COLUMN=<COLUMN_NAME>

COLOR=$GREEN

 

BBLOG=D:/Logs/AppLogs.txt

 

echo "Application Error Logs" > $BBLOG

 

if [ ! -e "D:/Logs/PREERRORS.log" ]; then

        `touch
D:/Logs/PREERRORS.log`

fi

 

PREERRORLOG=D:/Logs/PREERRORS.log



 PREERRORS=`cat D:/Logs/PREERRORS.log`



 APPLOG=D:/Logs/AppLog-"`eval date +%Y%m%d`".log

 

if [ -e $APPLOG ]; then

        ERRORS=`cat $APPLOG|
grep -i -e error -e exception | wc -l`

        else

        ERRORS=0

fi

 if [ "$ERRORS" -gt "$PREERRORS" ]; then

   COLOR=$RED

   echo "App Errors
= $ERRORS "\|" Previous Error Count = $PREERRORS" >>
$BBLOG

   echo
"LOG:" >> $BBLOG

   tail -n +1 $APPLOG|
grep -m 10 -i -e error -e exception >> $BBLOG

   echo "LOG
END" >> $BBLOG

   echo " "
>> $BBLOG

   echo " "
>> $BBLOG

   else

   echo "App
Errors = No New Errors "\|" Previous Error Count = $PREERRORS"
>> $BBLOG

fi

 

echo $ERRORS > $PREERRORLOG

 

# Tell Hobbit about it

$BB $BBDISP status $MACHINE $COLUMN $COLOR "`cat
D:/Logs/AppLogs.txt`"

exit 0





> Date: Thu, 23 Apr 2009 08:58:22 +1000
> From: Shea.Graeme.A at edumail.vic.gov.au
> To: hobbit at hswn.dk
> Subject: RE: [hobbit] monitoring text file
> 
> I posted a VB script to the shire that uses this idea to test the
> running of DCDiags. If you cut down that script so that it only opens
> your log file and looks for the word it will achieve what you want.
> Don't know how to get the method below to work.
> 
> Hope this helps
> 
> Regards
> Graeme
> 
> -----Original Message-----
> From: Johan Booysen [mailto:johan at matrix-data.co.uk] 
> Sent: Wednesday, 22 April 2009 2:25 AM
> To: hobbit at hswn.dk
> Subject: [hobbit] monitoring text file
> 
> I basically use hobbit 4.2.0 more or less as it comes out of the box and
> that's been sufficient for us.  The downside is that I don't actually
> know a lot about "advanced" features...
> 
> I want to monitor a plain text log file on one of our Windows servers
> (already running BBWin and reporting just fine).  I've RTFM and came to
> the conclusion that I need to do something like the following:
> 
> Specify the specific log file in client-local.cfg on the hobbit server:
> 
> [win32]
> log:"d:\Log directory with spaces in name\log.txt":10240
> 
> Configure hobbit-clients.cfg so that the occurrence of the word "error"
> causes the server's status to go red:
> 
> HOST=winservername
>         LOG "d:\Log directory with spaces in name\log.txt" %error
> color=red
> 
> Is this the correct way of doing this?  I guess not because it doesn't
> appear to be evaluating that log file.  I've had a look at the logs but
> see nothing to help.
> 
> Will appreciate advice on this.
> 
> Thanks.
> 
> To unsubscribe from the hobbit list, send an e-mail to
> hobbit-unsubscribe at hswn.dk
> 
> 
> 
> Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.
> 
> To unsubscribe from the hobbit list, send an e-mail to
> hobbit-unsubscribe at hswn.dk
> 
> 

_________________________________________________________________
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20090424/dd63dacf/attachment.html>


More information about the Xymon mailing list