check_snmp_int.pl: fix perf_out not defined error by adding d/p/18_check_snmp_int_fix_perf_out

This commit is contained in:
Jan Wagner 2020-12-07 15:38:56 +01:00
parent 085ba7e17c
commit 84561d3e52
2 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,43 @@
From effd196f76c4f4e9505b0955b020f8f65f1700a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Szafer?= <pszafer@gmail.com>
Date: Mon, 16 Mar 2020 18:41:49 +0100
Subject: [PATCH] fix perf_out not defined error
---
plugins/check_snmp_int.pl | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/plugins/check_snmp_int.pl b/plugins/check_snmp_int.pl
index 6e42163..1f0cdc2 100755
--- a/plugins/check_snmp_int.pl
+++ b/plugins/check_snmp_int.pl
@@ -993,24 +993,25 @@ sub check_options {
# Check if all interface are OK
if ($num_ok == $num_int) {
+ my $is_perf_defined = defined($perf_out) && defined($o_perf);
if ($final_status == 0) {
print $print_out, ":", $num_ok, " UP: OK";
- if (defined($o_perf)) { print " | ", $perf_out; }
+ if ($is_perf_defined) { print " | ", $perf_out; }
print "\n";
exit $ERRORS{"OK"};
} elsif ($final_status == 1) {
print $print_out, ":(", $num_ok, " UP): WARNING";
- if (defined($o_perf)) { print " | ", $perf_out; }
+ if ($is_perf_defined) { print " | ", $perf_out; }
print "\n";
exit $ERRORS{"WARNING"};
} elsif ($final_status == 2) {
print $print_out, ":(", $num_ok, " UP): CRITICAL";
- if (defined($o_perf)) { print " | ", $perf_out; }
+ if ($is_perf_defined) { print " | ", $perf_out; }
print "\n";
exit $ERRORS{"CRITICAL"};
} else {
print $print_out, ":(", $num_ok, " UP): UNKNOWN";
- if (defined($perf_out)) { print " | ", $perf_out; }
+ if ($is_perf_defined) { print " | ", $perf_out; }
print "\n";
exit $ERRORS{"UNKNOWN"};
}

View file

@ -6,5 +6,6 @@
15_check_snmp_int_spaces 15_check_snmp_int_spaces
16_check_snmp_win_max_message_size 16_check_snmp_win_max_message_size
17_check_snmp_storage_okifempty 17_check_snmp_storage_okifempty
18_check_snmp_int_fix_perf_out
50_disable_epn 50_disable_epn
51_fix_privacy_doc 51_fix_privacy_doc