diff --git a/centreon/common/emc/navisphere/mode/cache.pm b/centreon/common/emc/navisphere/mode/cache.pm index d926609c3..e1c39a72b 100644 --- a/centreon/common/emc/navisphere/mode/cache.pm +++ b/centreon/common/emc/navisphere/mode/cache.pm @@ -47,7 +47,6 @@ my %states = ( ], ); - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); diff --git a/centreon/common/emc/navisphere/mode/disk.pm b/centreon/common/emc/navisphere/mode/disk.pm index 676b9f4bd..a5bf080e5 100644 --- a/centreon/common/emc/navisphere/mode/disk.pm +++ b/centreon/common/emc/navisphere/mode/disk.pm @@ -147,7 +147,7 @@ sub set_counters { output_template => 'Utils : %.2f %%', output_use => 'utils', perfdatas => [ { label => 'utils', value => 'utils', template => '%.2f', - min => 0, max => 100, unit => '%%', label_extra_instance => 1, instance_use => 'display' }, + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/emc/navisphere/mode/sp.pm b/centreon/common/emc/navisphere/mode/sp.pm index 778d4aaff..06eef859d 100644 --- a/centreon/common/emc/navisphere/mode/sp.pm +++ b/centreon/common/emc/navisphere/mode/sp.pm @@ -18,173 +18,38 @@ # limitations under the License. # -package centreon::common::emc::navisphere::mode::sp; - -use base qw(centreon::plugins::mode); +package centreon::common::emc::navisphere::mode::spcomponents::sp; use strict; use warnings; -use centreon::common::emc::navisphere::mode::spcomponents::fan; -use centreon::common::emc::navisphere::mode::spcomponents::lcc; -use centreon::common::emc::navisphere::mode::spcomponents::psu; -use centreon::common::emc::navisphere::mode::spcomponents::battery; -use centreon::common::emc::navisphere::mode::spcomponents::memory; -use centreon::common::emc::navisphere::mode::spcomponents::cpu; -use centreon::common::emc::navisphere::mode::spcomponents::iomodule; -use centreon::common::emc::navisphere::mode::spcomponents::cable; -use centreon::common::emc::navisphere::mode::spcomponents::sp; -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "getcrus-options:s" => { name => 'getcrus_options', default => '-all' }, - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => 'all' }, - "no-component:s" => { name => 'no_component' }, - }); +sub load { }; - $self->{components} = {}; - $self->{no_components} = undef; - - return $self; -} +sub check { + my ($self) = @_; -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->{output}->output_add(long_msg => "Checking sp"); + $self->{components}->{sp} = {name => 'sp', total => 0, skip => 0}; + return if ($self->check_filter(section => 'sp')); - 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'; + # SP A State: Present + while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) { + my $instance = $1; + my $state = $2; + + next if ($self->check_filter(section => 'sp', instance => $instance)); + $self->{components}->{sp}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("sp '%s' state is %s.", + $instance, $state) + ); + my $exit = $self->get_severity(section => 'sp', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("sp '%s' state is %s", + $instance, $state)); } } } -sub component { - my ($self, %options) = @_; - - if ($self->{option_results}->{component} eq 'all') { - centreon::common::emc::navisphere::mode::spcomponents::fan::check($self); - centreon::common::emc::navisphere::mode::spcomponents::lcc::check($self); - centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); - centreon::common::emc::navisphere::mode::spcomponents::battery::check($self); - centreon::common::emc::navisphere::mode::spcomponents::cable::check($self); - centreon::common::emc::navisphere::mode::spcomponents::iomodule::check($self); - centreon::common::emc::navisphere::mode::spcomponents::memory::check($self); - centreon::common::emc::navisphere::mode::spcomponents::cpu::check($self); - centreon::common::emc::navisphere::mode::spcomponents::sp::check($self); - } elsif ($self->{option_results}->{component} eq 'sp') { - centreon::common::emc::navisphere::mode::spcomponents::sp::check($self); - } elsif ($self->{option_results}->{component} eq 'fan') { - centreon::common::emc::navisphere::mode::spcomponents::fan::check($self); - } elsif ($self->{option_results}->{component} eq 'lcc') { - centreon::common::emc::navisphere::mode::spcomponents::lcc::check($self); - } elsif ($self->{option_results}->{component} eq 'psu') { - centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); - } elsif ($self->{option_results}->{component} eq 'battery') { - centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); - } elsif ($self->{option_results}->{component} eq 'memory') { - centreon::common::emc::navisphere::mode::spcomponents::memory::check($self); - } elsif ($self->{option_results}->{component} eq 'cpu') { - centreon::common::emc::navisphere::mode::spcomponents::cpu::check($self); - } elsif ($self->{option_results}->{component} eq 'io') { - centreon::common::emc::navisphere::mode::spcomponents::iomodule::check($self); - } elsif ($self->{option_results}->{component} eq 'cable') { - centreon::common::emc::navisphere::mode::spcomponents::cable::check($self); - } else { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - 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}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components [%s] are ok.", - $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.'); - } -} - -sub run { - my ($self, %options) = @_; - my $clariion = $options{custom}; - - $self->{response} = $clariion->execute_command(cmd => 'getcrus ' . $self->{option_results}->{getcrus_options}); - chomp $self->{response}; - - $self->component(); - - $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; -} - -1; - -__END__ - -=head1 MODE - -Check status of storage processor. - -=over 8 - -=item B<--getcrus-options> - -Set option for 'getcrus' command (Default: '-all'). -'-all' option is for some new flare version. - -=item B<--component> - -Which component to check (Default: 'all'). -Can be: 'cpu', 'psu', 'pc', 'fan', 'network', 'temperature', 'storage', 'battery'. - -=item B<--exclude> - -Exclude some parts (comma seperated list) (Example: --exclude=fan,lcc) -Can also exclude specific instance: --exclude=fan#1.2#,lcc - -=item B<--no-component> - -Return an error if no compenents are checked. -If total (with skipped) is 0. (Default: 'critical' returns). - -=back - -=cut \ No newline at end of file +1; \ No newline at end of file diff --git a/centreon/common/emc/navisphere/mode/spcomponents/battery.pm b/centreon/common/emc/navisphere/mode/spcomponents/battery.pm index aade7195f..5bb257dd4 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/battery.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/battery.pm @@ -23,17 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::battery; use strict; use warnings; -my @conditions = ( - ['^(Not Ready|Testing|Unknown)$' => 'WARNING'], - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking batteries"); $self->{components}->{battery} = {name => 'battery', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'battery')); + return if ($self->check_filter(section => 'battery')); # SPS means = Standby Power Supply @@ -44,19 +41,17 @@ sub check { $instance = "$1.$2.$3.$4"; } - next if ($self->check_exclude(section => 'battery', instance => $instance)); + next if ($self->check_filter(section => 'battery', instance => $instance)); $self->{components}->{battery}->{total}++; $self->{output}->output_add(long_msg => sprintf("Battery '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("Battery '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'battery', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Battery '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon/common/emc/navisphere/mode/spcomponents/cable.pm b/centreon/common/emc/navisphere/mode/spcomponents/cable.pm index e67ffebac..73a475465 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/cable.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/cable.pm @@ -23,17 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::cable; use strict; use warnings; -my @conditions = ( - ['^(.*Unknown.*)$' => 'WARNING'], - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking cables"); $self->{components}->{cable} = {name => 'cables', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'cable')); + return if ($self->check_filter(section => 'cable')); # Enclosure SPE SPS A Cabling State: Valid while ($self->{response} =~ /^(?:Bus\s+(\d+)\s+){0,1}Enclosure\s+(\S+)\s+(Power|SPS)\s+(\S+)\s+Cabling\s+State:\s+(.*)$/mgi) { @@ -42,19 +39,17 @@ sub check { $instance = "$1.$2.$3.$4"; } - next if ($self->check_exclude(section => 'cable', instance => $instance)); + next if ($self->check_filter(section => 'cable', instance => $instance)); $self->{components}->{cable}->{total}++; $self->{output}->output_add(long_msg => sprintf("cable '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("cable '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'cable', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("cable '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm b/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm index 52083daf2..4874e3b7f 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::cpu; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking cpu"); $self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'cpu')); + return if ($self->check_filter(section => 'cpu')); # Enclosure SPE CPU Module A State: Present while ($self->{response} =~ /^Enclosure\s+(\S+)\s+CPU\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2"; my $state = $3; - next if ($self->check_exclude(section => 'cpu', instance => $instance)); + next if ($self->check_filter(section => 'cpu', instance => $instance)); $self->{components}->{cpu}->{total}++; $self->{output}->output_add(long_msg => sprintf("cpu '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("cpu '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'cpu', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("cpu '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon/common/emc/navisphere/mode/spcomponents/fan.pm b/centreon/common/emc/navisphere/mode/spcomponents/fan.pm index 5070bdcee..ea2598480 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/fan.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/fan.pm @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::fan; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $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')); # Bus 0 Enclosure 0 Fan A State: Present while ($self->{response} =~ /^Bus\s+(\d+)\s+Enclosure\s+(\d+)\s+Fan\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2.$3"; my $state = $4; - 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' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("fan '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'fan', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("fan '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm b/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm index 2590978bb..4a68e5e96 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::iomodule; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid|Empty)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking I/O modules"); $self->{components}->{io} = {name => 'IO module', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'io')); + return if ($self->check_filter(section => 'io')); # Enclosure SPE SP A I/O Module 0 State: Present while ($self->{response} =~ /^Enclosure\s+(\S+)\s+SP\s+(\S+)\s+I\/O\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2.$3"; my $state = $4; - next if ($self->check_exclude(section => 'io', instance => $instance)); + next if ($self->check_filter(section => 'io', instance => $instance)); $self->{components}->{io}->{total}++; $self->{output}->output_add(long_msg => sprintf("I/O module '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("I/O module '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'io', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("I/O module '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm b/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm index 1d114955c..71cc1b105 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::lcc; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking link control card"); $self->{components}->{lcc} = {name => 'lccs', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'lcc')); + return if ($self->check_filter(section => 'lcc')); # Bus 1 Enclosure 6 LCC A State: Present while ($self->{response} =~ /^Bus\s+(\d+)\s+Enclosure\s+(\d+)\s+LCC\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2.$3"; my $state = $4; - next if ($self->check_exclude(section => 'lcc', instance => $instance)); + next if ($self->check_filter(section => 'lcc', instance => $instance)); $self->{components}->{lcc}->{total}++; $self->{output}->output_add(long_msg => sprintf("lcc '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("lcc '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'lcc', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("lcc '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon/common/emc/navisphere/mode/spcomponents/memory.pm b/centreon/common/emc/navisphere/mode/spcomponents/memory.pm index 03af85d65..002bb0956 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/memory.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/memory.pm @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::memory; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking dimm"); $self->{components}->{dimm} = {name => 'dimm', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'dimm')); + return if ($self->check_filter(section => 'dimm')); # Enclosure SPE DIMM Module A State: Present while ($self->{response} =~ /^Enclosure\s+(\S+)\s+DIMM\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2"; my $state = $3; - next if ($self->check_exclude(section => 'dimm', instance => $instance)); + next if ($self->check_filter(section => 'dimm', instance => $instance)); $self->{components}->{dimm}->{total}++; $self->{output}->output_add(long_msg => sprintf("Dimm '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("Dimm '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'dimm', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("dimm '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon/common/emc/navisphere/mode/spcomponents/psu.pm b/centreon/common/emc/navisphere/mode/spcomponents/psu.pm index 86d13d2d4..b25687d83 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/psu.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/psu.pm @@ -23,16 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::psu; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $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')); # Enclosure SPE Power A0 State: Present # Bus 0 Enclosure 0 Power A State: Present @@ -42,19 +40,17 @@ sub check { $instance = "$1.$2.$3.$4"; } - 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' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("Power Supply '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'psu', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power Supply '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon/common/emc/navisphere/mode/spcomponents/sp.pm b/centreon/common/emc/navisphere/mode/spcomponents/sp.pm index 70a0d4f75..06eef859d 100644 --- a/centreon/common/emc/navisphere/mode/spcomponents/sp.pm +++ b/centreon/common/emc/navisphere/mode/spcomponents/sp.pm @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::sp; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking sp"); $self->{components}->{sp} = {name => 'sp', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'sp')); + return if ($self->check_filter(section => 'sp')); # SP A State: Present while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = $1; my $state = $2; - next if ($self->check_exclude(section => 'sp', instance => $instance)); + next if ($self->check_filter(section => 'sp', instance => $instance)); $self->{components}->{sp}->{total}++; $self->{output}->output_add(long_msg => sprintf("sp '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("sp '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'sp', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("sp '%s' state is %s", + $instance, $state)); } } } diff --git a/hardware/ups/apc/snmp/mode/batterystatus.pm b/hardware/ups/apc/snmp/mode/batterystatus.pm index 8b7db9daf..021ccf08f 100644 --- a/hardware/ups/apc/snmp/mode/batterystatus.pm +++ b/hardware/ups/apc/snmp/mode/batterystatus.pm @@ -204,7 +204,7 @@ sub manage_selection { my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_upsBasicBattery}, instance => '0'); my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_upsAdvBattery}, instance => '0'); - $result2->{upsAdvBatteryRunTimeRemaining} = $result2->{upsAdvBatteryRunTimeRemaining} / 100 / 60 if (defined($result2->{upsAdvBatteryRunTimeRemaining})); + $result2->{upsAdvBatteryRunTimeRemaining} = sprintf("%.0f", $result2->{upsAdvBatteryRunTimeRemaining} / 100 / 60) if (defined($result2->{upsAdvBatteryRunTimeRemaining})); foreach my $name (keys %{$mapping}) { $self->{global}->{$name} = $result->{$name}; diff --git a/os/solaris/local/mode/fmadm.pm b/os/solaris/local/mode/fmadm.pm index 020fe90e4..643a6a503 100644 --- a/os/solaris/local/mode/fmadm.pm +++ b/os/solaris/local/mode/fmadm.pm @@ -41,9 +41,9 @@ sub new { "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'luxadm' }, + "command:s" => { name => 'command', default => 'fmadm' }, "command-path:s" => { name => 'command_path', default => '/usr/sbin' }, - "command-options:s" => { name => 'command_options', default => '-e port 2>&1' }, + "command-options:s" => { name => 'command_options', default => 'faulty -r 2>&1' }, "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, }); diff --git a/storage/netapp/snmp/mode/components/temperature.pm b/storage/netapp/snmp/mode/components/temperature.pm index a2829f392..b30ac3b54 100644 --- a/storage/netapp/snmp/mode/components/temperature.pm +++ b/storage/netapp/snmp/mode/components/temperature.pm @@ -78,6 +78,8 @@ sub check { foreach my $num (split /,/, $result->{enclTempSensorsPresent}) { $num = centreon::plugins::misc::trim($num); next if ($num !~ /[0-9]/ || !defined($current_temp[$num - 1])); + + next if ($self->check_filter(section => 'temperature', instance => $shelf_addr . '.' . $num)); $warn_under_thr[$num - 1] =~ /(-*[0-9]+)C/; my $wu_thr = $1; @@ -90,7 +92,6 @@ sub check { $current_temp[$num - 1] =~ /(-*[0-9]+)C/; my $current_value = $1; - next if ($self->check_filter(section => 'temperature', instance => $shelf_addr . '.' . $num)); $self->{components}->{temperature}->{total}++; my $status = 'ok'; @@ -134,4 +135,4 @@ sub check { } } -1; \ No newline at end of file +1;