From f82fdd71a3f82bd41aac76ec4c0f3a22d8e0dc67 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Mon, 4 Aug 2014 09:48:45 +0200 Subject: [PATCH] Refs #5716 --- network/f5/mode/components/fan.pm | 19 +----------- network/f5/mode/components/psu.pm | 8 ++--- network/f5/mode/components/temperature.pm | 19 +++++------- network/f5/mode/connections.pm | 1 - network/f5/mode/hardware.pm | 36 +++++++++++------------ network/f5/plugin.pm | 5 ++-- 6 files changed, 33 insertions(+), 55 deletions(-) diff --git a/network/f5/mode/components/fan.pm b/network/f5/mode/components/fan.pm index 39b2cd1ef..f908aeaf0 100644 --- a/network/f5/mode/components/fan.pm +++ b/network/f5/mode/components/fan.pm @@ -38,22 +38,6 @@ package network::f5::mode::components::fan; use strict; use warnings; -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning', default => '' }, - "critical:s" => { name => 'critical', default => '' }, - }); - - return $self; -} - - my %map_status = ( 0 => 'bad', 1 => 'good', @@ -94,8 +78,7 @@ sub check { $self->{output}->perfdata_add(label => "fan_" . $instance, value => $speed, - ); - + ); } } diff --git a/network/f5/mode/components/psu.pm b/network/f5/mode/components/psu.pm index 2e99105bd..4293fdc9c 100644 --- a/network/f5/mode/components/psu.pm +++ b/network/f5/mode/components/psu.pm @@ -47,9 +47,9 @@ my %map_status = ( sub check { my ($self) = @_; - $self->{components}->{psus} = {name => 'psus', total => 0}; + $self->{components}->{psu} = {name => 'psus', total => 0}; $self->{output}->output_add(long_msg => "Checking power supplies"); - return if ($self->check_exclude(section => 'psus')); + return if ($self->check_exclude(section => 'psu')); my $oid_sysChassisPowerSupplyEntry = '.1.3.6.1.4.1.3375.2.1.3.2.2.2.1'; my $oid_sysChassisPowerSupplyStatus = '.1.3.6.1.4.1.3375.2.1.3.2.2.2.1.2'; @@ -60,11 +60,11 @@ sub check { foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { next if ($key !~ /^$oid_sysChassisPowerSupplyStatus\.(\d+)$/); my $instance = $1; - next if ($self->check_exclude(section => 'psus', instance => $instance)); + next if ($self->check_exclude(section => 'psu', instance => $instance)); my $status = $result->{$oid_sysChassisPowerSupplyStatus . '.' . $instance}; - $self->{components}->{psus}->{total}++; + $self->{components}->{psu}->{total}++; $self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is %s.", $instance, $map_status{$status})); if ($status < 1) { diff --git a/network/f5/mode/components/temperature.pm b/network/f5/mode/components/temperature.pm index d16a22010..d1d2b585a 100644 --- a/network/f5/mode/components/temperature.pm +++ b/network/f5/mode/components/temperature.pm @@ -54,25 +54,22 @@ sub check { foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { next if ($key !~ /^$oid_sysChassisTempTemperature\.(\d+)$/); my $instance = $1; - next if ($self->check_exclude(section => 'temperatures', instance => $instance)); - my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_sysChassisTempTemperature . '.' . $instance}, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_sysChassisTempTemperature . '.' . $instance}, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{components}->{temperatures}->{total}++; - $self->{output}->output_add(severity => $exit_code,long_msg => sprintf("temp_" . $instance . " is %.2f C", $result->{$oid_sysChassisTempTemperature . '.' . $instance})); - - if ($exit_code ne 'ok') { + if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit_code,short_msg => sprintf("temp_" . $instance . " is %.2f C", $result->{$oid_sysChassisTempTemperature . '.' . $instance})); } - $self->{output}->perfdata_add(label => "temp_" . $instance , unit => 'C', value => sprintf("%.2f", $result->{$oid_sysChassisTempTemperature . '.' . $instance}), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); - } + $self->{output}->perfdata_add(label => "temp_" . $instance , unit => 'C', + value => sprintf("%.2f", $result->{$oid_sysChassisTempTemperature . '.' . $instance}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); } - +} 1; diff --git a/network/f5/mode/connections.pm b/network/f5/mode/connections.pm index 97a29669a..299df8c56 100644 --- a/network/f5/mode/connections.pm +++ b/network/f5/mode/connections.pm @@ -90,7 +90,6 @@ sub run { $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); $self->{output}->option_exit(); } - my $oid_sysStatClientCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.8.0'; my $oid_sysStatServerCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.15.0'; diff --git a/network/f5/mode/hardware.pm b/network/f5/mode/hardware.pm index 627ebd7e9..99f2582c1 100644 --- a/network/f5/mode/hardware.pm +++ b/network/f5/mode/hardware.pm @@ -83,23 +83,6 @@ sub global { network::f5::mode::components::psu::check($self); } -sub check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - - sub run { my ($self, %options) = @_; # $options{snmp} = snmp object @@ -141,6 +124,21 @@ sub run { $self->{output}->exit(); } +sub check_exclude { + my ($self, %options) = @_; + + if (defined($options{instance})) { + if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { + $self->{components}->{$options{section}}->{skip}++; + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } + return 0; +} 1; @@ -159,8 +157,8 @@ Can be: 'fan', 'psu', 'temperature'. =item B<--exclude> -Exclude some parts (comma seperated list) (Example: --exclude=fans,psus) -Can also exclude specific instance: --exclude=fans#1#2#,modules#1#,psus +Exclude some parts (comma seperated list) (Example: --exclude=fans,psu) +Can also exclude specific instance: --exclude=fan#1#2#,psu =item B<--warning> diff --git a/network/f5/plugin.pm b/network/f5/plugin.pm index 491ff4f19..cc9500578 100644 --- a/network/f5/plugin.pm +++ b/network/f5/plugin.pm @@ -47,7 +47,7 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'hardware' => 'network::f5::mode::hardware', + 'hardware' => 'network::f5::mode::hardware', 'connections' => 'network::f5::mode::connections', ); @@ -60,6 +60,7 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Brocade hardware in SNMP. +Check F-5 hardware in SNMP. +Please use plugin SNMP Linux for system checks ('cpu', 'memory', 'traffic',...). =cut