Skip to content

Commit

Permalink
add performance data for snapmirror, and linefeed option for output
Browse files Browse the repository at this point in the history
  • Loading branch information
ngarratt authored and Neil Garratt - bastionwt1 committed Dec 16, 2020
1 parent 6c85ef8 commit 37b80e7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion check_netapp_ontap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
if ($verbose || $debug || $trace) {
use Data::Dumper;
}
my $lineFeed = undef;

##############################################
## DISK HEALTH
Expand Down Expand Up @@ -1144,6 +1145,7 @@ sub calc_snapmirror_health {
my $intState = 0;
my $intObjectCount = 0;
my $strOutput;
my %perfOutput = ();

foreach my $strSM (keys %$hrefSMInfo) {
$intObjectCount = $intObjectCount + 1;
Expand Down Expand Up @@ -1172,13 +1174,18 @@ sub calc_snapmirror_health {
$intState = get_nagios_state($intState, 1);
}
}
$perfOutput{"snapmirror-$strSM"} = "'" . $strSM . "_snapmirror'=" . $hrefSMInfo->{$strSM}->{'lag'} . "s;" . $hrefWarnThresholds->{'lag-time'} . ";" . $hrefCritThresholds->{'lag-time'} . ";;";
}

# If everything looks ok and no output has been defined then set the message to display OK.
if (!(defined($strOutput))) {
$strOutput = "OK - No problem found ($intObjectCount checked)";
}

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

return $intState, $strOutput;
}

Expand Down Expand Up @@ -1943,6 +1950,8 @@ sub help {
This modifier is used to set an inclusive or exclusive filter on what you want to monitor.
--report, -r
The output format. Can be "short", "long" (default), or "html"
--linefeed, -l
Use linefeed for object separation instead of comma (requires nagios 3.x or later)
--verbose, --debug, --trace
Debug output options
--help, -h
Expand Down Expand Up @@ -2077,7 +2086,7 @@ sub get_nagios_description {
if (!(defined($strOutput))) {
$strOutput = $strNewMessage;
} else {
$strOutput .= ", " . $strNewMessage;
$strOutput .= (defined $lineFeed ? "\n" : ", ") . $strNewMessage;
}

return $strOutput;
Expand Down Expand Up @@ -2187,6 +2196,7 @@ sub filter_object {
"c=s" => \$strCritical, "critical=s" => \$strCritical,
"m=s" => \$strModifier, "modifier=s" => \$strModifier,
"r=s" => \$strReport, "report=s" => \$strReport,
"l" => \$lineFeed, "linefeed" => \$lineFeed,
"verbose" => \$verbose,
"debug" => \$debug,
"trace" => \$trace,
Expand Down

0 comments on commit 37b80e7

Please sign in to comment.