From 55bb5a061c11f391b6b05dcabda4e2799307aead Mon Sep 17 00:00:00 2001 From: Neil Garratt Date: Wed, 16 Dec 2020 11:22:54 -0500 Subject: [PATCH 1/2] add performance data for snapmirror, and linefeed option for output --- check_netapp_ontap.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/check_netapp_ontap.pl b/check_netapp_ontap.pl index a3b0b03..a959f8d 100755 --- a/check_netapp_ontap.pl +++ b/check_netapp_ontap.pl @@ -32,6 +32,7 @@ if ($verbose || $debug || $trace) { use Data::Dumper; } +my $lineFeed = undef; ############################################## ## DISK HEALTH @@ -1161,6 +1162,7 @@ sub calc_snapmirror_health { my $intState = 0; my $intObjectCount = 0; my $strOutput; + my %perfOutput = (); foreach my $strSM (keys %$hrefSMInfo) { $intObjectCount = $intObjectCount + 1; @@ -1189,6 +1191,7 @@ 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. @@ -1196,6 +1199,10 @@ sub calc_snapmirror_health { $strOutput = "OK - No problem found ($intObjectCount checked)"; } + if (keys(%perfOutput) > 0) { + $strOutput .= ("\n| " . join(' ', values(%perfOutput))); + } + return $intState, $strOutput; } @@ -1970,6 +1977,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 @@ -2104,7 +2113,7 @@ sub get_nagios_description { if (!(defined($strOutput))) { $strOutput = $strNewMessage; } else { - $strOutput .= ", " . $strNewMessage; + $strOutput .= (defined $lineFeed ? "\n" : ", ") . $strNewMessage; } return $strOutput; @@ -2214,6 +2223,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, From cac72d04008aaaa1ce2659c5d7b32f0416725713 Mon Sep 17 00:00:00 2001 From: Neil Garratt Date: Tue, 25 May 2021 17:13:51 -0400 Subject: [PATCH 2/2] Document the --linefeed option in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bafbe52..413821d 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Copy `check_netapp_ontap.pl` script to your nagios libexec folder and configure * --warning, -w => A custom warning threshold value. See the option and threshold list at the bottom of this help text. * --critical, -c => A custom warning threshold value. See the option and threshold list at the bottom of this help text. * --modifier, -m => This modifier is used to set an inclusive or exclusive filter on what you want to monitor. +* --linefeed, -l => Add linefeeds between multi-line diagnostic output entries. * --help, -h => Display this help text. ### Options