Switch the subject to better reflect the topic and I move the script in development up here, it should be version 0.1 not 1.0. http://hobbitmon.svn.sourceforge.net/viewvc/hobbitmon/sandbox/modules/os-cou... I was able raise red flag if osversion is RH9. need to continue the work further to my goal. tj From: michael nemeth Sent: Thursday, November 13, 2008 4:50 AM To: hobbit at hswn.dk Subject: Re: [hobbit] [Hobbit/Xymon] PDF Reports I Did a little work on this yesterday. You have to parse the info section and look for the string "OS:" gabbing that line for further processing. BUT I think Ive an easy way to do what you want, will look into it today! T.J. Yang wrote: Thanks for sharing the code of your modification. I will need to parse "uname -a" section and have a hash or array to keep counting of os appearance... etc. later T.J. Yang
Date: Wed, 12 Nov 2008 07:34:06 -0500 From: michael.nemeth at lmco.com To: hobbit at hswn.dk Subject: Re: [hobbit] [Hobbit/Xymon] PDF Reports
|I have a pet project to write a oscount hobbit server side module by modifying |Henrik's rootlogin perl script. The script is to display statistics of OS types and their verions. Maybe this will help you with your project This is what to "parse " ps output on the server side to chech for running back-up (save -s). Watch out for line wraps #!/usr/local/bin/perl
#*----------------------------------------------------------------------------*/ #* Hobbit client message processor. */ #* */ #* This perl program shows how to create a server-side module using the */ #* data sent by the Hobbit clients. This program is fed data from the */ #* Hobbit "client" channel via the hobbitd_channel program; each client */ #* message is processed by looking at the [who] section and generates */ #* a "login" status that goes red when an active "root" login is found. */ #* */ #* Written 2007-Jan-28 by Henrik Storner <henrik at hswn.dk> */ #* */ #* This program is in the public domain, and may be used freely for */ #* creating your own Hobbit server-side modules. */ #* Henrik's script was modified by me, Mike Nemeth Michael.nemeth at lmco.com */ #* the rootlogin.pl which parses the [who] section was changed to parse */ #* the [ps] of client data. */ #* Often Ive seen people ask how to monitor a certain proccess and have */ #* a separted test/column for it This works for me! */ #* */ #*----------------------------------------------------------------------------*/
# $Id: rootlogin.pl,v 1.1 2007/01/28 12:42:34 henrik Exp $ # look for back-ups running: save -s
my $bb; my $bbdisp; my $hobbitcolumn = "bkup"; my $hostname = ""; my $msgtxt = ""; my %sections = (); my $cursection = "";
sub processmessage;
# Get the BB and BBDISP environment settings. $bb = $ENV{"BB"} || die "BB not defined"; $bbdisp = $ENV{"BBDISP"} || die "BBDISP not defined";
# Main routine. # # This reads client messages from <STDIN>, looking for the # delimiters that separate each message, and also looking for the # section markers that delimit each part of the client message. # When a message is complete, the processmessage() subroutine # is invoked. $msgtxt contains the complete message, and the # %sections hash contains the individual sections of the client # message.
while ($line = <STDIN>) { if ($line =~ /^\@\@client\#/) { # It's the start of a new client message - the header looks like this: # @@client#830759/HOSTNAME|1169985951.340108|10.60.65.152|HOSTNAME|sunos|sunos
# Grab the hostname field from the header @hdrfields = split(/\|/, $line); $hostname = $hdrfields[3];
# Clear the variables we use to store the message in $msgtxt = ""; %sections = (); } elsif ($line =~ /^\@\@/) { # End of a message. Do something with it. processmessage(); } elsif ($line =~ /^\[(.+)\]/) { # Start of new message section.
$cursection = $1; $sections{ $cursection } = "\n"; } else { # Add another line to the entire message text variable, # and the the current section. $msgtxt = $msgtxt . $line; $sections{ $cursection } = $sections{ $cursection } . $line; } }
# This subroutine processes the client message. In this case, # we watch the [ps] section of the client message and alert # if our string is found: save -s meaning backs are active.
sub processmessage { my $color; my $summary; my $statusmsg; my $cmd; my $cmdl;
# Dont do anything unless we have the "ps" section return unless ( $sections{"ps"} );
# Is the string/process somewhere in the "ps" section? # Note that we must match with /m because there are multiple # lines in the [ps] section. if ( ($cmdl) = $sections{"ps"} =~ /(save.+-s.*)/ ) { $color = "yellow"; $summary = "There MAYBE active backups" ; # $statusmsg = "&yellow " . $cmdl . $sections{"ps"}; # sendins out the entire ps section seam to cause some purples so just send the match `, hey you've a proc column all ready. $statusmsg = "&yellow " . $cmdl ; } else { $color = "green"; $summary = "Ok"; $statusmsg = "&green No backup active\n\n"; } # Build the command we use to send a status to the Hobbit daemon $cmd = $bb . " " . $bbdisp . " \"status " . $hostname . "." . $hobbitcolumn . " " . $color . " " . $summary . "\n\n" . $statusmsg . "\""; # And send the message system $cmd; }
T.J. Yang wrote:
-------------------------------------------------- From: "Martin Flemming" <martin.flemming at desy.de> Sent: Wednesday, November 12, 2008 4:14 AM To: <hobbit at hswn.dk> Subject: Re: [hobbit] [Hobbit/Xymon] PDF Reports
Hi, Thomas ..
i'm very interesting and other too, i think :-)
Second that. you can post your script here, I will upload the script to svn repository.
Or request an account from Henrik and upload the script yourself.
I have a pet project to write a oscount hobbit server side module by modifying Henrik's rootlogin perl script. The script is to display statistics of OS types and their verions. This is useful for management to understand how many Solaris 2.5.1, 2.6 are still hanging around in a big IT environment.
tj
.. the shire will be the right place ..
cheers, martin
On Wed, 12 Nov 2008, Thomas Séglard wrote:
Hello,
some months (year ?) ago, I wrote a few php/shell code lines to generate on-demand/automatised PDF reports with the help of the RRD data produced by Hobbit. At the time of coding, I've used 'libfpdf' but it's a pain to include PNG with alpha-channel.
I'm now in charge of a new platform and I setup Hobbit to monitor everything, of course :) Besides, I discovered the library 'tcpdf' which is very good and efficient. So, I decided to bring back my reports and have them to work with 'tcpdf'. Modifications were easy since 'tcpdf' is based on 'libfpdf' and now everything works again :) But this time, I really want to share this work with you on the Shire or whatever. I need to know if some of you are interested by these reports... Thus, just let me know.
Best regards,
ThomaS
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
------------------------------------------------------------------------------ Windows Live Hotmail now works up to 70% faster. Sign up today.