This commit is contained in:
garnier-quentin 2016-08-03 10:54:17 +02:00
commit 29f8186bf0
15 changed files with 103 additions and 276 deletions

View File

@ -47,7 +47,6 @@ my %states = (
], ],
); );
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);

View File

@ -147,7 +147,7 @@ sub set_counters {
output_template => 'Utils : %.2f %%', output_use => 'utils', output_template => 'Utils : %.2f %%', output_use => 'utils',
perfdatas => [ perfdatas => [
{ label => 'utils', value => 'utils', template => '%.2f', { 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' },
], ],
} }
}, },

View File

@ -18,173 +18,38 @@
# limitations under the License. # limitations under the License.
# #
package centreon::common::emc::navisphere::mode::sp; package centreon::common::emc::navisphere::mode::spcomponents::sp;
use base qw(centreon::plugins::mode);
use strict; use strict;
use warnings; 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 { sub load { };
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0'; sub check {
$options{options}->add_options(arguments => my ($self) = @_;
{
"getcrus-options:s" => { name => 'getcrus_options', default => '-all' },
"exclude:s" => { name => 'exclude' },
"component:s" => { name => 'component', default => 'all' },
"no-component:s" => { name => 'no_component' },
});
$self->{components} = {}; $self->{output}->output_add(long_msg => "Checking sp");
$self->{no_components} = undef; $self->{components}->{sp} = {name => 'sp', total => 0, skip => 0};
return if ($self->check_filter(section => 'sp'));
return $self; # SP A State: Present
} while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) {
my $instance = $1;
my $state = $2;
sub check_options { next if ($self->check_filter(section => 'sp', instance => $instance));
my ($self, %options) = @_; $self->{components}->{sp}->{total}++;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{no_component})) { $self->{output}->output_add(long_msg => sprintf("sp '%s' state is %s.",
if ($self->{option_results}->{no_component} ne '') { $instance, $state)
$self->{no_components} = $self->{option_results}->{no_component};
} else {
$self->{no_components} = 'critical';
}
}
}
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)
); );
my $exit = $self->get_severity(section => 'sp', value => $state);
if (defined($self->{option_results}->{no_component}) && $total_components == 0) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $self->{no_components}, $self->{output}->output_add(severity => $exit,
short_msg => 'No components are checked.'); short_msg => sprintf("sp '%s' state is %s",
$instance, $state));
} }
} }
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; 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

View File

