[Nagiosplug-devel] check_log plugin

John.Riddoch at scottishwater.co.uk John.Riddoch at scottishwater.co.uk
Mon Nov 17 07:38:11 CET 2003


I've been testing Nagios and I've found a few issues with the "check_log" 
plugin:

1. On log switches, it flags an error if there were any messages in the 
previous log; it doesn't differentiate between errors which have appeared 
and errors which have gone.  This can be fixed by changing the line:
count=`$GREP -c "$query" $tempdiff`
to
count=`$GREP -c "^>.*$query" $tempdiff`

2. The 'tail' command relies on GNU tail; Solaris (and other Unix) tail 
versions don't have long command options.  Fix is to change:
lastentry=`$GREP "$query" $tempdiff | $TAIL --lines=1`
to
lastentry=`$GREP "^>.*$query" $tempdiff | $TAIL -1`
Note that we also incorporate the grep change here.

3. PATH is set to "", but the chmod isn't given a full path; change:
chmod 600 $tempdiff
to
/bin/chmod 600 $tempdiff

A diff of all these changes is:
# diff check_log.bak check_log
192c192
<     chmod 600 $tempdiff
---
>     /bin/chmod 600 $tempdiff
198c198
< count=`$GREP -c "$query" $tempdiff`
---
> count=`$GREP -c "^>.*$query" $tempdiff`
201c201
< lastentry=`$GREP "$query" $tempdiff | $TAIL --lines=1`
---
> lastentry=`$GREP "^>.*$query" $tempdiff | $TAIL -1`

Hope these changes prove useful.

John Riddoch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20031117/25237d7d/attachment.html>


More information about the Devel mailing list