diff --git a/storage/dell/equallogic/snmp/mode/components/disk.pm b/storage/dell/equallogic/snmp/mode/components/disk.pm index ed9f3562d..375d347d5 100644 --- a/storage/dell/equallogic/snmp/mode/components/disk.pm +++ b/storage/dell/equallogic/snmp/mode/components/disk.pm @@ -43,9 +43,9 @@ my $mapping = { my $oid_eqlDiskStatus = '.1.3.6.1.4.1.12740.3.1.1.1.8'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_eqlDiskStatus }; + push @{$self->{request}}, { oid => $oid_eqlDiskStatus }; } sub check { @@ -53,7 +53,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking disks"); $self->{components}->{disk} = {name => 'disks', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'disk')); + return if ($self->check_filter(section => 'disk')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlDiskStatus}})) { next if ($oid !~ /^$mapping->{eqlDiskStatus}->{oid}\.(\d+\.\d+)\.(.*)$/); @@ -61,11 +61,11 @@ sub check { my $member_name = $self->get_member_name(instance => $member_instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlDiskStatus}, instance => $member_instance . '.' . $instance); - next if ($self->check_exclude(section => 'disk', instance => $instance)); + next if ($self->check_filter(section => 'disk', instance => $member_instance . '.' . $instance)); $self->{components}->{disk}->{total}++; $self->{output}->output_add(long_msg => sprintf("Disk '%s/%s' status is %s [instance: %s].", - $member_name, $instance, $result->{eqlDiskStatus}, $instance + $member_name, $instance, $result->{eqlDiskStatus}, $member_instance . '.' . $instance )); my $exit = $self->get_severity(section => 'disk', value => $result->{eqlDiskStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { diff --git a/storage/dell/equallogic/snmp/mode/components/fan.pm b/storage/dell/equallogic/snmp/mode/components/fan.pm index bc0431eeb..031d15e85 100644 --- a/storage/dell/equallogic/snmp/mode/components/fan.pm +++ b/storage/dell/equallogic/snmp/mode/components/fan.pm @@ -43,9 +43,9 @@ my $mapping = { my $oid_eqlMemberHealthDetailsFanEntry = '.1.3.6.1.4.1.12740.2.1.7.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_eqlMemberHealthDetailsFanEntry }; + push @{$self->{request}}, { oid => $oid_eqlMemberHealthDetailsFanEntry }; } sub check { @@ -53,7 +53,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_eqlMemberHealthDetailsFanEntry}})) { next if ($oid !~ /^$mapping->{eqlMemberHealthDetailsFanCurrentState}->{oid}\.(\d+\.\d+)\.(.*)$/); @@ -61,12 +61,12 @@ sub check { my $member_name = $self->get_member_name(instance => $member_instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthDetailsFanEntry}, instance => $member_instance . '.' . $instance); - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $member_instance . '.' . $instance)); $self->{components}->{fan}->{total}++; $self->{output}->output_add(long_msg => sprintf("Fan '%s/%s' status is %s [instance: %s].", $member_name, $result->{eqlMemberHealthDetailsFanName}, $result->{eqlMemberHealthDetailsFanCurrentState}, - $instance + $member_instance . '.' . $instance )); my $exit = $self->get_severity(section => 'fan', value => $result->{eqlMemberHealthDetailsFanCurrentState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { diff --git a/storage/dell/equallogic/snmp/mode/components/health.pm b/storage/dell/equallogic/snmp/mode/components/health.pm index d25dff84a..b3af94754 100644 --- a/storage/dell/equallogic/snmp/mode/components/health.pm +++ b/storage/dell/equallogic/snmp/mode/components/health.pm @@ -37,9 +37,9 @@ my $mapping = { my $oid_eqlMemberHealthStatus = '.1.3.6.1.4.1.12740.2.1.5.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_eqlMemberHealthStatus }; + push @{$self->{request}}, { oid => $oid_eqlMemberHealthStatus }; } sub check { @@ -47,7 +47,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking health"); $self->{components}->{health} = {name => 'health', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'health')); + return if ($self->check_filter(section => 'health')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberHealthStatus}})) { next if ($oid !~ /^$mapping->{eqlMemberHealthStatus}->{oid}\.(\d+\.\d+)$/); @@ -55,12 +55,12 @@ sub check { my $member_name = $self->get_member_name(instance => $member_instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthStatus}, instance => $member_instance); - next if ($self->check_exclude(section => 'health', instance => $member_instance)); + next if ($self->check_filter(section => 'health', instance => $member_instance)); $self->{components}->{health}->{total}++; $self->{output}->output_add(long_msg => sprintf("Health '%s' status is %s [instance: %s].", $member_name, $result->{eqlMemberHealthStatus}, - $member_name + $member_instance )); my $exit = $self->get_severity(section => 'health', value => $result->{eqlMemberHealthStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { diff --git a/storage/dell/equallogic/snmp/mode/components/psu.pm b/storage/dell/equallogic/snmp/mode/components/psu.pm index 2460f3eaf..363f9f41b 100644 --- a/storage/dell/equallogic/snmp/mode/components/psu.pm +++ b/storage/dell/equallogic/snmp/mode/components/psu.pm @@ -43,9 +43,9 @@ my $mapping = { my $oid_eqlMemberHealthDetailsPowerSupplyEntry = '.1.3.6.1.4.1.12740.2.1.8.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_eqlMemberHealthDetailsPowerSupplyEntry }; + push @{$self->{request}}, { oid => $oid_eqlMemberHealthDetailsPowerSupplyEntry }; } sub check { @@ -53,7 +53,7 @@ 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_eqlMemberHealthDetailsPowerSupplyEntry}})) { next if ($oid !~ /^$mapping->{eqlMemberHealthDetailsPowerSupplyCurrentState}->{oid}\.(\d+\.\d+)\.(.*)$/); @@ -61,12 +61,12 @@ sub check { my $member_name = $self->get_member_name(instance => $member_instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthDetailsPowerSupplyEntry}, instance => $member_instance . '.' . $instance); - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $member_instance . '.' . $instance)); $self->{components}->{psu}->{total}++; $self->{output}->output_add(long_msg => sprintf("Power supply '%s/%s' status is %s [instance: %s] [fan status: %s].", $member_name, $result->{eqlMemberHealthDetailsPowerSupplyName}, $result->{eqlMemberHealthDetailsPowerSupplyCurrentState}, - $instance, $result->{eqlMemberHealthDetailsPowerSupplyFanStatus} + $member_instance . '.' . $instance, $result->{eqlMemberHealthDetailsPowerSupplyFanStatus} )); my $exit = $self->get_severity(section => 'psu', value => $result->{eqlMemberHealthDetailsPowerSupplyCurrentState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { @@ -75,7 +75,7 @@ sub check { $member_name, $result->{eqlMemberHealthDetailsPowerSupplyName}, $result->{eqlMemberHealthDetailsPowerSupplyCurrentState})); } - next if ($self->check_exclude(section => 'psu.fan', instance => $instance)); + next if ($self->check_filter(section => 'psu.fan', instance => $member_instance . '.' . $instance)); $exit = $self->get_severity(section => 'psu.fan', value => $result->{eqlMemberHealthDetailsPowerSupplyFanStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, diff --git a/storage/dell/equallogic/snmp/mode/components/raid.pm b/storage/dell/equallogic/snmp/mode/components/raid.pm index 60fe49c68..a80404f59 100644 --- a/storage/dell/equallogic/snmp/mode/components/raid.pm +++ b/storage/dell/equallogic/snmp/mode/components/raid.pm @@ -41,9 +41,9 @@ my $mapping = { my $oid_eqlMemberRAIDEntry = '.1.3.6.1.4.1.12740.2.1.13.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_eqlMemberRAIDEntry }; + push @{$self->{request}}, { oid => $oid_eqlMemberRAIDEntry }; } sub check { @@ -51,7 +51,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking raids"); $self->{components}->{raid} = {name => 'raids', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'raid')); + return if ($self->check_filter(section => 'raid')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberRAIDEntry}})) { next if ($oid !~ /^$mapping->{eqlMemberRaidStatus}->{oid}\.(\d+\.\d+)$/); @@ -59,11 +59,11 @@ sub check { my $member_name = $self->get_member_name(instance => $member_instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberRAIDEntry}, instance => $member_instance); - next if ($self->check_exclude(section => 'raid', instance => $member_instance)); + next if ($self->check_filter(section => 'raid', instance => $member_instance)); $self->{components}->{raid}->{total}++; $self->{output}->output_add(long_msg => sprintf("Raid '%s' status is %s [instance: %s].", - $member_name, $result->{eqlMemberRaidStatus}, $member_name + $member_name, $result->{eqlMemberRaidStatus}, $member_instance )); my $exit = $self->get_severity(section => 'raid', value => $result->{eqlMemberRaidStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { diff --git a/storage/dell/equallogic/snmp/mode/components/temperature.pm b/storage/dell/equallogic/snmp/mode/components/temperature.pm index 9f835c8b0..028a711b2 100644 --- a/storage/dell/equallogic/snmp/mode/components/temperature.pm +++ b/storage/dell/equallogic/snmp/mode/components/temperature.pm @@ -43,9 +43,9 @@ my $mapping = { my $oid_eqlMemberHealthDetailsTemperatureEntry = '.1.3.6.1.4.1.12740.2.1.6.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_eqlMemberHealthDetailsTemperatureEntry }; + push @{$self->{request}}, { oid => $oid_eqlMemberHealthDetailsTemperatureEntry }; } sub check { @@ -53,7 +53,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 ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberHealthDetailsTemperatureEntry}})) { next if ($oid !~ /^$mapping->{eqlMemberHealthDetailsTemperatureCurrentState}->{oid}\.(\d+\.\d+)\.(.*)$/); @@ -61,12 +61,12 @@ sub check { my $member_name = $self->get_member_name(instance => $member_instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthDetailsTemperatureEntry}, instance => $member_instance . '.' . $instance); - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $member_instance . '.' . $instance)); $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("Temperature '%s/%s' status is %s [instance: %s].", $member_name, $result->{eqlMemberHealthDetailsTemperatureName}, $result->{eqlMemberHealthDetailsTemperatureCurrentState}, - $instance + $member_instance . '.' . $instance )); my $exit = $self->get_severity(section => 'temperature', value => $result->{eqlMemberHealthDetailsTemperatureCurrentState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { diff --git a/storage/dell/equallogic/snmp/mode/hardware.pm b/storage/dell/equallogic/snmp/mode/hardware.pm index 9c74ba3d4..455140e8d 100644 --- a/storage/dell/equallogic/snmp/mode/hardware.pm +++ b/storage/dell/equallogic/snmp/mode/hardware.pm @@ -20,141 +20,99 @@ package storage::dell::equallogic::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fan => [ - ['unknown', 'UNKNOWN'], - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ], - temperature => [ - ['unknown', 'UNKNOWN'], - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ], - health => [ - ['unknown', 'UNKNOWN'], - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ], - psu => [ - ['on-and-operating', 'OK'], - ['no-ac-power', 'CRITICAL'], - ['failed-or-no-data', 'CRITICAL'], - ], - 'psu.fan' => [ - ['not-applicable', 'OK'], - ['fan-is-operational', 'OK'], - ['fan-not-operational', 'CRITICAL'], - ], - raid => [ - ['ok', 'OK'], - ['degraded', 'WARNING'], - ['verifying', 'OK'], - ['reconstructing', 'WARNING'], - ['failed', 'CRITICAL'], - ['catastrophicLoss', 'CRITICAL'], - ['expanding', 'OK'], - ['mirroring', 'OK'], - ], - disk => [ - ['on-line', 'OK'], - ['spare', 'OK'], - ['failed', 'CRITICAL'], - ['off-line', 'WARNING'], - ['alt-sig', 'WARNING'], - ['too-small', 'WARNING'], - ['history-of-failures', 'WARNING'], - ['unsupported-version', 'CRITICAL'], - ['unhealthy', 'CRITICAL'], - ['replacement', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|temperature|raid|disk|health)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ], + temperature => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ], + health => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ], + psu => [ + ['on-and-operating', 'OK'], + ['no-ac-power', 'CRITICAL'], + ['failed-or-no-data', 'CRITICAL'], + ], + 'psu.fan' => [ + ['not-applicable', 'OK'], + ['fan-is-operational', 'OK'], + ['fan-not-operational', 'CRITICAL'], + ], + raid => [ + ['ok', 'OK'], + ['degraded', 'WARNING'], + ['verifying', 'OK'], + ['reconstructing', 'WARNING'], + ['failed', 'CRITICAL'], + ['catastrophicLoss', 'CRITICAL'], + ['expanding', 'OK'], + ['mirroring', 'OK'], + ], + disk => [ + ['on-line', 'OK'], + ['spare', 'OK'], + ['failed', 'CRITICAL'], + ['off-line', 'WARNING'], + ['alt-sig', 'WARNING'], + ['too-small', 'WARNING'], + ['history-of-failures', 'WARNING'], + ['unsupported-version', 'CRITICAL'], + ['unhealthy', 'CRITICAL'], + ['replacement', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'storage::dell::equallogic::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature', 'raid', 'disk', 'health']; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, 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' }, - "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) = ($1, $2, $3); - if ($section !~ /(temperature|fan)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature or fan)."); - $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 }; - } - } -} - my $oid_eqlMemberName = '.1.3.6.1.4.1.12740.2.1.1.1.9'; +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + push @{$self->{request}}, { oid => $oid_eqlMemberName }; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + sub get_member_name { my ($self, %options) = @_; @@ -163,122 +121,6 @@ sub get_member_name { return $name; } -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = [ { oid => $oid_eqlMemberName } ]; - my @components = ('fan', 'psu', 'temperature', 'raid', 'disk', 'health'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "storage::dell::equallogic::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}) == 1) { - $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 = "storage::dell::equallogic::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_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__ @@ -294,10 +136,10 @@ Check Hardware (Power Supplies, Fans, Temperatures, Raids, Disks, Health). Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'temperature', 'raid', 'disk', 'health'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan) -Can also exclude specific instance: --exclude=fan#1#,psu#3# +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,1 =item B<--no-component> @@ -312,12 +154,12 @@ Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: type,regexp,threshold) +Set warning threshold for 'temperature', 'fan' (syntax: type,regexp,threshold) Example: --warning='temperature,.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: type,regexp,threshold) +Set critical threshold for 'temperature', 'fan' (syntax: type,regexp,threshold) Example: --critical='temperature,.*,40' =back