creating a report of all the notifications sent by hobbit
Is there a way to use the hobbit cgi scripts to generate a report listing all of the notifications sent by Hobbit (i.e. from log/notifications.log) for a specific time frame?
Tom Georgoulias Systems Engineer McClatchy Interactive tomg at mcclatchyinteractive.com
I bet you could write one in short order by using one of the existing CGI's as a framework.
-----Original Message----- From: Tom Georgoulias [mailto:tomg at mcclatchyinteractive.com] Sent: Tuesday, February 06, 2007 10:45 AM To: hobbit mailing list Subject: [hobbit] creating a report of all the notifications sent by hobbit
Is there a way to use the hobbit cgi scripts to generate a report listing all of the notifications sent by Hobbit (i.e. from log/notifications.log) for a specific time frame?
Tom Georgoulias Systems Engineer McClatchy Interactive tomg at mcclatchyinteractive.com
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
Hubbard, Greg L wrote:
I bet you could write one in short order by using one of the existing CGI's as a framework.
Thought about using bb-eventlog.c, but I don't know much about C programming. I'll try and give it a shot anyway--can't hurt.
Tom Georgoulias Systems Engineer McClatchy Interactive tomg at mcclatchyinteractive.com
I think all you need is a Perl script to prompt for the start time, then have it read the notification log, skipping everything that is older than the entered time. You will have to parse each notification entry for the notification time, convert it to an internal format, and then compare to the time you get from the form.
You might be able to do it in shell, but I am not sure what could be used to convert times into something that can be compared.
GLH
-----Original Message----- From: Tom Georgoulias [mailto:tomg at mcclatchyinteractive.com] Sent: Tuesday, February 06, 2007 2:03 PM To: hobbit at hswn.dk Subject: Re: [hobbit] creating a report of all the notifications sent by hobbit
Hubbard, Greg L wrote:
I bet you could write one in short order by using one of the existing CGI's as a framework.
Thought about using bb-eventlog.c, but I don't know much about C programming. I'll try and give it a shot anyway--can't hurt.
Tom Georgoulias Systems Engineer McClatchy Interactive tomg at mcclatchyinteractive.com
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
On 2/6/07, Hubbard, Greg L <greg.hubbard at eds.com> wrote:
I think all you need is a Perl script to prompt for the start time, then have it read the notification log, skipping everything that is older than the entered time. You will have to parse each notification entry for the notification time, convert it to an internal format, and then compare to the time you get from the form.
You might be able to do it in shell, but I am not sure what could be used to convert times into something that can be compared.
If you're on a system with the GNU 'date' program, you can feed it a date and use the format string to get seconds-since-the-epoch:
e.g. date +%s --date="2/6/2007 14:00"
give you: 1170792000
Then you can do math on that using expr.
I'm using that for tracking SSL cert expiry.
Ralph Mitchell
On Tue, Feb 06, 2007 at 03:02:51PM -0500, Tom Georgoulias wrote:
Hubbard, Greg L wrote:
I bet you could write one in short order by using one of the existing CGI's as a framework.
Thought about using bb-eventlog.c, but I don't know much about C programming. I'll try and give it a shot anyway--can't hurt.
For a simpler approach, how about just scripting something that shows the "notifications.log" file nicely on a HTML page ?
The notifications log is fairly simple: Entries look like this:
Thu Jan 11 18:17:52 2007 fenris.hswn.dk.cpu (172.16.10.254) henrik at hswn.dk[121] 1168535872 200
Most fields are obvious; the "[121]" after the mail address is the linenumber in hobbit-alerts.cfg that triggered this alert. "1168535872" is the timestamp in Unix epoch form, same as what is on the start of the line. "200" is the numeric service identifier, here it's for the "cpu" status.
For the Hobbit "look", you can feed the content through bb-webpage.
So a quick hack would be:
#!/bin/sh (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
echo "<tr>"
echo "<td>$1 $2 $3 $4 $5</td>"
echo "<td>$6</td>"
echo "<td>$8</td>"
echo "</tr>"
done
echo "</table>") | bbcmd bb-webpage exit 0
Regards, Henrik
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...
GLH
-----Original Message----- From: Henrik Stoerner [mailto:henrik at hswn.dk] Sent: Tuesday, February 06, 2007 3:47 PM To: hobbit at hswn.dk Subject: Re: [hobbit] creating a report of all the notifications sent by hobbit
On Tue, Feb 06, 2007 at 03:02:51PM -0500, Tom Georgoulias wrote:
Hubbard, Greg L wrote:
I bet you could write one in short order by using one of the existing
CGI's as a framework.
Thought about using bb-eventlog.c, but I don't know much about C programming. I'll try and give it a shot anyway--can't hurt.
For a simpler approach, how about just scripting something that shows the "notifications.log" file nicely on a HTML page ?
The notifications log is fairly simple: Entries look like this:
Thu Jan 11 18:17:52 2007 fenris.hswn.dk.cpu (172.16.10.254) henrik at hswn.dk[121] 1168535872 200
Most fields are obvious; the "[121]" after the mail address is the linenumber in hobbit-alerts.cfg that triggered this alert. "1168535872" is the timestamp in Unix epoch form, same as what is on the start of the line. "200" is the numeric service identifier, here it's for the "cpu" status.
For the Hobbit "look", you can feed the content through bb-webpage.
So a quick hack would be:
#!/bin/sh (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
echo "<tr>"
echo "<td>$1 $2 $3 $4 $5</td>"
echo "<td>$6</td>"
echo "<td>$8</td>"
echo "</tr>"
done
echo "</table>") | bbcmd bb-webpage exit 0
Regards, Henrik
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
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
Hi, i think i could integrade it in my admin_scripts. Which licenc is this code? (I will not made it twice)
thx Stefan
aspect online AG Beim Glaspalast 1 86153 Augsburg
Fon: +49(0)821-247 47 085
stefan.freisler at aspect-online.de www.aspect-online.de
Amtsgericht Augsburg HRB 20 24 Ust-ID: DE204754384 Genehmigung §34c Gewerbeordnung: Landratsamt Augsburg
Vorstand: Reinhold Berger, Helmut Paesler, Wolfgang Schütz Aufsichtsratsvorsitzender: Stephan Gabriel
On Wed, Feb 07, 2007 at 08:14:43AM +0100, stefan.freisler at aspect-online.de wrote:
i think i could integrade it in my admin_scripts. Which licenc is this code? (I will not made it twice)
I normally don't copyright such simple scripts, so you can regard as being in the public domain.
Regards, Henrik
Henrik Stoerner wrote:
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.
Henrik, thanks for the example shell script in your previous message. I've already got that configured on my server and round one is over, which was simply to get the data into an area where a non-Tom can see it. ;)
I would still like to have a Hobbit option where our staff can search through the notification logs in the same way we can search the events.
As for modifying the bb-eventlog.c approach, I actually spent about an hour working on it and it appears that I would have to modify/create many other files to have full access to all of the notification data I'd need. To make a bb-notifylog cgi, I think I'd have to create code in hobbitd/lib/notification.c/h, add a chunk of html to hobbitd/web/event_form, create hobbitd/bb-notifylog.c, sh, sh.DIST, etc., and all of the necessary Makefile and menu_items.js changes. Unless I'm missing the obvious, it's not the most straightforward task.
Tom
-- Tom Georgoulias Systems Engineer McClatchy Interactive tomg at mcclatchyinteractive.com
On Wed, Feb 07, 2007 at 10:03:31AM -0500, Tom Georgoulias wrote:
I would still like to have a Hobbit option where our staff can search through the notification logs in the same way we can search the events.
As for modifying the bb-eventlog.c approach, I actually spent about an hour working on it and it appears that I would have to modify/create many other files to have full access to all of the notification data I'd need. To make a bb-notifylog cgi, I think I'd have to create code in hobbitd/lib/notification.c/h, add a chunk of html to hobbitd/web/event_form, create hobbitd/bb-notifylog.c, sh, sh.DIST, etc., and all of the necessary Makefile and menu_items.js changes. Unless I'm missing the obvious, it's not the most straightforward task.
I guess having worked with the code previously does have some advantages.
You're right about several things having to be modified. But don't worry, I already did it and there's a notification log CGI in the snapshot - mostly cut-and-pasted from the current event log view, so you have the same filtering mechanisms.
Grab it from http://www.hswn.dk/beta/
If you'd rather not jeopardize your current setup, just run "make" and then copy these by hand:
- web/hobbit-notifylog.cgi to ~hobbit/server/bin/
- web/hobbit-notifylog.sh to ~hobbit/cgi-bin/
- hobbitd/webfiles/notify* to ~hobbit/server/web/ and update the ~hobbit/data/www/menu/menu_items.js file with the new entry for the notification log (see hobbitd/wwwfiles/menu/menu_items.js).
Regards, Henrik
Henrik Stoerner wrote:
On Wed, Feb 07, 2007 at 10:03:31AM -0500, Tom Georgoulias wrote:
I would still like to have a Hobbit option where our staff can search through the notification logs in the same way we can search the events.
You're right about several things having to be modified. But don't worry, I already did it and there's a notification log CGI in the snapshot - mostly cut-and-pasted from the current event log view, so you have the same filtering mechanisms.
Grab it from http://www.hswn.dk/beta/
Wow, thanks a lot! Got it on my 4.2.0 server and it works really well. I really hate to bite the hand that feeds, but one thing I know we could benefit from is the ability to search on a specific recipient email address. That way we can easily see which servers/test alerts were sent to our developers, how many times the customer support folks were notified, etc.
Tom Georgoulias Systems Engineer McClatchy Interactive tomg at mcclatchyinteractive.com
Hi, i will public a new version of my adminscripts on friday with this function. (Filter Server, Test, Time, Recipient) If you want i can send you an preview tomorrw.
cu Stefan
On Wed, Feb 07, 2007 at 01:32:16PM -0500, Tom Georgoulias wrote:
Henrik Stoerner wrote:
On Wed, Feb 07, 2007 at 10:03:31AM -0500, Tom Georgoulias wrote:
I would still like to have a Hobbit option where our staff can search through the notification logs in the same way we can search the events.
You're right about several things having to be modified. But don't worry, I already did it and there's a notification log CGI in the snapshot - mostly cut-and-pasted from the current event log view, so you have the same filtering mechanisms.
Grab it from http://www.hswn.dk/beta/
Wow, thanks a lot! Got it on my 4.2.0 server and it works really well. I really hate to bite the hand that feeds, but one thing I know we could benefit from is the ability to search on a specific recipient email address.
No problem, I just added it.
Henrik
Henrik Stoerner wrote:
I know we could benefit from is the ability to search on a specific recipient email address.
No problem, I just added it.
Works well. Thank you very much for that feature.
Tom Georgoulias Systems Engineer McClatchy Interactive tomg at mcclatchyinteractive.com
participants (6)
-
greg.hubbard@eds.com
-
henrik@hswn.dk
-
ralphmitchell@gmail.com
-
stefan.freisler@aspect-online.de
-
tomg@mcclatchyinteractive.com
-
wdsl@gmx.de