Add n5k support to check_snmp_load via 19_check_snmp_load_n5k patch

This commit is contained in:
Jan Wagner 2015-04-08 16:07:36 +02:00
parent 76f4f9b381
commit 9157b9d026
2 changed files with 98 additions and 0 deletions

97
debian/patches/19_check_snmp_load_n5k vendored Normal file
View file

@ -0,0 +1,97 @@
## 19_check_snmp_load_n5k by Luis I. Perez Villota
##
## DP: Add support for n5k to check_snmp_load.pl
## From de5ca289b5a696d17bdf0343f53b06ab7f7bbb9b Mon Sep 17 00:00:00 2001
## From: "Luis I. Perez Villota" <chewieip@gmail.com>
## Date: Wed, 8 Apr 2015 14:18:37 +0200
## Subject: [PATCH] Add Cisco Nexus Devices capability for load
Adding CPU Check for Cisco Nexus Devices
---
plugins/check_snmp_load.pl | 50 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/plugins/check_snmp_load.pl b/plugins/check_snmp_load.pl
index 6487bde..fd13f71 100755
--- a/plugins/check_snmp_load.pl
+++ b/plugins/check_snmp_load.pl
@@ -55,6 +55,9 @@
my $as400_cpu = "1.3.6.1.4.1.2.6.4.5.1.0"; # AS400 CPU load (10000=100%);
+# N5K CPU
+my $n5k_cpu = "1.3.6.1.4.1.9.9.305.1.1.1.0"; # N5K CPU load (%)
+
# Net-SNMP CPU
my $ns_cpu_idle = "1.3.6.1.4.1.2021.11.11.0"; # Net-snmp cpu idle
@@ -85,9 +88,9 @@
my $hpux_load_15_min="1.3.6.1.4.1.11.2.3.1.1.5.0";
# valid values
-my @valid_types = ("stand","netsc","netsl","as400","cisco","cata","nsc","fg","bc","nokia","hp","lp","hpux");
+my @valid_types = ("stand","netsc","netsl","as400","cisco","cata","nsc","fg","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);
+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);
# Globals
@@ -179,6 +182,7 @@ sub help {
netsc : cpu usage given by net-snmp (100-idle)
as400 : as400 CPU usage
cisco : Cisco CPU usage
+ n5k : Cisco Nexus CPU Usage
cata : Cisco catalyst CPU usage
nsc : NetScreen CPU usage
fg : Fortigate CPU usage
@@ -475,6 +479,48 @@ sub check_options {
exit $exit_val;
}
+############## Cisco N5K CPU Check ###################
+if ($o_check_type eq "n5k") {
+my @oidlists = ($n5k_cpu);
+my $resultat = (Net::SNMP->VERSION lt 4) ?
+ $session->get_request(@oidlists)
+ : $session->get_request(-varbindlist => \@oidlists);
+if (!defined($resultat)) {
+ printf("ERROR: Description table : %s.\n", $session->error);
+ $session->close;
+ exit $ERRORS{"UNKNOWN"};
+}
+
+$session->close;
+if (!defined ($$resultat{$n5k_cpu})) {
+ print "No CPU information : UNKNOWN\n";
+ exit $ERRORS{"UNKNOWN"};
+}
+
+my $n5k_load = $$resultat{$n5k_cpu};
+if ($n5k_load > $o_crit ) {
+ print "$n5k_load% > $o_crit% : CRITICAL";
+ $exit_val=$ERRORS{"CRITICAL"};
+}
+elsif ($n5k_load > $o_warn) {
+ print "$n5k_load% > $o_warn% : WARNING";
+ $exit_val=$ERRORS{"WARNING"};
+}
+else{
+ print "CPU: $n5k_load%";
+ $exit_val=$ERRORS{"OK"};
+}
+if (defined($o_perf)) {
+ print " | n5k_load=$n5k_load%";
+}
+print "\n";
+exit $exit_val;
+
+
+
+
+
+}
############## Cisco Catalyst CPU check ################
if ($o_check_type eq "cata") {

View file

@ -4,5 +4,6 @@
16_perfdata
17_protocol_fam
18_check_snmp_process_tmp_file
19_check_snmp_load_n5k
50_disable_epn
51_fix_privacy_doc