[hobbit] creating a report of all the notifications sent by hobbit

Henrik Stoerner henrik at hswn.dk
Wed Feb 7 07:51:59 CET 2007


On Tue, Feb 06, 2007 at 04:17:59PM -0600, Hubbard, Greg L wrote:
> I knew it would be easy, but he wanted to be able to specify a time and
> have it display all the entries that were NEWER (or maybe older), so
> that it where it gets harder.  Are there any shell shortcuts for data
> comparisons?  I haven't gotten the trusty "UNIX in a Nutshell" out
> yet...

The 9th field is the Unix timestamp of the notification, so it would
be trivial to compare that against a cut-off timestamp. Remember: The
logfiles are BB compatible, and BB used shell scripts for most of its
work. E.g.

#!/bin/sh

# Invoked as CGI with http://www/cgi-bin/notifylog.sh?12345&67890
# The numbers are the unix timestamps for beginning and end time
# of the report, can be generated with GNU date using "+%s" format.
#
# NOTE: It is horribly insecure to blindly use $QUERY_STRING in
#       shell scripts! This is ONLY for demonstration purposes!

STARTTIME="`echo $QUERY_STRING | cut -d'&' -f1`"
ENDTIME="`echo $QUERY_STRING | cut -d'&' -f2`"

(echo "<table summary=Notifications border=1>"
 echo "<tr><th align=left>Time</th><th align=left>Host.service</th><th
align=left>Recipient</th></tr>"

 cat /var/log/hobbit/notifications.log |  while read L  do
    set $L

    if test $9 -ge "$STARTTIME" -a $9 -lt "$ENDTIME"
    then
       echo "<tr>"
       echo "<td>$1 $2 $3 $4 $5</td>"
       echo "<td>$6</td>"
       echo "<td>$8</td>"
       echo "</tr>"
    fi
 done

 echo "</table>") | bbcmd bb-webpage
exit 0


Henrik




More information about the Xymon mailing list