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"};
     }
