From 18318462c4709439abba75361484e8a1045ab694 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 8 Jan 2016 16:39:50 +0100 Subject: [PATCH] + update: refactoring with hardware template class --- .../common/aruba/snmp/mode/components/fan.pm | 8 +- .../aruba/snmp/mode/components/module.pm | 8 +- .../common/aruba/snmp/mode/components/psu.pm | 8 +- centreon/common/aruba/snmp/mode/hardware.pm | 191 ++------- .../smallbusiness/snmp/mode/components/fan.pm | 8 +- .../smallbusiness/snmp/mode/components/psu.pm | 8 +- .../smallbusiness/snmp/mode/environment.pm | 214 +++-------- .../force10/snmp/mode/components/fan.pm | 4 +- .../force10/snmp/mode/components/psu.pm | 4 +- .../snmp/mode/components/temperature.pm | 4 +- centreon/common/force10/snmp/mode/hardware.pm | 291 ++------------ .../common/violin/snmp/mode/components/ca.pm | 8 +- .../common/violin/snmp/mode/components/fan.pm | 8 +- .../common/violin/snmp/mode/components/gfc.pm | 8 +- .../common/violin/snmp/mode/components/lfc.pm | 8 +- .../common/violin/snmp/mode/components/psu.pm | 9 +- .../snmp/mode/components/temperature.pm | 11 +- .../violin/snmp/mode/components/vimm.pm | 9 +- centreon/common/violin/snmp/mode/hardware.pm | 316 ++++----------- .../server/cisco/ucs/mode/components/blade.pm | 8 +- .../cisco/ucs/mode/components/chassis.pm | 8 +- .../server/cisco/ucs/mode/components/cpu.pm | 8 +- .../server/cisco/ucs/mode/components/fan.pm | 8 +- .../server/cisco/ucs/mode/components/fex.pm | 8 +- .../cisco/ucs/mode/components/iocard.pm | 8 +- .../cisco/ucs/mode/components/localdisk.pm | 8 +- .../cisco/ucs/mode/components/memory.pm | 8 +- .../server/cisco/ucs/mode/components/psu.pm | 8 +- hardware/server/cisco/ucs/mode/equipment.pm | 203 ++-------- .../snmp/mode/components/ambient.pm | 8 +- .../bladecenter/snmp/mode/components/blade.pm | 8 +- .../snmp/mode/components/blower.pm | 10 +- .../snmp/mode/components/chassisfan.pm | 8 +- .../snmp/mode/components/chassisstatus.pm | 8 +- .../snmp/mode/components/fanpack.pm | 8 +- .../snmp/mode/components/powermodule.pm | 8 +- .../snmp/mode/components/switchmodule.pm | 8 +- .../snmp/mode/components/systemhealth.pm | 9 +- .../ibm/bladecenter/snmp/mode/hardware.pm | 361 +++++------------- 39 files changed, 444 insertions(+), 1392 deletions(-) diff --git a/centreon/common/aruba/snmp/mode/components/fan.pm b/centreon/common/aruba/snmp/mode/components/fan.pm index 14942b192..8a573f3f6 100644 --- a/centreon/common/aruba/snmp/mode/components/fan.pm +++ b/centreon/common/aruba/snmp/mode/components/fan.pm @@ -35,9 +35,9 @@ my $mapping = { my $oid_wlsxSysExtFanEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.17.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_wlsxSysExtFanEntry }; + push @{$self->{request}}, { oid => $oid_wlsxSysExtFanEntry }; } sub check { @@ -45,14 +45,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_wlsxSysExtFanEntry}})) { next if ($oid !~ /^$mapping->{sysExtFanStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxSysExtFanEntry}, instance => $instance); - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); $self->{components}->{fan}->{total}++; $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s [instance: %s].", diff --git a/centreon/common/aruba/snmp/mode/components/module.pm b/centreon/common/aruba/snmp/mode/components/module.pm index eebf2fd5d..8f3174630 100644 --- a/centreon/common/aruba/snmp/mode/components/module.pm +++ b/centreon/common/aruba/snmp/mode/components/module.pm @@ -55,9 +55,9 @@ my $mapping = { my $oid_wlsxSysExtCardEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.16.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_wlsxSysExtCardEntry }; + push @{$self->{request}}, { oid => $oid_wlsxSysExtCardEntry }; } sub check { @@ -65,14 +65,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking modules"); $self->{components}->{module} = {name => 'modules', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'module')); + return if ($self->check_filter(section => 'module')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_wlsxSysExtCardEntry}})) { next if ($oid !~ /^$mapping->{sysExtCardStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxSysExtCardEntry}, instance => $instance); - next if ($self->check_exclude(section => 'module', instance => $instance)); + next if ($self->check_filter(section => 'module', instance => $instance)); $self->{components}->{module}->{total}++; $self->{output}->output_add(long_msg => sprintf("Module '%s/%s' status is %s [instance: %s].", diff --git a/centreon/common/aruba/snmp/mode/components/psu.pm b/centreon/common/aruba/snmp/mode/components/psu.pm index 754df13ed..bd031a919 100644 --- a/centreon/common/aruba/snmp/mode/components/psu.pm +++ b/centreon/common/aruba/snmp/mode/components/psu.pm @@ -35,9 +35,9 @@ my $mapping = { my $oid_wlsxSysExtPowerSupplyEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.18.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_wlsxSysExtPowerSupplyEntry }; + push @{$self->{request}}, { oid => $oid_wlsxSysExtPowerSupplyEntry }; } sub check { @@ -45,14 +45,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_wlsxSysExtPowerSupplyEntry}})) { next if ($oid !~ /^$mapping->{sysExtPowerSupplyStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxSysExtPowerSupplyEntry}, instance => $instance); - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); $self->{components}->{psu}->{total}++; $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s].", diff --git a/centreon/common/aruba/snmp/mode/hardware.pm b/centreon/common/aruba/snmp/mode/hardware.pm index 3dfc4cb48..2bfeff3d3 100644 --- a/centreon/common/aruba/snmp/mode/hardware.pm +++ b/centreon/common/aruba/snmp/mode/hardware.pm @@ -20,168 +20,57 @@ package centreon::common::aruba::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fan => [ - ['active', 'OK'], - ['inactive', 'CRITICAL'], - ], - psu => [ - ['active', 'OK'], - ['inactive', 'CRITICAL'], - ], - module => [ - ['active', 'OK'], - ['inactive', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|module)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['active', 'OK'], + ['inactive', 'CRITICAL'], + ], + psu => [ + ['active', 'OK'], + ['inactive', 'CRITICAL'], + ], + module => [ + ['active', 'OK'], + ['inactive', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'centreon::common::aruba::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'module']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, + { }); - $self->{components} = {}; - $self->{no_components} = undef; + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } - } - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu', 'module'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::aruba::snmp::mode::components::$_"; - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, - error_msg => "Cannot load module '$mod_name'."); - my $func = $mod_name->can('load'); - $func->(request => $snmp_request); - } - } - - if (scalar(@{$snmp_request}) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::aruba::snmp::mode::components::$_"; - my $func = $mod_name->can('check'); - $func->($self); - } - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components are ok [%s].", - $total_components, - $display_by_component) - ); - - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked.'); - } - - $self->{output}->display(); - $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; -} - -sub get_severity { - my ($self, %options) = @_; - my $status = 'UNKNOWN'; # default - - if (defined($self->{overload_th}->{$options{section}})) { - foreach (@{$self->{overload_th}->{$options{section}}}) { - if ($options{value} =~ /$_->{filter}/i) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - 1; __END__ @@ -197,10 +86,10 @@ Check hardware (modules, fans, power supplies). Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'module'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan,module) -Can also exclude specific instance: --exclude=fan#1#2#,module#1#,psu +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,1 =item B<--no-component> @@ -209,7 +98,7 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='fan,OK,inactive' diff --git a/centreon/common/cisco/smallbusiness/snmp/mode/components/fan.pm b/centreon/common/cisco/smallbusiness/snmp/mode/components/fan.pm index 97ab832e8..5d2166c4e 100644 --- a/centreon/common/cisco/smallbusiness/snmp/mode/components/fan.pm +++ b/centreon/common/cisco/smallbusiness/snmp/mode/components/fan.pm @@ -39,9 +39,9 @@ my $mapping = { my $oid_rlEnvMonFanStatusEntry = '.1.3.6.1.4.1.9.6.1.101.83.1.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rlEnvMonFanStatusEntry }; + push @{$self->{request}}, { oid => $oid_rlEnvMonFanStatusEntry }; } sub check { @@ -49,14 +49,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fan', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonFanStatusEntry}})) { next if ($oid !~ /^$mapping->{rlEnvMonFanState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonFanStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); if ($result->{rlEnvMonFanState} =~ /notPresent/i) { $self->absent_problem(section => 'fan', instance => $instance); next; diff --git a/centreon/common/cisco/smallbusiness/snmp/mode/components/psu.pm b/centreon/common/cisco/smallbusiness/snmp/mode/components/psu.pm index 0e8a59860..e24a05483 100644 --- a/centreon/common/cisco/smallbusiness/snmp/mode/components/psu.pm +++ b/centreon/common/cisco/smallbusiness/snmp/mode/components/psu.pm @@ -39,9 +39,9 @@ my $mapping = { my $oid_rlEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.9.6.1.101.83.1.2.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rlEnvMonSupplyStatusEntry }; + push @{$self->{request}}, { oid => $oid_rlEnvMonSupplyStatusEntry }; } sub check { @@ -49,14 +49,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psu', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonSupplyStatusEntry}})) { next if ($oid !~ /^$mapping->{rlEnvMonSupplyState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonSupplyStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); if ($result->{rlEnvMonSupplyState} =~ /notPresent/i) { $self->absent_problem(section => 'psu', instance => $instance); next; diff --git a/centreon/common/cisco/smallbusiness/snmp/mode/environment.pm b/centreon/common/cisco/smallbusiness/snmp/mode/environment.pm index b42b27843..e53c92eb7 100644 --- a/centreon/common/cisco/smallbusiness/snmp/mode/environment.pm +++ b/centreon/common/cisco/smallbusiness/snmp/mode/environment.pm @@ -20,189 +20,61 @@ package centreon::common::cisco::smallbusiness::snmp::mode::environment; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fan => [ - ['normal', 'OK'], - ['notPresent', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['notFunctioning', 'CRITICAL'], - ], - psu => [ - ['normal', 'OK'], - ['notPresent', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['notFunctioning', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['normal', 'OK'], + ['notPresent', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['notFunctioning', 'CRITICAL'], + ], + psu => [ + ['normal', 'OK'], + ['notPresent', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['notFunctioning', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'centreon::common::cisco::smallbusiness::snmp::mode::components'; + $self->{components_module} = ['psu', 'fan']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "absent-problem:s" => { name => 'absent' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, + { }); - $self->{components} = {}; - $self->{no_components} = undef; return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } - } - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('psu', 'fan'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::cisco::smallbusiness::snmp::mode::components::$_"; - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, - error_msg => "Cannot load module '$mod_name'."); - my $func = $mod_name->can('load'); - $func->(request => $snmp_request); - } - } - - if (scalar(@{$snmp_request}) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::cisco::smallbusiness::snmp::mode::components::$_"; - my $func = $mod_name->can('check'); - $func->($self); - } - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components are ok [%s]", - $total_components, - $display_by_component) - ); - - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked'); - } - - $self->{output}->display(); - $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; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Component '%s' instance '%s' is not present", - $options{section}, $options{instance})); - } - - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)")); - $self->{components}->{$options{section}}->{skip}++; - return 1; -} - -sub get_severity { - my ($self, %options) = @_; - my $status = 'UNKNOWN'; # default - - if (defined($self->{overload_th}->{$options{section}})) { - foreach (@{$self->{overload_th}->{$options{section}}}) { - if ($options{value} =~ /$_->{filter}/i) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - 1; __END__ @@ -218,10 +90,10 @@ Check environment (Fans, Power supplies). Which component to check (Default: '.*'). Can be: 'fan', 'psu'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='psu#0#' +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=psu,0 =item B<--absent-problem> @@ -235,7 +107,7 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)' diff --git a/centreon/common/force10/snmp/mode/components/fan.pm b/centreon/common/force10/snmp/mode/components/fan.pm index 0f0cc9c0f..f3717d8d1 100644 --- a/centreon/common/force10/snmp/mode/components/fan.pm +++ b/centreon/common/force10/snmp/mode/components/fan.pm @@ -42,9 +42,9 @@ my $mapping = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} }, + push @{$self->{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} }, { oid => $mapping->{mseries}->{OperStatus}->{oid} }, { oid => $mapping->{zseries}->{OperStatus}->{oid} }; } diff --git a/centreon/common/force10/snmp/mode/components/psu.pm b/centreon/common/force10/snmp/mode/components/psu.pm index 853f25d6f..4d754f55e 100644 --- a/centreon/common/force10/snmp/mode/components/psu.pm +++ b/centreon/common/force10/snmp/mode/components/psu.pm @@ -50,9 +50,9 @@ my $mapping = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} }, + push @{$self->{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} }, { oid => $mapping->{mseries}->{OperStatus}->{oid} }, { oid => $mapping->{zseries}->{OperStatus}->{oid} }; } diff --git a/centreon/common/force10/snmp/mode/components/temperature.pm b/centreon/common/force10/snmp/mode/components/temperature.pm index 7e38f45bd..9dfa727f6 100644 --- a/centreon/common/force10/snmp/mode/components/temperature.pm +++ b/centreon/common/force10/snmp/mode/components/temperature.pm @@ -34,9 +34,9 @@ my $mapping = { my $oid_deviceSensorValueEntry = '.1.3.6.1.4.1.3417.2.1.1.1.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{sseries}->{Temp}->{oid} }, + push @{$self->{request}}, { oid => $mapping->{sseries}->{Temp}->{oid} }, { oid => $mapping->{mseries}->{Temp}->{oid} }; } diff --git a/centreon/common/force10/snmp/mode/hardware.pm b/centreon/common/force10/snmp/mode/hardware.pm index 65b78494c..3f93c85b0 100644 --- a/centreon/common/force10/snmp/mode/hardware.pm +++ b/centreon/common/force10/snmp/mode/hardware.pm @@ -20,31 +20,49 @@ package centreon::common::force10::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; -my $thresholds = { - fan => [ - ['up', 'OK'], - ['absent', 'OK'], - ['down', 'CRITICAL'], - ], - psu => [ - ['up', 'OK'], - ['absent', 'OK'], - ['down', 'CRITICAL'], - - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['notPresent', 'OK'], - ['notFunctioning', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(psu|fan)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['up', 'OK'], + ['absent', 'OK'], + ['down', 'CRITICAL'], + ], + psu => [ + ['up', 'OK'], + ['absent', 'OK'], + ['down', 'CRITICAL'], + + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['notPresent', 'OK'], + ['notFunctioning', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'centreon::common::force10::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -53,241 +71,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "filter:s@" => { name => 'filter' }, - "absent-problem:s@" => { name => 'absent_problem' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - - $self->{components} = {}; - $self->{no_components} = undef; return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } - } - - $self->{filter} = []; - foreach my $val (@{$self->{option_results}->{filter}}) { - next if (!defined($val) || $val eq ''); - my @values = split (/,/, $val); - push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; - } - - $self->{absent_problem} = []; - foreach my $val (@{$self->{option_results}->{absent_problem}}) { - next if (!defined($val) || $val eq ''); - my @values = split (/,/, $val); - push @{$self->{absent_problem}}, { filter => $values[0], instance => $values[1] }; - } - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - next if (!defined($val) || $val eq ''); - my @values = split (/,/, $val); - if (scalar(@values) < 3) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $status, $filter); - if (scalar(@values) == 3) { - ($section, $status, $filter) = @values; - $instance = '.*'; - } else { - ($section, $instance, $status, $filter) = @values; - } - if ($section !~ /^psu|fan$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'."); - $self->{output}->option_exit(); - } - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance }; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - next if (!defined($val) || $val eq ''); - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $value) = ($1, $2, $3); - if ($section !~ /^temperature$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance }; - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu', 'temperature'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::force10::snmp::mode::components::$_"; - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, - error_msg => "Cannot load module '$mod_name'."); - my $func = $mod_name->can('load'); - $func->(request => $snmp_request); - } - } - - if (scalar(@{$snmp_request}) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::force10::snmp::mode::components::$_"; - my $func = $mod_name->can('check'); - $func->($self); - } - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components are ok [%s].", - $total_components, - $display_by_component) - ); - - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked.'); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -sub absent_problem { - my ($self, %options) = @_; - - foreach (@{$self->{absent_problem}}) { - if ($options{section} =~ /$_->{filter}/) { - if (!defined($_->{instance}) || $options{instance} =~ /$_->{instance}/) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Component '%s' instance '%s' is not present", - $options{section}, $options{instance})); - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)")); - $self->{components}->{$options{section}}->{skip}++; - return 1; - } - } - } - - return 0; -} - -sub check_filter { - my ($self, %options) = @_; - - foreach (@{$self->{filter}}) { - if ($options{section} =~ /$_->{filter}/) { - if (!defined($options{instance}) && !defined($_->{instance})) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } - } - - return 0; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{instance}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -sub get_severity { - my ($self, %options) = @_; - my $status = 'UNKNOWN'; # default - - if (defined($self->{overload_th}->{$options{section}})) { - foreach (@{$self->{overload_th}->{$options{section}}}) { - if ($options{value} =~ /$_->{filter}/i && - (!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) { - $status = $_->{status}; - return $status; - } - } - } - my $label = defined($options{label}) ? $options{label} : $options{section}; - foreach (@{$thresholds->{$label}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - 1; __END__ diff --git a/centreon/common/violin/snmp/mode/components/ca.pm b/centreon/common/violin/snmp/mode/components/ca.pm index 46d4533e9..cb91c747a 100644 --- a/centreon/common/violin/snmp/mode/components/ca.pm +++ b/centreon/common/violin/snmp/mode/components/ca.pm @@ -28,9 +28,9 @@ use warnings; my $oid_chassisSystemLedAlarm = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.7'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_chassisSystemLedAlarm }; + push @{$self->{request}}, { oid => $oid_chassisSystemLedAlarm }; } sub check { @@ -38,7 +38,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking chassis alarm"); $self->{components}->{ca} = {name => 'chassis alarm', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'ca')); + return if ($self->check_filter(section => 'ca')); foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemLedAlarm}}) { $oid =~ /^$oid_chassisSystemLedAlarm\.(.*)$/; @@ -46,7 +46,7 @@ sub check { my $instance = $array_name; my $ca_state = $self->{results}->{$oid_chassisSystemLedAlarm}->{$oid}; - next if ($self->check_exclude(section => 'ca', instance => $instance)); + next if ($self->check_filter(section => 'ca', instance => $instance)); $self->{components}->{ca}->{total}++; $self->{output}->output_add(long_msg => sprintf("Chassis alarm '%s' is %s.", diff --git a/centreon/common/violin/snmp/mode/components/fan.pm b/centreon/common/violin/snmp/mode/components/fan.pm index a6f5d40cf..e08d5c627 100644 --- a/centreon/common/violin/snmp/mode/components/fan.pm +++ b/centreon/common/violin/snmp/mode/components/fan.pm @@ -28,9 +28,9 @@ use warnings; my $oid_arrayFanEntry_speed = '.1.3.6.1.4.1.35897.1.2.2.3.18.1.3'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_arrayFanEntry_speed }; + push @{$self->{request}}, { oid => $oid_arrayFanEntry_speed }; } sub check { @@ -38,7 +38,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid (keys %{$self->{results}->{$oid_arrayFanEntry_speed}}) { $oid =~ /^$oid_arrayFanEntry_speed\.(.*)$/; @@ -46,7 +46,7 @@ sub check { my $instance = $array_name . '-' . $fan_name; my $fan_state = $self->{results}->{$oid_arrayFanEntry_speed}->{$oid}; - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); next if ($fan_state =~ /Absent/i && $self->absent_problem(section => 'fan', instance => $instance)); diff --git a/centreon/common/violin/snmp/mode/components/gfc.pm b/centreon/common/violin/snmp/mode/components/gfc.pm index e1ee67a82..1293a7f56 100644 --- a/centreon/common/violin/snmp/mode/components/gfc.pm +++ b/centreon/common/violin/snmp/mode/components/gfc.pm @@ -31,9 +31,9 @@ my $oid_enable = '.1.3.6.1.4.1.35897.1.2.1.10.1.4'; my $oid_portState = '.1.3.6.1.4.1.35897.1.2.1.10.1.8'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_globalTargetFcEntry }; + push @{$self->{request}}, { oid => $oid_globalTargetFcEntry }; } sub check { @@ -41,7 +41,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking global fc"); $self->{components}->{gfc} = {name => 'global fc', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'gfc')); + return if ($self->check_filter(section => 'gfc')); foreach my $oid (keys %{$self->{results}->{$oid_globalTargetFcEntry}}) { next if ($oid !~ /^$oid_wwn\.(.*)$/); @@ -53,7 +53,7 @@ sub check { $self->{output}->output_add(long_msg => sprintf("Skipping instance '$wwn' (not enable)")); next; } - next if ($self->check_exclude(section => 'gfc', instance => $wwn)); + next if ($self->check_filter(section => 'gfc', instance => $wwn)); $self->{components}->{gfc}->{total}++; $self->{output}->output_add(long_msg => sprintf("Global FC '%s' is %s.", diff --git a/centreon/common/violin/snmp/mode/components/lfc.pm b/centreon/common/violin/snmp/mode/components/lfc.pm index d3c56bbb1..8bf9c5ec6 100644 --- a/centreon/common/violin/snmp/mode/components/lfc.pm +++ b/centreon/common/violin/snmp/mode/components/lfc.pm @@ -31,9 +31,9 @@ my $oid_enable = '.1.3.6.1.4.1.35897.1.2.1.6.1.3'; my $oid_portState = '.1.3.6.1.4.1.35897.1.2.1.6.1.7'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_localTargetFcEntry }; + push @{$self->{request}}, { oid => $oid_localTargetFcEntry }; } sub check { @@ -41,7 +41,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking local fc"); $self->{components}->{lfc} = {name => 'local fc', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'lfc')); + return if ($self->check_filter(section => 'lfc')); foreach my $oid (keys %{$self->{results}->{$oid_localTargetFcEntry}}) { next if ($oid !~ /^$oid_wwn\.(.*)$/); @@ -53,7 +53,7 @@ sub check { $self->{output}->output_add(long_msg => sprintf("Skipping instance '$wwn' (not enable)")); next; } - next if ($self->check_exclude(section => 'lfc', instance => $wwn)); + next if ($self->check_filter(section => 'lfc', instance => $wwn)); $self->{components}->{lfc}->{total}++; $self->{output}->output_add(long_msg => sprintf("Local FC '%s' is %s.", diff --git a/centreon/common/violin/snmp/mode/components/psu.pm b/centreon/common/violin/snmp/mode/components/psu.pm index 23dd5510e..082ad10f2 100644 --- a/centreon/common/violin/snmp/mode/components/psu.pm +++ b/centreon/common/violin/snmp/mode/components/psu.pm @@ -29,10 +29,9 @@ my $oid_chassisSystemPowerPSUA = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.17'; my $oid_chassisSystemPowerPSUB = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.18'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_chassisSystemPowerPSUA }; - push @{$options{request}}, { oid => $oid_chassisSystemPowerPSUB }; + push @{$self->{request}}, { oid => $oid_chassisSystemPowerPSUA }, { oid => $oid_chassisSystemPowerPSUB }; } sub psu { @@ -45,7 +44,7 @@ sub psu { my $psu_state = $options{value}; - return if ($self->check_exclude(section => 'psu', instance => $instance)); + return if ($self->check_filter(section => 'psu', instance => $instance)); return if ($psu_state =~ /Absent/i && $self->absent_problem(section => 'psu', instance => $instance)); @@ -64,7 +63,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemPowerPSUA}}) { psu($self, oid => $oid, oid_short => $oid_chassisSystemPowerPSUA, value => $self->{results}->{$oid_chassisSystemPowerPSUA}->{$oid}, diff --git a/centreon/common/violin/snmp/mode/components/temperature.pm b/centreon/common/violin/snmp/mode/components/temperature.pm index c724a7251..daf330b81 100644 --- a/centreon/common/violin/snmp/mode/components/temperature.pm +++ b/centreon/common/violin/snmp/mode/components/temperature.pm @@ -30,11 +30,10 @@ my $oid_chassisSystemTempController = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.21'; my $oid_arrayVimmEntry_temp = '.1.3.6.1.4.1.35897.1.2.2.3.16.1.12'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_arrayVimmEntry_temp }; - push @{$options{request}}, { oid => $oid_chassisSystemTempAmbient }; - push @{$options{request}}, { oid => $oid_chassisSystemTempController }; + push @{$self->{request}}, { oid => $oid_arrayVimmEntry_temp }, { oid => $oid_chassisSystemTempAmbient }, + { oid => $oid_chassisSystemTempController }; } sub temperature { @@ -47,7 +46,7 @@ sub temperature { my $temperature = $options{value}; - return if ($self->check_exclude(section => 'temperature', instance => $instance)); + return if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %s degree centigrade.", @@ -68,7 +67,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemTempAmbient}}) { temperature($self, oid => $oid, oid_short => $oid_chassisSystemTempAmbient, value => $self->{results}->{$oid_chassisSystemTempAmbient}->{$oid}, diff --git a/centreon/common/violin/snmp/mode/components/vimm.pm b/centreon/common/violin/snmp/mode/components/vimm.pm index 8f0189ea9..63c36042e 100644 --- a/centreon/common/violin/snmp/mode/components/vimm.pm +++ b/centreon/common/violin/snmp/mode/components/vimm.pm @@ -39,10 +39,9 @@ my %map_vimm_present = ( ); sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_arrayVimmEntry_present }; - push @{$options{request}}, { oid => $oid_arrayVimmEntry_failed }; + push @{$self->{request}}, { oid => $oid_arrayVimmEntry_present }, { oid => $oid_arrayVimmEntry_failed }; } sub check { @@ -50,7 +49,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking vimms"); $self->{components}->{vimm} = {name => 'vimms', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'vimm')); + return if ($self->check_filter(section => 'vimm')); foreach my $oid (keys %{$self->{results}->{$oid_arrayVimmEntry_present}}) { next if ($oid !~ /^$oid_arrayVimmEntry_present\.(.*)$/); @@ -59,7 +58,7 @@ sub check { my ($dummy, $array_name, $vimm_name) = $self->convert_index(value => $1); my $instance = $array_name . '-' . $vimm_name; - next if ($self->check_exclude(section => 'vimm', instance => $instance)); + next if ($self->check_filter(section => 'vimm', instance => $instance)); next if ($map_vimm_present{$present} =~ /Absent/i && $self->absent_problem(section => 'vimm', instance => $instance)); diff --git a/centreon/common/violin/snmp/mode/hardware.pm b/centreon/common/violin/snmp/mode/hardware.pm index f264e3e5b..1200df760 100644 --- a/centreon/common/violin/snmp/mode/hardware.pm +++ b/centreon/common/violin/snmp/mode/hardware.pm @@ -20,55 +20,77 @@ package centreon::common::violin::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; my $thresholds = { - vimm => [ - ['not failed', 'OK'], - ['failed', 'CRITICAL'], - ], - ca => [ - ['ON', 'CRITICAL'], - ['OFF', 'OK'], - ], - psu => [ - ['OFF', 'CRITICAL'], - ['Absent', 'OK'], - ['ON', 'OK'], - ], - fan => [ - ['OFF', 'CRITICAL'], - ['Absent', 'OK'], - ['Low', 'OK'], - ['Medium', 'OK'], - ['High', 'WARNING'], - ], - gfc => [ - ['Online', 'OK'], - ['Unconfigured', 'OK'], - ['Unknown', 'UNKNOWN'], - ['Not\s*Supported', 'WARNING'], - ['Dead', 'CRITICAL'], - ['Lost', 'CRITICAL'], - ['Failover\s*Failed', 'CRITICAL'], - ['Failover', 'WARNING'], - ], - lfc => [ - ['Online', 'OK'], - ['Unconfigured', 'OK'], - ['Unknown', 'UNKNOWN'], - ['Not\s*Supported', 'WARNING'], - ['Dead', 'CRITICAL'], - ['Lost', 'CRITICAL'], - ['Failover\s*Failed', 'CRITICAL'], - ['Failover', 'WARNING'], - ], + }; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(vimm|ca|psu|fan|gfc|lfc)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + vimm => [ + ['not failed', 'OK'], + ['failed', 'CRITICAL'], + ], + ca => [ + ['ON', 'CRITICAL'], + ['OFF', 'OK'], + ], + psu => [ + ['OFF', 'CRITICAL'], + ['Absent', 'OK'], + ['ON', 'OK'], + ], + fan => [ + ['OFF', 'CRITICAL'], + ['Absent', 'OK'], + ['Low', 'OK'], + ['Medium', 'OK'], + ['High', 'WARNING'], + ], + gfc => [ + ['Online', 'OK'], + ['Unconfigured', 'OK'], + ['Unknown', 'UNKNOWN'], + ['Not\s*Supported', 'WARNING'], + ['Dead', 'CRITICAL'], + ['Lost', 'CRITICAL'], + ['Failover\s*Failed', 'CRITICAL'], + ['Failover', 'WARNING'], + ], + lfc => [ + ['Online', 'OK'], + ['Unconfigured', 'OK'], + ['Unknown', 'UNKNOWN'], + ['Not\s*Supported', 'WARNING'], + ['Dead', 'CRITICAL'], + ['Lost', 'CRITICAL'], + ['Failover\s*Failed', 'CRITICAL'], + ['Failover', 'WARNING'], + ], + }; + + $self->{components_path} = 'centreon::common::violin::snmp::mode::components'; + $self->{components_module} = ['ca', 'psu', 'fan', 'vimm', 'temperature', 'gfc', 'lfc']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -76,202 +98,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "absent-problem:s" => { name => 'absent' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $self->{components} = {}; - $self->{no_components} = undef; return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } - } - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ('temperature', $1, $2); - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('ca', 'psu', 'fan', 'vimm', 'temperature', 'gfc', 'lfc'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::violin::snmp::mode::components::$_"; - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, - error_msg => "Cannot load module '$mod_name'."); - my $func = $mod_name->can('load'); - $func->(request => $snmp_request); - } - } - - if (scalar(@{$snmp_request}) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::violin::snmp::mode::components::$_"; - my $func = $mod_name->can('check'); - $func->($self); - } - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components are ok [%s].", - $total_components, - $display_by_component) - ); - - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked.'); - } - - $self->{output}->display(); - $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; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Component '%s' instance '%s' is not present", - $options{section}, $options{instance})); - } - - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)")); - $self->{components}->{$options{section}}->{skip}++; - return 1; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}); -} - -sub get_severity { - my ($self, %options) = @_; - my $status = 'UNKNOWN'; # default - - if (defined($self->{overload_th}->{$options{section}})) { - foreach (@{$self->{overload_th}->{$options{section}}}) { - if ($options{value} =~ /$_->{filter}/i) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - sub convert_index { my ($self, %options) = @_; @@ -306,15 +138,15 @@ Check components (Fans, Power Supplies, Temperatures, Chassis alarm, vimm, globa Which component to check (Default: '.*'). Can be: 'psu', 'fan', 'ca', 'vimm', 'lfc', 'gfc', 'temperature'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='psu#41239F00647-A#' +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,41239F00647-A =item B<--absent-problem> Return an error if an entity is not 'present' (default is skipping) (comma seperated list) -Can be specific or global: --absent-problem=fan#41239F00647-fan02# +Can be specific or global: --absent-problem=fan,41239F00647-fan02 =item B<--no-component> @@ -323,19 +155,19 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='gfc,CRITICAL,^(?!(Online)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: regexp,treshold) -Example: --warning='41239F00647-vimm46,20' --warning='41239F00647-vimm5.*,30' +Set warning threshold for temperatures (syntax: type,regexp,threshold) +Example: --warning='temperature,41239F00647-vimm46,20' --warning='temperature,41239F00647-vimm5.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: regexp,treshold) -Example: --critical='41239F00647-vimm46,25' --warning='41239F00647-vimm5.*,35' +Set critical threshold for temperatures (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,25' --warning='temperature,.*,35' =back diff --git a/hardware/server/cisco/ucs/mode/components/blade.pm b/hardware/server/cisco/ucs/mode/components/blade.pm index b5cba0ee6..e928ddf72 100644 --- a/hardware/server/cisco/ucs/mode/components/blade.pm +++ b/hardware/server/cisco/ucs/mode/components/blade.pm @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsComputeBladeDn = '.1.3.6.1.4.1.9.9.719.1.9.2.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsComputeBladePresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsComputeBladePresence}->{oid} }, { oid => $mapping2->{cucsComputeBladeOperState}->{oid} }, { oid => $oid_cucsComputeBladeDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking blades"); $self->{components}->{blade} = {name => 'blades', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'blade')); + return if ($self->check_filter(section => 'blade')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsComputeBladeDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsComputeBladeOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'blade', instance => $blade_dn)); - next if ($self->check_exclude(section => 'blade', instance => $blade_dn)); + next if ($self->check_filter(section => 'blade', instance => $blade_dn)); $self->{output}->output_add(long_msg => sprintf("blade '%s' state is '%s' [presence: %s].", $blade_dn, $result2->{cucsComputeBladeOperState}, diff --git a/hardware/server/cisco/ucs/mode/components/chassis.pm b/hardware/server/cisco/ucs/mode/components/chassis.pm index c395b04d6..b1413df31 100644 --- a/hardware/server/cisco/ucs/mode/components/chassis.pm +++ b/hardware/server/cisco/ucs/mode/components/chassis.pm @@ -32,9 +32,9 @@ my $mapping1 = { my $oid_cucsEquipmentChassisDn = '.1.3.6.1.4.1.9.9.719.1.15.7.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentChassisOperState}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentChassisOperState}->{oid} }, { oid => $oid_cucsEquipmentChassisDn }; } @@ -43,7 +43,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking chassis"); $self->{components}->{chassis} = {name => 'chassis', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'chassis')); + return if ($self->check_filter(section => 'chassis')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentChassisDn}})) { $oid =~ /\.(\d+)$/; @@ -52,7 +52,7 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsEquipmentChassisOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'chassis', instance => $chassis_dn)); - next if ($self->check_exclude(section => 'chassis', instance => $chassis_dn)); + next if ($self->check_filter(section => 'chassis', instance => $chassis_dn)); $self->{components}->{chassis}->{total}++; diff --git a/hardware/server/cisco/ucs/mode/components/cpu.pm b/hardware/server/cisco/ucs/mode/components/cpu.pm index 04194ef13..c49b1c074 100644 --- a/hardware/server/cisco/ucs/mode/components/cpu.pm +++ b/hardware/server/cisco/ucs/mode/components/cpu.pm @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsProcessorUnitDn = '.1.3.6.1.4.1.9.9.719.1.41.9.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsProcessorUnitPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsProcessorUnitPresence}->{oid} }, { oid => $mapping2->{cucsProcessorUnitOperState}->{oid} }, { oid => $oid_cucsProcessorUnitDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking cpus"); $self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'cpu')); + return if ($self->check_filter(section => 'cpu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsProcessorUnitDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsProcessorUnitOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'cpu', instance => $cpu_dn)); - next if ($self->check_exclude(section => 'cpu', instance => $cpu_dn)); + next if ($self->check_filter(section => 'cpu', instance => $cpu_dn)); $self->{output}->output_add(long_msg => sprintf("cpu '%s' state is '%s' [presence: %s].", $cpu_dn, $result2->{cucsProcessorUnitOperState}, diff --git a/hardware/server/cisco/ucs/mode/components/fan.pm b/hardware/server/cisco/ucs/mode/components/fan.pm index 5fd1ce740..169341beb 100644 --- a/hardware/server/cisco/ucs/mode/components/fan.pm +++ b/hardware/server/cisco/ucs/mode/components/fan.pm @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsEquipmentFanDn = '.1.3.6.1.4.1.9.9.719.1.15.12.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentFanPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentFanPresence}->{oid} }, { oid => $mapping2->{cucsEquipmentFanOperState}->{oid} }, { oid => $oid_cucsEquipmentFanDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentFanDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentFanOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'fan', instance => $fan_dn)); - next if ($self->check_exclude(section => 'fan', instance => $fan_dn)); + next if ($self->check_filter(section => 'fan', instance => $fan_dn)); $self->{output}->output_add(long_msg => sprintf("fan '%s' state is '%s' [presence: %s].", $fan_dn, $result2->{cucsEquipmentFanOperState}, diff --git a/hardware/server/cisco/ucs/mode/components/fex.pm b/hardware/server/cisco/ucs/mode/components/fex.pm index 953912bea..a6845cc79 100644 --- a/hardware/server/cisco/ucs/mode/components/fex.pm +++ b/hardware/server/cisco/ucs/mode/components/fex.pm @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsEquipmentFexDn = '.1.3.6.1.4.1.9.9.719.1.15.19.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentFexPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentFexPresence}->{oid} }, { oid => $mapping2->{cucsEquipmentFexOperState}->{oid} }, { oid => $oid_cucsEquipmentFexDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fabric extenders"); $self->{components}->{fex} = {name => 'fabric extenders', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fex')); + return if ($self->check_filter(section => 'fex')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentFexDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentFexOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'fex', instance => $fex_dn)); - next if ($self->check_exclude(section => 'fex', instance => $fex_dn)); + next if ($self->check_filter(section => 'fex', instance => $fex_dn)); $self->{output}->output_add(long_msg => sprintf("Fabric extender '%s' state is '%s' [presence: %s].", $fex_dn, $result2->{cucsEquipmentFexOperState}, diff --git a/hardware/server/cisco/ucs/mode/components/iocard.pm b/hardware/server/cisco/ucs/mode/components/iocard.pm index 174bfc86e..b3808608f 100644 --- a/hardware/server/cisco/ucs/mode/components/iocard.pm +++ b/hardware/server/cisco/ucs/mode/components/iocard.pm @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsEquipmentIOCardDn = '.1.3.6.1.4.1.9.9.719.1.15.30.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentIOCardPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentIOCardPresence}->{oid} }, { oid => $mapping2->{cucsEquipmentIOCardOperState}->{oid} }, { oid => $oid_cucsEquipmentIOCardDn }; } @@ -46,7 +46,7 @@ sub check { # In MIB 'CISCO-UNIFIED-COMPUTING-EQUIPMENT-MIB' $self->{output}->output_add(long_msg => "Checking io cards"); $self->{components}->{iocard} = {name => 'io cards', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'iocard')); + return if ($self->check_filter(section => 'iocard')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentIOCardDn}})) { $oid =~ /\.(\d+)$/; @@ -56,7 +56,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentIOCardOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'iocard', instance => $iocard_dn)); - next if ($self->check_exclude(section => 'iocard', instance => $iocard_dn)); + next if ($self->check_filter(section => 'iocard', instance => $iocard_dn)); $self->{output}->output_add(long_msg => sprintf("IO cards '%s' state is '%s' [presence: %s].", $iocard_dn, $result2->{cucsEquipmentIOCardOperState}, diff --git a/hardware/server/cisco/ucs/mode/components/localdisk.pm b/hardware/server/cisco/ucs/mode/components/localdisk.pm index 44104d87e..35f7c8306 100644 --- a/hardware/server/cisco/ucs/mode/components/localdisk.pm +++ b/hardware/server/cisco/ucs/mode/components/localdisk.pm @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsStorageLocalDiskDn = '.1.3.6.1.4.1.9.9.719.1.45.4.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsStorageLocalDiskPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsStorageLocalDiskPresence}->{oid} }, { oid => $mapping2->{cucsStorageLocalDiskOperability}->{oid} }, { oid => $oid_cucsStorageLocalDiskDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking local disks"); $self->{components}->{localdisk} = {name => 'local disks', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'localdisk')); + return if ($self->check_filter(section => 'localdisk')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsStorageLocalDiskDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsStorageLocalDiskOperability}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'localdisk', instance => $localdisk_dn)); - next if ($self->check_exclude(section => 'localdisk', instance => $localdisk_dn)); + next if ($self->check_filter(section => 'localdisk', instance => $localdisk_dn)); $self->{output}->output_add(long_msg => sprintf("local disk '%s' state is '%s' [presence: %s].", $localdisk_dn, $result2->{cucsStorageLocalDiskOperability}, diff --git a/hardware/server/cisco/ucs/mode/components/memory.pm b/hardware/server/cisco/ucs/mode/components/memory.pm index ae442a0ee..d79451b60 100644 --- a/hardware/server/cisco/ucs/mode/components/memory.pm +++ b/hardware/server/cisco/ucs/mode/components/memory.pm @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsMemoryUnitDn = '.1.3.6.1.4.1.9.9.719.1.30.11.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsMemoryUnitPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsMemoryUnitPresence}->{oid} }, { oid => $mapping2->{cucsMemoryUnitOperState}->{oid} }, { oid => $oid_cucsMemoryUnitDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking memories"); $self->{components}->{memory} = {name => 'memories', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'memory')); + return if ($self->check_filter(section => 'memory')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsMemoryUnitDn}})) { $oid =~ /\.(\d+)$/; @@ -56,7 +56,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsMemoryUnitOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'memory', instance => $memory_dn)); - next if ($self->check_exclude(section => 'memory', instance => $memory_dn)); + next if ($self->check_filter(section => 'memory', instance => $memory_dn)); $self->{output}->output_add(long_msg => sprintf("memory '%s' state is '%s' [presence: %s].", $memory_dn, $result2->{cucsMemoryUnitOperState}, diff --git a/hardware/server/cisco/ucs/mode/components/psu.pm b/hardware/server/cisco/ucs/mode/components/psu.pm index 26a2bdec6..5180e6ae7 100644 --- a/hardware/server/cisco/ucs/mode/components/psu.pm +++ b/hardware/server/cisco/ucs/mode/components/psu.pm @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsEquipmentPsuDn = '.1.3.6.1.4.1.9.9.719.1.15.56.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentPsuPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentPsuPresence}->{oid} }, { oid => $mapping2->{cucsEquipmentPsuOperState}->{oid} }, { oid => $oid_cucsEquipmentPsuDn }; } @@ -46,7 +46,7 @@ sub check { # In MIB 'CISCO-UNIFIED-COMPUTING-EQUIPMENT-MIB' $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentPsuDn}})) { $oid =~ /\.(\d+)$/; @@ -56,7 +56,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentPsuOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'psu', instance => $psu_dn)); - next if ($self->check_exclude(section => 'psu', instance => $psu_dn)); + next if ($self->check_filter(section => 'psu', instance => $psu_dn)); $self->{output}->output_add(long_msg => sprintf("power supply '%s' state is '%s' [presence: %s].", $psu_dn, $result2->{cucsEquipmentPsuOperState}, diff --git a/hardware/server/cisco/ucs/mode/equipment.pm b/hardware/server/cisco/ucs/mode/equipment.pm index 91d7e45ac..fbd837d37 100644 --- a/hardware/server/cisco/ucs/mode/equipment.pm +++ b/hardware/server/cisco/ucs/mode/equipment.pm @@ -20,194 +20,45 @@ package hardware::server::cisco::ucs::mode::equipment; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; use hardware::server::cisco::ucs::mode::components::resources qw($thresholds); +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|chassis|iocard|blade|fex|cpu|memory|localdisk)\.(presence|operability|overall_status)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = $thresholds; + + $self->{components_path} = 'hardware::server::cisco::ucs::mode::components'; + $self->{components_module} = ['fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s@" => { name => 'absent_problem' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, + { }); - $self->{components} = {}; - $self->{no_components} = undef; + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } - } - - $self->{absent_problem} = []; - foreach my $val (@{$self->{option_results}->{absent_problem}}) { - next if (!defined($val) || $val eq ''); - my @values = split (/,/, $val); - push @{$self->{absent_problem}}, { filter => $values[0], instance => $values[1] }; - } - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - next if (!defined($val) || $val eq ''); - my @values = split (/,/, $val); - if (scalar(@values) < 3) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $status, $filter); - if (scalar(@values) == 3) { - ($section, $status, $filter) = @values; - $instance = '.*'; - } else { - ($section, $instance, $status, $filter) = @values; - } - if ($section !~ /^(fan|psu|chassis|iocard|blade|fex|cpu|memory|localdisk)\.(presence|operability|overall_status)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'."); - $self->{output}->option_exit(); - } - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance }; - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "hardware::server::cisco::ucs::mode::components::$_"; - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, - error_msg => "Cannot load module '$mod_name'."); - my $func = $mod_name->can('load'); - $func->(request => $snmp_request); - } - } - - if (scalar(@{$snmp_request}) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "hardware::server::cisco::ucs::mode::components::$_"; - my $func = $mod_name->can('check'); - $func->($self); - } - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components are ok [%s].", - $total_components, - $display_by_component) - ); - - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked.'); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -sub absent_problem { - my ($self, %options) = @_; - - foreach (@{$self->{absent_problem}}) { - if ($options{section} =~ /$_->{filter}/) { - if (!defined($_->{instance}) || $options{instance} =~ /$_->{instance}/) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Component '%s' instance '%s' is not present", - $options{section}, $options{instance})); - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)")); - $self->{components}->{$options{section}}->{skip}++; - return 1; - } - } - } - - return 0; -} - -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 get_severity { - my ($self, %options) = @_; - my $status = 'UNKNOWN'; # default - - if (defined($self->{overload_th}->{$options{section}})) { - foreach (@{$self->{overload_th}->{$options{section}}}) { - if ($options{value} =~ /$_->{filter}/i && - (!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) { - $status = $_->{status}; - return $status; - } - } - } - my $label = defined($options{label}) ? $options{label} : $options{section}; - foreach (@{$thresholds->{$label}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - 1; __END__ @@ -223,10 +74,10 @@ Check Hardware (Fans, Power supplies, chassis, io cards, blades, fabric extender Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan) -Can be specific or global: --exclude=fan#/sys/chassis-7/fan-module-1-7/fan-1# +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,/sys/chassis-7/fan-module-1-7/fan-1 =item B<--absent-problem> diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm index eabf896d3..88361c9ff 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm @@ -40,9 +40,9 @@ my $oids = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_temperature, end => $oid_end }; + push @{$self->{request}}, { oid => $oid_temperature, end => $oid_end }; } sub check { @@ -50,7 +50,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking ambient"); $self->{components}->{ambient} = {name => 'ambient', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'ambient')); + return if ($self->check_filter(section => 'ambient')); my @sensors = ('mm', 'frontpanel', 'frontpanel2'); my $label = 'bladecenter'; @@ -68,7 +68,7 @@ sub check { } my $value = $1; - next if ($self->check_exclude(section => 'ambient', instance => $temp)); + next if ($self->check_filter(section => 'ambient', instance => $temp)); $self->{components}->{ambient}->{total}++; $self->{output}->output_add(long_msg => sprintf("ambient '%s' is %s degree centigrade.", diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm index 2f020405a..dd9918b7d 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm @@ -59,9 +59,9 @@ my $mapping = { my $oid_bladeSystemStatusEntry = '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_bladeSystemStatusEntry, start => $mapping->{bladeId}->{oid}, end => $mapping->{bladeName}->{oid} }; + push @{$self->{request}}, { oid => $oid_bladeSystemStatusEntry, start => $mapping->{bladeId}->{oid}, end => $mapping->{bladeName}->{oid} }; } sub check { @@ -69,14 +69,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking blades"); $self->{components}->{blade} = {name => 'blades', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'blade')); + return if ($self->check_filter(section => 'blade')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeSystemStatusEntry}})) { next if ($oid !~ /^$mapping->{bladeExists}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeSystemStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'blade', instance => $result->{bladeId})); + next if ($self->check_filter(section => 'blade', instance => $result->{bladeId})); if ($result->{bladeExists} =~ /false/i) { $self->{output}->output_add(long_msg => "skipping blade '" . $instance . "' : not exits"); next; diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/blower.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/blower.pm index b03b7c565..022cb698b 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/blower.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/blower.pm @@ -45,9 +45,9 @@ my $entry_controller_state = '30'; my $count = 4; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_blowers }; + push @{$self->{request}}, { oid => $oid_blowers }; } sub check { @@ -55,7 +55,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking blowers"); $self->{components}->{blower} = {name => 'blowers', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'blower')); + return if ($self->check_filter(section => 'blower')); for (my $i = 0; $i < $count; $i++) { my $instance = $i + 1; @@ -64,7 +64,7 @@ sub check { my $blower_speed = defined($self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_blower_speed + $i) . '.0'}) ? $self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_blower_speed + $i) . '.0'} : 'unknown'; my $ctrl_state = defined($self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_controller_state + $i) . '.0'}) ? $map_controller_state{$self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_controller_state + $i) . '.0'}} : undef; - next if ($self->check_exclude(section => 'blower', instance => $instance)); + next if ($self->check_filter(section => 'blower', instance => $instance)); next if ($blower_speed =~ /No Blower/i && $self->absent_problem(section => 'blower', instance => $instance)); $self->{components}->{blower}->{total}++; @@ -94,7 +94,7 @@ sub check { next if (!defined($ctrl_state)); - next if ($self->check_exclude(section => 'blowerctrl', instance => $instance)); + next if ($self->check_filter(section => 'blowerctrl', instance => $instance)); next if ($ctrl_state =~ /notPresent/i && $self->absent_problem(section => 'blowerctrl', instance => $instance)); $self->{output}->output_add(long_msg => sprintf("Blower controller '%s' state is %s.", diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm index a3c90d7a2..f3648f55c 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm @@ -38,9 +38,9 @@ my $mapping = { my $oid_chassisFansEntry = '.1.3.6.1.4.1.2.3.51.2.2.3.50.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_chassisFansEntry }; + push @{$self->{request}}, { oid => $oid_chassisFansEntry }; } sub check { @@ -48,14 +48,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking chassis fan"); $self->{components}->{chassisfan} = {name => 'chassis fan', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'chassisfan')); + return if ($self->check_filter(section => 'chassisfan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_chassisFansEntry}})) { next if ($oid !~ /^$mapping->{chassisFanState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_chassisFansEntry}, instance => $instance); - next if ($self->check_exclude(section => 'chassisfan', instance => $instance)); + next if ($self->check_filter(section => 'chassisfan', instance => $instance)); $self->{components}->{chassisfan}->{total}++; $self->{output}->output_add(long_msg => sprintf("Chassis fan '%s' is %s rpm [status: %s, instance: %s]", diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm index db8b4a56a..f4a315fdb 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm @@ -64,9 +64,9 @@ my %map_test_state = ( ); sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_mmBistAndChassisStatus, end => $oid_bistLogicalNetworkLink }; + push @{$self->{request}}, { oid => $oid_mmBistAndChassisStatus, end => $oid_bistLogicalNetworkLink }; } sub check { @@ -74,7 +74,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking chassis status"); $self->{components}->{chassisstatus} = {name => 'chassis-status', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'chassisstatus')); + return if ($self->check_filter(section => 'chassisstatus')); foreach my $name (sort keys %{$oids}) { if (!defined($self->{results}->{$oid_mmBistAndChassisStatus}->{$oids->{$name}})) { @@ -84,7 +84,7 @@ sub check { } my $value = $map_test_state{$self->{results}->{$oid_mmBistAndChassisStatus}->{$oids->{$name}}}; - next if ($self->check_exclude(section => 'chassisstatus', instance => $name)); + next if ($self->check_filter(section => 'chassisstatus', instance => $name)); $self->{components}->{chassisstatus}->{total}++; $self->{output}->output_add(long_msg => sprintf("Chassis status '%s' state is %s", diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm index 918cd655a..7f9a067f2 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm @@ -43,9 +43,9 @@ my $mapping = { my $oid_fanPackEntry = '.1.3.6.1.4.1.2.3.51.2.2.6.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_fanPackEntry }; + push @{$self->{request}}, { oid => $oid_fanPackEntry }; } sub check { @@ -53,7 +53,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fanpack"); $self->{components}->{fanpack} = {name => 'fanpacks', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fanpack')); + return if ($self->check_filter(section => 'fanpack')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanPackEntry}})) { next if ($oid !~ /^$mapping->{fanPackState}->{oid}\.(.*)$/); @@ -64,7 +64,7 @@ sub check { $self->{output}->output_add(long_msg => "skipping fanpack '" . $instance . "' : not exits"); next; } - next if ($self->check_exclude(section => 'fanpack', instance => $instance)); + next if ($self->check_filter(section => 'fanpack', instance => $instance)); $self->{components}->{fanpack}->{total}++; $self->{output}->output_add(long_msg => sprintf("Fanpack '%s' is %s rpm [status: %s, instance: %s]", diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm index dd4fd6135..27e6d8a5d 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm @@ -44,9 +44,9 @@ my $mapping = { my $oid_powerModuleHealthEntry = '.1.3.6.1.4.1.2.3.51.2.2.4.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_powerModuleHealthEntry, start => $mapping->{powerModuleExists}->{oid} }; + push @{$self->{request}}, { oid => $oid_powerModuleHealthEntry, start => $mapping->{powerModuleExists}->{oid} }; } sub check { @@ -54,14 +54,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power modules"); $self->{components}->{powermodule} = {name => 'power modules', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'powermodule')); + return if ($self->check_filter(section => 'powermodule')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerModuleHealthEntry}})) { next if ($oid !~ /^$mapping->{powerModuleState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerModuleHealthEntry}, instance => $instance); - next if ($self->check_exclude(section => 'powermodule', instance => $instance)); + next if ($self->check_filter(section => 'powermodule', instance => $instance)); next if ($result->{powerModuleExists} =~ /No/i && $self->absent_problem(section => 'powermodule', instance => $instance)); $self->{components}->{powermodule}->{total}++; diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm index 3d6c6b3f2..95e2517d2 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm @@ -36,9 +36,9 @@ my $mapping = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{smHealthState}->{oid} }; + push @{$self->{request}}, { oid => $mapping->{smHealthState}->{oid} }; } sub check { @@ -46,14 +46,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking switch module"); $self->{components}->{switchmodule} = {name => 'switch modules', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'switchmodule')); + return if ($self->check_filter(section => 'switchmodule')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{smHealthState}->{oid}}})) { $oid =~ /^$mapping->{smHealthState}->{oid}\.(.*)/; my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{smHealthState}->{oid}}, instance => $instance); - next if ($self->check_exclude(section => 'switchmodule', instance => $instance)); + next if ($self->check_filter(section => 'switchmodule', instance => $instance)); $self->{components}->{switchmodule}->{total}++; $self->{output}->output_add(long_msg => sprintf("Switch module '%s' status is %s [instance: %s]", diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm index 4f4958292..18c5e49b0 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm @@ -34,9 +34,9 @@ my %map_systemhealth_state = ( ); sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_systemHealthStat }; + push @{$self->{request}}, { oid => $oid_systemHealthStat }; } sub check { @@ -44,8 +44,11 @@ sub check { $self->{output}->output_add(long_msg => "Checking system health"); $self->{components}->{systemhealth} = {name => 'system-health', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'systemhealth')); + return if ($self->check_filter(section => 'systemhealth')); + return if (!defined($self->{results}->{$oid_systemHealthStat}->{$oid_systemHealthStat . '.0'}) || + !defined($map_systemhealth_state{$self->{results}->{$oid_systemHealthStat}->{$oid_systemHealthStat . '.0'}})); + my $value = $map_systemhealth_state{$self->{results}->{$oid_systemHealthStat}->{$oid_systemHealthStat . '.0'}}; $self->{components}->{systemhealth}->{total}++; diff --git a/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm b/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm index 1d939c6e7..7be62e343 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm @@ -20,74 +20,92 @@ package hardware::server::ibm::bladecenter::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - chassisstatus => [ - ['testSucceeded', 'OK'], - ['testFailed', 'CRITICAL'], - ], - systemhealth => [ - ['normal', 'OK'], - ['systemLevel', 'WARNING'], - ['nonCritical', 'WARNING'], - ['critical', 'CRITICAL'], - ], - powermodule => [ - ['unknown', 'UNKNOWN'], - ['good', 'OK'], - ['warning', 'WARNING'], - ['notAvailable', 'UNKNOWN'], - ], - fanpack => [ - ['unknown', 'UNKNOWN'], - ['good', 'OK'], - ['warning', 'WARNING'], - ['bad', 'CRITICAL'], - ], - chassisfan => [ - ['unknown', 'UNKNOWN'], - ['good', 'OK'], - ['warning', 'WARNING'], - ['bad', 'CRITICAL'], - ], - blower => [ - ['unknown', 'UNKNOWN'], - ['good', 'OK'], - ['warning', 'WARNING'], - ['bad', 'CRITICAL'], - ], - switchmodule => [ - ['unknown', 'UNKNOWN'], - ['good', 'OK'], - ['warning', 'WARNING'], - ['bad', 'CRITICAL'], - ], - blowerctrl => [ - ['unknown', 'UNKNOWN'], - ['operational', 'OK'], - ['flashing', 'WARNING'], - ['communicationError', 'CRITICAL'], - ['notPresent', 'UNKNOWN'], - ], - blade => [ - ['unknown', 'UNKNOWN'], - ['good', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['kernelMode', 'WARNING'], - ['discovering', 'WARNING'], - ['commError', 'CRITICAL'], - ['noPower', 'WARNING'], - ['flashing', 'WARNING'], - ['initFailure', 'CRITICAL'], - ['insufficientPower', 'CRITICAL'], - ['powerDenied', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(blower|ambient|fanpack|chassisfan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + chassisstatus => [ + ['testSucceeded', 'OK'], + ['testFailed', 'CRITICAL'], + ], + systemhealth => [ + ['normal', 'OK'], + ['systemLevel', 'WARNING'], + ['nonCritical', 'WARNING'], + ['critical', 'CRITICAL'], + ], + powermodule => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['notAvailable', 'UNKNOWN'], + ], + fanpack => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['bad', 'CRITICAL'], + ], + chassisfan => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['bad', 'CRITICAL'], + ], + blower => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['bad', 'CRITICAL'], + ], + switchmodule => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['bad', 'CRITICAL'], + ], + blowerctrl => [ + ['unknown', 'UNKNOWN'], + ['operational', 'OK'], + ['flashing', 'WARNING'], + ['communicationError', 'CRITICAL'], + ['notPresent', 'UNKNOWN'], + ], + blade => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['kernelMode', 'WARNING'], + ['discovering', 'WARNING'], + ['commError', 'CRITICAL'], + ['noPower', 'WARNING'], + ['flashing', 'WARNING'], + ['initFailure', 'CRITICAL'], + ['insufficientPower', 'CRITICAL'], + ['powerDenied', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::server::ibm::bladecenter::snmp::mode::components'; + $self->{components_module} = ['ambient', 'powermodule', 'blade', 'blower', 'fanpack', 'chassisfan', 'systemhealth', 'chassisstatus', 'switchmodule']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -96,211 +114,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $self->{product_name} = undef; - $self->{serial} = undef; - $self->{romversion} = undef; - $self->{components} = {}; - $self->{no_components} = undef; - return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } - } - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(blower|ambient|fanpack|chassisfan)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: blower, fanpack, chassisfan or ambient)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('ambient', 'powermodule', 'blade', 'blower', 'fanpack', 'chassisfan', 'systemhealth', 'chassisstatus', 'switchmodule'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "hardware::server::ibm::bladecenter::snmp::mode::components::$_"; - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, - error_msg => "Cannot load module '$mod_name'."); - my $func = $mod_name->can('load'); - $func->(request => $snmp_request); - } - } - - if (scalar(@{$snmp_request}) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "hardware::server::ibm::bladecenter::snmp::mode::components::$_"; - my $func = $mod_name->can('check'); - $func->($self); - } - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components are ok [%s].", - $total_components, - $display_by_component) - ); - - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked.'); - } - - $self->{output}->display(); - $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; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Component '%s' instance '%s' is not present", - $options{section}, $options{instance})); - } - - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)")); - $self->{components}->{$options{section}}->{skip}++; - return 1; -} - - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -sub get_severity { - my ($self, %options) = @_; - my $status = 'UNKNOWN'; # default - - if (defined($self->{overload_th}->{$options{section}})) { - foreach (@{$self->{overload_th}->{$options{section}}}) { - if ($options{value} =~ /$_->{filter}/i) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - 1; __END__ @@ -317,15 +136,15 @@ Which component to check (Default: 'all'). Can be: 'ambient', 'powermodule', 'fanpack', 'chassisfan', 'blower', 'blade', 'systemhealth', 'chassisstatus', 'switchmodule'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=blower,powermodule) -Can also exclude specific instance: --exclude=blower#1#,powermodule#2# +Exclude some parts (comma seperated list) (Example: --filter=blower --filter=powermodule) +Can also exclude specific instance: --filter=blower,1 =item B<--absent-problem> Return an error if an entity is not 'notAvailable' (default is skipping) (comma seperated list) -Can be specific or global: --absent-problem=powermodule#2# +Can be specific or global: --absent-problem=powermodule,2 =item B<--no-component> @@ -334,18 +153,18 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='blade,OK,unknown' =item B<--warning> -Set warning threshold for temperatures (syntax: type,regexp,treshold) +Set warning threshold (syntax: type,regexp,threshold) Example: --warning='ambient,mm,30' --warning='ambient,frontpanel,35' =item B<--critical> -Set critical threshold for temperatures (syntax: type,regexp,treshold) +Set critical threshold (syntax: type,regexp,threshold) Example: --critical='blower,1,50' =back