[Resmon-devel] [resmon commit] Resmon Resource Monitor branch, master, updated. cbdafc7828c365598882711905b828493f504a59

git at labs.omniti.com git at labs.omniti.com
Mon Apr 25 15:47:19 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Resmon Resource Monitor".

The branch, master has been updated
       via  cbdafc7828c365598882711905b828493f504a59 (commit)
       via  dae50c14b6528ce350c00784c59bcb59f1ab61e3 (commit)
      from  92cfa46746b7b066236f784998687a05e94f9e24 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cbdafc7828c365598882711905b828493f504a59
Author: Mark Harrison <mark at mivok.net>
Date:   Mon Apr 25 15:41:47 2011 -0400

    Deal with multiple checks in resmon output
    
    An example of this is the resmon main page. By default this check will look
    at http://hostname:81/modulename/checkname which will output a single check.
    However, this change lets you specify a custom URL which returns metrics for
    multiple modules and it will find the correct one.

diff --git a/resources/check_resmon_metric b/resources/check_resmon_metric
index 9ed5e39..3adc516 100755
--- a/resources/check_resmon_metric
+++ b/resources/check_resmon_metric
@@ -325,13 +325,19 @@ eval {
     #use Data::Dumper;
     #print Dumper($ref->{ResmonResult});
 
+    my $idx;
+    for ($idx=0; $idx < $#{$ref->{ResmonResult}}; $idx++) {
+        last if ($ref->{ResmonResult}->[$idx]->{module} eq $module &&
+            $ref->{ResmonResult}->[$idx]->{service} eq $check);
+    }
+
     # If we have stale information, then go critical
-    my $last_update = time() - $ref->{ResmonResult}->[0]->{last_update}->[0];
+    my $last_update = time() - $ref->{ResmonResult}->[$idx]->{last_update}->[0];
     die "Stale metrics. Last updated $last_update seconds ago"
         if($age && $age < $last_update);
 
     # Get the metrics
-    my $metricval = $ref->{ResmonResult}->[0]->{metric}->{$metric};
+    my $metricval = $ref->{ResmonResult}->[$idx]->{metric}->{$metric};
 
     # Detect absence of a metric
     if (!defined($metricval)) {

commit dae50c14b6528ce350c00784c59bcb59f1ab61e3
Author: Mark Harrison <mark at mivok.net>
Date:   Mon Apr 25 15:41:15 2011 -0400

    Detect (and optionally return OK on) metric absence

diff --git a/resources/check_resmon_metric b/resources/check_resmon_metric
index 839e352..9ed5e39 100755
--- a/resources/check_resmon_metric
+++ b/resources/check_resmon_metric
@@ -82,6 +82,14 @@ similar fashion to resmon, you can specify an alternate url here. You only
 need to specify the part after hostname/port. For example, if you need to hit
 http://host:port/resmon then pass -u /resmon.
 
+=item -a
+
+Specify that an absence should be treated as an OK value. By default, if a
+metric is absent, it is treated as CRITICAL. A metric is considered absent if
+the check information can be fetched, but the metric itself isn't listed in
+the XML output. If the check information cannot be fetched, then it is still a
+critical error.
+
 =back
 
 =head1 THRESHOLDS
@@ -179,7 +187,7 @@ use utils qw($TIMEOUT %ERRORS &print_revision &support);
 delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
 
 my ($port, $host, $module, $check, $age, $warning, $critical, $equals, $regex,
-    $metric, $url) = (81,"","","",0, "", "", "", "");
+    $metric, $url, $allow_absent) = (81,"","","",0, "", "", "", "", 0);
 
 sub help {
     print "Usage: $0 [options]\n";
@@ -195,6 +203,7 @@ sub help {
     print " -e | --equals       metric must equal this value (numerical metrics only)\n";
     print " -r | --regex        regex match against the metric (string print metrics only)\n";
     print " -u | --url          specify an alternate URL to fetch\n";
+    print " -a | --allowabsent  Treat absences as OK (default: critical)\n";
     exit $ERRORS{'UNKNOWN'};
 }
 
@@ -281,7 +290,8 @@ GetOptions (
     "c|critical=s" => \$critical,
     "e|equals=i"   => \$equals,
     "r|regex=s"    => \$regex,
-    "u|url=s"      => \$url);
+    "u|url=s"      => \$url,
+    "a|allowabsent" => \$allow_absent);
 
 unless ($host && $module && $check) {
     short_help();
@@ -322,6 +332,18 @@ eval {
 
     # Get the metrics
     my $metricval = $ref->{ResmonResult}->[0]->{metric}->{$metric};
+
+    # Detect absence of a metric
+    if (!defined($metricval)) {
+        if ($allow_absent) {
+            $state = "OK";
+        } else {
+            $state = "CRITICAL";
+        }
+        print "$state: Metric $metric is absent\n";
+        exit $ERRORS{$state};
+    }
+
     my $value = $metricval->{content};
     my $type = $metricval->{type} || "0";
 

-----------------------------------------------------------------------

Summary of changes:
 resources/check_resmon_metric |   36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
Resmon Resource Monitor


More information about the Resmon-devel mailing list