Adding 20_check_snmp_load_multiple_cpus

This commit is contained in:
Jan Wagner 2015-04-25 23:57:18 +02:00
parent 4a57e8bec7
commit e4c5a528cf
2 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,58 @@
## 19_check_snmp_load_n5k by Luis I. Perez Villota
##
## DP: Add support for n5k to check_snmp_load.pl
## From 1fcf4f4220edb886fb85931792542d962cf02ecb Mon Sep 17 00:00:00 2001
## From: Michael Friedrich <michael.friedrich@gmail.com>
## Date: Sat, 25 Apr 2015 15:20:32 +0200
## Subject: [PATCH] check_snmp_load.pl - Linux load multiple CPUs
## Linux load doesn't handle multiple CPUs properly. Here is a patch that makes
## the plugin to get the number of CPUs for a particular system and multiply
## warning and critical limits by this number.
fixes #6
---
plugins/check_snmp_load.pl | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/plugins/check_snmp_load.pl b/plugins/check_snmp_load.pl
index fd13f71..1f29ac5 100755
--- a/plugins/check_snmp_load.pl
+++ b/plugins/check_snmp_load.pl
@@ -363,6 +363,20 @@ sub check_options {
if ($o_check_type eq "netsl") {
verb("Checking linux load");
+
+# Get number of CPUs
+my $resultat = (Net::SNMP->VERSION < 4) ?
+ $session->get_table($proc_id)
+ : $session->get_table(Baseoid => $proc_id);
+
+if (!defined($resultat)) {
+ printf("ERROR: Description table : %s.\n", $session->error);
+ $session->close;
+ exit $ERRORS{"UNKNOWN"};
+}
+
+my $ncpu = keys %$resultat;
+
# Get load table
my $resultat = (Net::SNMP->VERSION lt 4) ?
$session->get_table($linload_table)
@@ -397,10 +411,13 @@ sub check_options {
for (my $i=0;$i<3;$i++) { $load[$i] = $$resultat{$linload_load . "." . $iload[$i]}};
-print "Load : $load[0] $load[1] $load[2] :";
+print "Load (CPUs: $ncpu) : $load[0] $load[1] $load[2] :";
$exit_val=$ERRORS{"OK"};
for (my $i=0;$i<3;$i++) {
+ # Multiply warning and critical levels by the number of CPUs
+ $o_warnL[$i] *= $ncpu;
+ $o_critL[$i] *= $ncpu;
if ( $load[$i] > $o_critL[$i] ) {
print " $load[$i] > $o_critL[$i] : CRITICAL";
$exit_val=$ERRORS{"CRITICAL"};

View file

@ -5,5 +5,6 @@
17_protocol_fam
18_check_snmp_process_tmp_file
19_check_snmp_load_n5k
20_check_snmp_load_multiple_cpus
50_disable_epn
51_fix_privacy_doc