From d26a60e9cde2fe99d2709854474d59eeb763ee82 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Feb 2017 15:57:37 +0100 Subject: [PATCH] + Fix #603 + change path name --- network/brocade/{ => snmp}/mode/cpu.pm | 12 ++++++++---- network/brocade/{ => snmp}/mode/hardware.pm | 2 +- network/brocade/{ => snmp}/mode/memory.pm | 12 ++++++++---- network/brocade/{ => snmp}/plugin.pm | 8 ++++---- 4 files changed, 21 insertions(+), 13 deletions(-) rename network/brocade/{ => snmp}/mode/cpu.pm (86%) rename network/brocade/{ => snmp}/mode/hardware.pm (98%) rename network/brocade/{ => snmp}/mode/memory.pm (86%) rename network/brocade/{ => snmp}/plugin.pm (93%) diff --git a/network/brocade/mode/cpu.pm b/network/brocade/snmp/mode/cpu.pm similarity index 86% rename from network/brocade/mode/cpu.pm rename to network/brocade/snmp/mode/cpu.pm index 12e66fa6a..b58e36880 100644 --- a/network/brocade/mode/cpu.pm +++ b/network/brocade/snmp/mode/cpu.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::brocade::mode::cpu; +package network::brocade::snmp::mode::cpu; use base qw(centreon::plugins::mode); @@ -62,13 +62,17 @@ sub run { my $oid_swCpuUsage = '.1.3.6.1.4.1.1588.2.1.1.1.26.1.0'; my $result = $self->{snmp}->get_leef(oids => [$oid_swFwFabricWatchLicense, $oid_swCpuUsage], nothing_quit => 1); - if ($result->{$oid_swFwFabricWatchLicense} == 2) { - $self->{output}->add_option_msg(short_msg => "Need Fabric Watch License to get information."); + if (!defined($result->{$oid_swCpuUsage})) { + if ($result->{$oid_swFwFabricWatchLicense} == 2) { + $self->{output}->add_option_msg(short_msg => "Need Fabric Watch License to get information."); + $self->{output}->option_exit(); + } + $self->{output}->add_option_msg(short_msg => "Cannot get information."); $self->{output}->option_exit(); } my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_swCpuUsage}, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("CPU Usage: %.2f%%", $result->{$oid_swCpuUsage})); $self->{output}->perfdata_add(label => "cpu", unit => '%', diff --git a/network/brocade/mode/hardware.pm b/network/brocade/snmp/mode/hardware.pm similarity index 98% rename from network/brocade/mode/hardware.pm rename to network/brocade/snmp/mode/hardware.pm index 5b30a71e2..755d2e8e6 100644 --- a/network/brocade/mode/hardware.pm +++ b/network/brocade/snmp/mode/hardware.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::brocade::mode::hardware; +package network::brocade::snmp::mode::hardware; use base qw(centreon::plugins::mode); diff --git a/network/brocade/mode/memory.pm b/network/brocade/snmp/mode/memory.pm similarity index 86% rename from network/brocade/mode/memory.pm rename to network/brocade/snmp/mode/memory.pm index 9ae0a41ed..6ebf64077 100644 --- a/network/brocade/mode/memory.pm +++ b/network/brocade/snmp/mode/memory.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::brocade::mode::memory; +package network::brocade::snmp::mode::memory; use base qw(centreon::plugins::mode); @@ -62,13 +62,17 @@ sub run { my $oid_swMemUsage = '.1.3.6.1.4.1.1588.2.1.1.1.26.6.0'; my $result = $self->{snmp}->get_leef(oids => [$oid_swFwFabricWatchLicense, $oid_swMemUsage], nothing_quit => 1); - if ($result->{$oid_swFwFabricWatchLicense} == 2) { - $self->{output}->add_option_msg(short_msg => "Need Fabric Watch License to get information."); + if (!defined($result->{$oid_swMemUsage})) { + if ($result->{$oid_swFwFabricWatchLicense} == 2) { + $self->{output}->add_option_msg(short_msg => "Need Fabric Watch License to get information."); + $self->{output}->option_exit(); + } + $self->{output}->add_option_msg(short_msg => "Cannot get information."); $self->{output}->option_exit(); } my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_swMemUsage}, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Memory Usage: %.2f%% used", $result->{$oid_swMemUsage})); $self->{output}->perfdata_add(label => "used", unit => '%', diff --git a/network/brocade/plugin.pm b/network/brocade/snmp/plugin.pm similarity index 93% rename from network/brocade/plugin.pm rename to network/brocade/snmp/plugin.pm index bbf7ea36c..d445cd74f 100644 --- a/network/brocade/plugin.pm +++ b/network/brocade/snmp/plugin.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::brocade::plugin; +package network::brocade::snmp::plugin; use strict; use warnings; @@ -31,11 +31,11 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'cpu' => 'network::brocade::mode::cpu', - 'hardware' => 'network::brocade::mode::hardware', + 'cpu' => 'network::brocade::snmp::mode::cpu', + 'hardware' => 'network::brocade::snmp::mode::hardware', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'memory' => 'network::brocade::mode::memory', + 'memory' => 'network::brocade::snmp::mode::memory', ); return $self;