@ -23,17 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::battery;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(Not Ready|Testing|Unknown)$' => 'WARNING'],
['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking batteries"); $self->{output}->output_add(long_msg => "Checking batteries");
$self->{components}->{battery} = {name => 'battery', total => 0, skip => 0}; $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 # SPS means = Standby Power Supply
@ -44,19 +41,17 @@ sub check {
$instance = "$1.$2.$3.$4"; $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->{components}->{battery}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Battery '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("Battery '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'battery', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Battery '%s' state is %s", short_msg => sprintf("Battery '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -23,17 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::cable;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(.*Unknown.*)$' => 'WARNING'],
['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking cables"); $self->{output}->output_add(long_msg => "Checking cables");
$self->{components}->{cable} = {name => 'cables', total => 0, skip => 0}; $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 # 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) { 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"; $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->{components}->{cable}->{total}++;
$self->{output}->output_add(long_msg => sprintf("cable '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("cable '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'cable', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("cable '%s' state is %s", short_msg => sprintf("cable '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::cpu;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking cpu"); $self->{output}->output_add(long_msg => "Checking cpu");
$self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0}; $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 # Enclosure SPE CPU Module A State: Present
while ($self->{response} =~ /^Enclosure\s+(\S+)\s+CPU\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) { while ($self->{response} =~ /^Enclosure\s+(\S+)\s+CPU\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) {
my $instance = "$1.$2"; my $instance = "$1.$2";
my $state = $3; 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->{components}->{cpu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("cpu '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("cpu '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'cpu', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("cpu '%s' state is %s", short_msg => sprintf("cpu '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::fan;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans"); $self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; $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 # 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) { while ($self->{response} =~ /^Bus\s+(\d+)\s+Enclosure\s+(\d+)\s+Fan\s+(\S+)\s+State:\s+(.*)$/mgi) {
my $instance = "$1.$2.$3"; my $instance = "$1.$2.$3";
my $state = $4; 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->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("fan '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'fan', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' state is %s", short_msg => sprintf("fan '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::iomodule;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(?!(Present|Valid|Empty)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking I/O modules"); $self->{output}->output_add(long_msg => "Checking I/O modules");
$self->{components}->{io} = {name => 'IO module', total => 0, skip => 0}; $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 # 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) { 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 $instance = "$1.$2.$3";
my $state = $4; 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->{components}->{io}->{total}++;
$self->{output}->output_add(long_msg => sprintf("I/O module '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("I/O module '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'io', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("I/O module '%s' state is %s", short_msg => sprintf("I/O module '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::lcc;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking link control card"); $self->{output}->output_add(long_msg => "Checking link control card");
$self->{components}->{lcc} = {name => 'lccs', total => 0, skip => 0}; $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 # 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) { while ($self->{response} =~ /^Bus\s+(\d+)\s+Enclosure\s+(\d+)\s+LCC\s+(\S+)\s+State:\s+(.*)$/mgi) {
my $instance = "$1.$2.$3"; my $instance = "$1.$2.$3";
my $state = $4; 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->{components}->{lcc}->{total}++;
$self->{output}->output_add(long_msg => sprintf("lcc '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("lcc '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'lcc', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("lcc '%s' state is %s", short_msg => sprintf("lcc '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::memory;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking dimm"); $self->{output}->output_add(long_msg => "Checking dimm");
$self->{components}->{dimm} = {name => 'dimm', total => 0, skip => 0}; $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 # Enclosure SPE DIMM Module A State: Present
while ($self->{response} =~ /^Enclosure\s+(\S+)\s+DIMM\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) { while ($self->{response} =~ /^Enclosure\s+(\S+)\s+DIMM\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) {
my $instance = "$1.$2"; my $instance = "$1.$2";
my $state = $3; 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->{components}->{dimm}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Dimm '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("Dimm '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'dimm', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Dimm '%s' state is %s", short_msg => sprintf("dimm '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -23,16 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::psu;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies"); $self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; $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 # Enclosure SPE Power A0 State: Present
# Bus 0 Enclosure 0 Power A State: Present # Bus 0 Enclosure 0 Power A State: Present
@ -42,19 +40,17 @@ sub check {
$instance = "$1.$2.$3.$4"; $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->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("Power Supply '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'psu', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power Supply '%s' state is %s", short_msg => sprintf("Power Supply '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::sp;
use strict; use strict;
use warnings; use warnings;
my @conditions = ( sub load { };
['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking sp"); $self->{output}->output_add(long_msg => "Checking sp");
$self->{components}->{sp} = {name => 'sp', total => 0, skip => 0}; $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 # SP A State: Present
while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) { while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) {
my $instance = $1; my $instance = $1;
my $state = $2; 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->{components}->{sp}->{total}++;
$self->{output}->output_add(long_msg => sprintf("sp '%s' state is %s.", $self->{output}->output_add(long_msg => sprintf("sp '%s' state is %s.",
$instance, $state) $instance, $state)
); );
foreach (@conditions) { my $exit = $self->get_severity(section => 'sp', value => $state);
if ($state =~ /$$_[0]/i) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $$_[1], $self->{output}->output_add(severity => $exit,
short_msg => sprintf("sp '%s' state is %s", short_msg => sprintf("sp '%s' state is %s",
$instance, $state)); $instance, $state));
last;
}
} }
} }
} }

View File

@ -204,7 +204,7 @@ sub manage_selection {
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_upsBasicBattery}, instance => '0'); 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'); 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}) { foreach my $name (keys %{$mapping}) {
$self->{global}->{$name} = $result->{$name}; $self->{global}->{$name} = $result->{$name};

View File

@ -41,9 +41,9 @@ sub new {
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 }, "timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' }, "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-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', }, "warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', }, "critical:s" => { name => 'critical', },
}); });

View File

@ -79,6 +79,8 @@ sub check {
$num = centreon::plugins::misc::trim($num); $num = centreon::plugins::misc::trim($num);
next if ($num !~ /[0-9]/ || !defined($current_temp[$num - 1])); 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/; $warn_under_thr[$num - 1] =~ /(-*[0-9]+)C/;
my $wu_thr = $1; my $wu_thr = $1;
$crit_under_thr[$num - 1] =~ /(-*[0-9]+)C/; $crit_under_thr[$num - 1] =~ /(-*[0-9]+)C/;
@ -90,7 +92,6 @@ sub check {
$current_temp[$num - 1] =~ /(-*[0-9]+)C/; $current_temp[$num - 1] =~ /(-*[0-9]+)C/;
my $current_value = $1; my $current_value = $1;
next if ($self->check_filter(section => 'temperature', instance => $shelf_addr . '.' . $num));
$self->{components}->{temperature}->{total}++; $self->{components}->{temperature}->{total}++;
my $status = 'ok'; my $status = 'ok';