Skip to content

Commit

Permalink
fix performance data output on space monitors (entities at critical w…
Browse files Browse the repository at this point in the history
…here skipped)

* this is just a least-instrusive fix for this impornat issue (fixes district09#74)

from my point of view the thing should be restructered further:
* call space_threshold_helper just once with both thresholds
* use a threshold-check function for the recurring task to determine intAlertLevel for a condition result
* include  thresholds in perf-data (also requested in district09#82) which would be quite hacky currently and I did not do yet despite I also want it
* output perfdata also for metrics where no threshold is defined (threshold is for alerting but a historical graph would be fine even if no alert is defined)
  • Loading branch information
Elias481 committed Sep 24, 2020
1 parent b059e0f commit 7e6d5c1
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions check_netapp_ontap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ sub calc_space_health {
my $intState = 0;
my $intObjectCount = 0;
my $strOutput;
my $perfOutput;
my %perfOutput = ();
my $hrefObjectState;

foreach my $strObj (keys %$hrefSpaceInfo) {
Expand Down Expand Up @@ -1628,8 +1628,8 @@ sub calc_space_health {

# Test to see if the monitored object has crossed a defined space threshhold.
unless ( (defined($hrefCritThresholds->{'strings'}) && @{$hrefCritThresholds->{'strings'}}) || (defined($hrefWarnThresholds->{'strings'}) && @{$hrefWarnThresholds->{'strings'}}) || $hrefWarnThresholds->{'owner'} || $hrefCritThresholds->{'owner'} ) {
($intState, $strOutput, $perfOutput, $hrefSpaceInfo) = space_threshold_helper($intState, $strOutput, $hrefSpaceInfo, $hrefCritThresholds, 2);
($intState, $strOutput, $perfOutput, $hrefSpaceInfo) = space_threshold_helper($intState, $strOutput, $hrefSpaceInfo, $hrefWarnThresholds, 1);
($intState, $strOutput, $hrefSpaceInfo) = space_threshold_helper($intState, $strOutput, $hrefSpaceInfo, $hrefCritThresholds, \%perfOutput, 2);
($intState, $strOutput, $hrefSpaceInfo) = space_threshold_helper($intState, $strOutput, $hrefSpaceInfo, $hrefWarnThresholds, \%perfOutput, 1);
}


Expand All @@ -1639,8 +1639,8 @@ sub calc_space_health {
$strOutput = "OK - No problem found ($intObjectCount checked)";
}

if ((defined($perfOutput))) {
$strOutput .= $perfOutput;
if (keys(%perfOutput) > 0) {
$strOutput .= ("\n| " . join(' ', values(%perfOutput)));
}


Expand All @@ -1650,10 +1650,7 @@ sub calc_space_health {

sub space_threshold_helper {
# Test the various monitored object values against the thresholds provided by the user.
my ($intState, $strOutput, $hrefVolInfo, $hrefThresholds, $intAlertLevel) = @_;

my $perfOutput = "";
my $perfOutputFinal = " | ";
my ($intState, $strOutput, $hrefVolInfo, $hrefThresholds, $perfOutput, $intAlertLevel) = @_;

foreach my $strVol (keys %$hrefVolInfo) {
my $bMarkedForRemoval = 0;
Expand All @@ -1680,8 +1677,8 @@ sub space_threshold_helper {
my $strReadableTotal = space_to_human_readable($hrefVolInfo->{$strVol}->{'space-total'});
my $strNewMessage = $strVol . " - " . $strReadableUsed . "/" . $strReadableTotal . " (" . $intUsedPercent . "%) SPACE USED";

if ($intAlertLevel == 1) {
$perfOutput .= "'" . $strVol . "_usage'=" . $hrefVolInfo->{$strVol}->{'space-used'} . "B;;;0;" . $hrefVolInfo->{$strVol}->{'space-total'} . " ";
if (!exists($perfOutput->{"space-$strVol"})) {
$perfOutput->{"space-$strVol"} = "'" . $strVol . "_usage'=" . $hrefVolInfo->{$strVol}->{'space-used'} . "B;;;0;" . $hrefVolInfo->{$strVol}->{'space-total'};
}

if (defined($hrefThresholds->{'space-percent'}) && defined($hrefThresholds->{'space-count'})) {
Expand Down Expand Up @@ -1727,8 +1724,8 @@ sub space_threshold_helper {
$intUsedPercent = floor($intUsedPercent + 0.5);
my $strNewMessage = $strVol . " - " . $hrefVolInfo->{$strVol}->{'inodes-used'} . "/" . $hrefVolInfo->{$strVol}->{'inodes-total'} . " (" . $intUsedPercent . "%) INODES USED";

if ($intAlertLevel == 1) {
$perfOutput .= "'" . $strVol . "_inodes'=" . $hrefVolInfo->{$strVol}->{'inodes-used'} . "B;;;0;" . $hrefVolInfo->{$strVol}->{'inodes-total'} . " ";
if (!exists($perfOutput->{"inodes-$strVol"})) {
$perfOutput->{"inodes-$strVol"} = "'" . $strVol . "_inodes'=" . $hrefVolInfo->{$strVol}->{'inodes-used'} . "B;;;0;" . $hrefVolInfo->{$strVol}->{'inodes-total'};
}

if (defined($hrefThresholds->{'inodes-percent'}) && defined($hrefThresholds->{'inodes-count'})) {
Expand Down Expand Up @@ -1772,12 +1769,7 @@ sub space_threshold_helper {
}
}

if ($intAlertLevel == 1) {
#print "perfOutput: " . $perfOutput . "\n";
$perfOutputFinal .= $perfOutput;
}

return $intState, $strOutput, $perfOutputFinal, $hrefVolInfo;
return $intState, $strOutput, $hrefVolInfo;
}

sub space_threshold_converter {
Expand Down

0 comments on commit 7e6d5c1

Please sign in to comment.