[Xymon] EXT :Re: How to grab time-since-last-change for a test?
Nico
nicolas at lienard.name
Thu Nov 15 19:27:10 CET 2012
Hi David;
Drop these lines:
> my $HOB_BIN = "/usr/local/xymon/client/bin";
> my $HOB_SERV = "XXX.XXX.XXX.XXX"; # Substitute the FQDN or IP for your Hobbit server
Then change this line to have a filter with the high days on top and using xymon variable ( i use BB to have compatibility with older version, adapt as well).
my @current_non_green_hosts = `$ENV{BB} $ENV{BBDISP} "xymondboard color=red,yellow,purple fields=hostname,testname,color,lastchange" | sort --field-separator="|" -k4`;
cheers
nico
Le 15 nov. 2012 à 18:36, Mills, David (IS) a écrit :
> Jeremy –
>
> Many thanks / that’s exactly what I needed. Now time to “give back”. I’m pasting the little Perl script I wrote to summarize, in tabular format, all non-green alerts currently older than a week…
>
> === Sample output (appears ‘tabular’ in fixed font):
>
> ** Host Name ** ** Test ** ** Color ** ** Days Since Change **
> ApntmntDtlSrvc_A http red 9.91
> App-Completed http red 9.91
> App-Complete_B http red 9.91
> App-Complete_C http red 9.91
> App-Complete_D http red 9.91
> ...
>
> === Code: (‘Hope this helps someone!)
> #!/usr/bin/perl
>
> #------------------------------------------------------------------------------------------------
> # Extract list of "stale" alerts from Xymon server / format list as 4-column table:
> # Host / (non-green) Test / (current) Color / # of days since last change
> #
> # 11/15/12 -- david mills
> #------------------------------------------------------------------------------------------------
>
> use strict;
>
> my $HOB_BIN = "/usr/local/xymon/client/bin";
> my $HOB_SERV = "XXX.XXX.XXX.XXX"; # Substitute the FQDN or IP for your Hobbit server
>
> my $grace_period_in_secs = 7 * 24 * 60 * 60; # 1 week expressed as seconds
> my $grace_period_threshold = (time - $grace_period_in_secs);
>
> my @current_non_green_hosts = `$HOB_BIN/xymon $HOB_SERV "xymondboard color=red,yellow,purple fields=hostname,testname,color,lastchange"`;
>
> my $col1_margin = 50; # Output col width
> my $other_cols_margin = 15;
> printf("%-${col1_margin}s%-${other_cols_margin}s%-${other_cols_margin}s%-${other_cols_margin}s%-${other_cols_margin}s\n",
> "** Host Name **",
> "** Test **",
> "** Color **",
> "** Days Since Change **" );
>
> foreach my $host_rec ( @current_non_green_hosts ) {
> my @flds = split /\|/, $host_rec;
>
> my $days_since_last_change = (time - $flds[3]) / (60 * 60 * 24);
> printf("%-${col1_margin}s %-${other_cols_margin}s%-${other_cols_margin}s %.2f\n",
> @flds[0..2],
> $days_since_last_change)
> if ($grace_period_threshold >= $flds[3]);
> }
>
> From: Jeremy Laidman [mailto:jlaidman at rebel-it.com.au]
> Sent: Wednesday, November 14, 2012 5:42 PM
> To: Mills, David (IS)
> Cc: xymon at xymon.com
> Subject: EXT :Re: [Xymon] How to grab time-since-last-change for a test?
>
> On 15 November 2012 07:16, Mills, David (IS) <David.Mills at ngc.com> wrote:
> All –
>
> What is the easiest way to grab the timestamp of the last status change for given host / test from a script?
>
> Maybe something like this:
>
> xymoncmd xymon localhost 'xymondboard host=hostname test=cpu fields=hostname,testname,color,lastchange'
>
> For more info, see the "xymondboard" section of the "xymon" man page:http://xymon.org/xymon/help/manpages/man1/xymon.1.html.
>
> J
>
> _______________________________________________
> Xymon mailing list
> Xymon at xymon.com
> http://lists.xymon.com/mailman/listinfo/xymon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20121115/ba668121/attachment.html>
More information about the Xymon
mailing list