File: 18_check_snmp_int_fix_perf_out

package info (click to toggle)
nagios-snmp-plugins 2.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,244 kB
  • sloc: perl: 7,453; sh: 309; makefile: 50
file content (41 lines) | stat: -rw-r--r-- 1,573 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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(-)

--- a/plugins/check_snmp_int.pl
+++ b/plugins/check_snmp_int.pl
@@ -1053,24 +1053,25 @@
 
 # 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"};
     }