From d4bd9c980ea433593f3badd6018cb7b36637618d Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Fri, 13 Jan 2023 10:50:17 +0000 Subject: [PATCH] Adding d/p/21_check_snmp_load_update_fortiswitch_and_fortigate4.3 from upstream --- ...p_load_update_fortiswitch_and_fortigate4.3 | 90 +++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 91 insertions(+) create mode 100644 debian/patches/21_check_snmp_load_update_fortiswitch_and_fortigate4.3 diff --git a/debian/patches/21_check_snmp_load_update_fortiswitch_and_fortigate4.3 b/debian/patches/21_check_snmp_load_update_fortiswitch_and_fortigate4.3 new file mode 100644 index 0000000..cf0ffcb --- /dev/null +++ b/debian/patches/21_check_snmp_load_update_fortiswitch_and_fortigate4.3 @@ -0,0 +1,90 @@ +From 946bd37f5632fead9382f05a3600f0328dae53a1 Mon Sep 17 00:00:00 2001 +From: Martin Botka <16738302+Haxk20@users.noreply.github.com> +Date: Mon, 1 Aug 2022 12:14:37 +0200 +Subject: [PATCH] check_snmp_load.pl: Add Fortiswitch & 4.3+ firmware fortigate + +This commit adds support for checking the fortiswitch CPU usage +and also fortigate 4.3 and above firmware. This OID got changed but to keep +backwards compatibility and not to break already running platforms depending on this +the new OID was added as new type. + +Signed-off-by: Martin Botka +--- + plugins/check_snmp_load.pl | 21 ++++++++++++++------- + 1 file changed, 14 insertions(+), 7 deletions(-) + +diff --git a/plugins/check_snmp_load.pl b/plugins/check_snmp_load.pl +index 0959f6a..ecafb59 100755 +--- a/plugins/check_snmp_load.pl ++++ b/plugins/check_snmp_load.pl +@@ -81,6 +81,12 @@ + # Fortigate CPU + my $fortigate_cpu = ".1.3.6.1.4.1.12356.1.8.0"; # Fortigate CPU % usage + ++# Fortigate CPU ++my $fortigate43_cpu = "1.3.6.1.4.1.12356.101.4.1.3.0"; # Fortigate 4.3 firmware CPU % usage ++ ++# Fortigate CPU ++my $fortiswitch_cpu = ".1.3.6.1.4.1.12356.106.4.1.2.0"; # Fortiswitch CPU % usage ++ + # Linkproof Appliance + my $linkproof_cpu = "1.3.6.1.4.1.89.35.1.55.0"; # CPU RE (Routing Engine Tasks) + +@@ -95,12 +101,12 @@ + + # valid values + my @valid_types +- = ("stand", "netsc", "netsl", "as400", "cisco", "cata", "cisg", "nsc", "fg", "bc", "nokia", "hp", "lp", "hpux", "n5k"); ++ = ("stand", "netsc", "netsl", "as400", "cisco", "cata", "cisg", "nsc", "fg", "fg43", "fs", "bc", "nokia", "hp", "lp", "hpux", "n5k"); + + # CPU OID array + my %cpu_oid = ( + "netsc", $ns_cpu_idle, "as400", $as400_cpu, "bc", $bluecoat_cpu, "nokia", $nokia_cpu, +- "hp", $procurve_cpu, "lp", $linkproof_cpu, "fg", $fortigate_cpu, "n5k", $n5k_cpu ++ "hp", $procurve_cpu, "lp", $linkproof_cpu, "fg", $fortigate_cpu, "fg43", $fortigate43_cpu, "fs", $fortiswitch_cpu, "n5k", $n5k_cpu + ); + + # Globals +@@ -113,7 +119,7 @@ + my $o_verb = undef; # verbose mode + my $o_version = undef; # print version + +-# check type : stand | netsc | netsl | as400 | cisco | cata | cisg | nsc | fg | bc | nokia | hp | lp | hpux ++# check type : stand | netsc | netsl | as400 | cisco | cata | cisg | nsc | fg | fg43| fs | bc | nokia | hp | lp | hpux + my $o_check_type = "stand"; + + # End compatibility +@@ -139,7 +145,7 @@ + + sub print_usage { + print +-"Usage: $0 [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] [-P ] -w -c -T=[stand|netsl|netsc|as400|cisco|cata|cisg|nsc|fg|bc|nokia|hp|lp|hpux] [-f] [-t ] [-V]\n"; ++"Usage: $0 [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] [-P ] -w -c -T=[stand|netsl|netsc|as400|cisco|cata|cisg|nsc|fg|fg43|fs|bc|nokia|hp|lp|hpux] [-f] [-t ] [-V]\n"; + } + + sub isnnum { # Return true if arg is not a number +@@ -201,6 +207,8 @@ sub help { + cisg : Cisco small business (SG500) CPU usage (1,5 & 15 minutes values) + nsc : NetScreen CPU usage + fg : Fortigate CPU usage ++ fg43 : Fortigate CPU usage for 4.3 firmware ++ fs : Fortiswitch CPU usage + bc : Bluecoat CPU usage + nokia : Nokia CPU usage + hp : HP procurve switch CPU usage +@@ -806,8 +814,8 @@ sub is_legacy_snmp_version { + exit $exit_val; + } + +-################## CPU for : AS/400 , Netsnmp, HP, Bluecoat, linkproof, fortigate ########### +-if ($o_check_type =~ /netsc|as400|bc|nokia|^hp$|lp|fg/) { ++################## CPU for : AS/400 , Netsnmp, HP, Bluecoat, linkproof, fortigate, fortigate43, fortiswitch ########### ++if ($o_check_type =~ /netsc|as400|bc|nokia|^hp$|lp|fg|fg43|fs/) { + + # Get load table + my @oidlist = $cpu_oid{$o_check_type}; +@@ -965,4 +973,3 @@ sub is_legacy_snmp_version { + ? print " | cpu_prct_used=$cpu_used%;$o_warn;$o_crit\n" + : print "\n"; + exit $exit_val; +- diff --git a/debian/patches/series b/debian/patches/series index 74089a9..fded68c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -9,5 +9,6 @@ 18_check_snmp_int_fix_perf_out 19_check_snmp_int_remove_unneeded_my 20_check_snmp_int_avaid_huge_amount_of_regex +21_check_snmp_load_update_fortiswitch_and_fortigate4.3 50_disable_epn 51_fix_privacy_doc