Build precise queries to find exactly what you need
Press ESC to close
Nagios World Conference 2026: Sept. 14-17 in St. Paul, MN | Learn More
Two things are needed. First of all, you need to run “cpan DateTime::Format::Epoch::Unix” to install this module. If anyone knows an RPM on RHEL/Centos please leave a comment. Next, the biggest problem, the correct exit status when treshhold is reached doesn’t work. So I fixed it. I’m not a Perl programmer, so if it looks somewhat crude, please excuse me. Copy/paste the following code and run it as a patch: — /tmp/check_ganglia.pl 2013-03-21 12:43:48.000000000 +0100 +++ check_ganglia.pl 2013-03-22 08:38:48.574700147 +0100 @@ -14,7 +14,6 @@ # TODO: call $cluster{host} hash directly instead of seeking within it. # TODO: Fix some clusters that don’t match host checks… # TODO: add retval matching (range, string, etc) -# TODO: fix warn/crit to measure returned metric # TODO: !!! NEXT !!! call $cluster{host} hash directly instead of seeking within it. # TODO: !!! NEXT !!! better, pass in cluster:host context for direct passing of XML # TODO: !!! NEXT !!! use syntax localhost:8652 TCP @@ -22,6 +21,7 @@ # TODO: !!! NEXT !!! Or, since that requires knowing the CLUSTER, make it option and check the hostname as key # TODO: !!! NEXT !!! for the hash of each cluster found. Still reduces cpu/time drastically # +# 2013-03-22: Tom Kerremans: fixed warn/crit to measure returned metric, removed some obsolete notifications ###########
# core modules needed: @@ -72,6 +72,7 @@ exit $ERRORS{‘CRITICAL’}; }
+ sub isnumeric() { my ($x) = @_; @@ -128,14 +129,14 @@ } #/ if hostcheck
if (defined($warn)) { – print “WARN definedn”; + #print “WARN definedn”; #if ( ! isnumeric($warn) ) { die “NOT NUMERIC n”; } #die “NOT NUMERIC n” if ( ! isnumeric($warn) ) ; die “## $warn is NOT NUMERIC n” if $_ =~ s/[a-z]//; }
if (defined($crit)) { – print “CRIT definedn”; + #print “CRIT definedn”; }
} #/ sub processargs @@ -301,9 +302,9 @@ ###: ELI: WTF did I put this in here for?? ### DELETEME
-### FUNC: output_match -#sub output_match { -#my $output = shift; +## FUNC: output_match +sub output_match { +my $output = shift;
# perform string regex match on retval: # if ( “$output” =~ /.*$match.*/ ) { @@ -314,17 +315,20 @@ # exit 2; # }
-## perform range check for warn/crit values: -# if ( “$output” >= “$crit” ) { -# exit 1; -# } elsif ( “$output” >= “$warn” ) { -# exit 2; -# } else { -# exit 0; -# } +# perform range check for warn/crit values: + if ( “$output” >= “$crit” ) { + print “CRITICAL: $metric = $output higher than treshhold of $critn”; + exit 2; + } elsif ( “$output” >= “$warn” ) { + print “WARNING: $metric = $output higher than treshhold of $warnn”; + exit 1; + } else { + print “OK: $metric = $outputn”; + exit 0; + }
-#} #/sub -### /FUNC: output_match +} #/sub +## /FUNC: output_match
#^^^^ ##: ELI: WTF did I put this in here for?? #^^^^ ## DELETEME @@ -386,14 +390,14 @@ print “UNKNOWN: ($metric) not found in host XML! “,”n”; exit $ERRORS{‘UNKNOWN’} } else { – print “OK: $metric = $host_metrics{$metric} n”; – exit $ERRORS{‘OK’}; + &output_match ($host_metrics{$metric}); } } # /unless ($metric)
} else {# /if ($hostname eq)
} # /if hostname loop through hash. We’ve exhausted input data, exit now: + } # /foreach $hostkey
# don’t exit here, create exit at end of all arrays to be searched (after function exits searching the last hash)