+ Refactor HP server directory (for ilo)

+ Correct local 'vx-disks'
This commit is contained in:
garnier-quentin 2014-10-05 17:37:48 +02:00
parent 4ea13ffaf9
commit f3f3689c58
24 changed files with 163 additions and 137 deletions

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::components::blade;
package hardware::server::hp::bladechassis::snmp::mode::components::blade;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::components::enclosure;
package hardware::server::hp::bladechassis::snmp::mode::components::enclosure;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::components::fan;
package hardware::server::hp::bladechassis::snmp::mode::components::fan;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::components::fuse;
package hardware::server::hp::bladechassis::snmp::mode::components::fuse;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::components::manager;
package hardware::server::hp::bladechassis::snmp::mode::components::manager;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::components::network;
package hardware::server::hp::bladechassis::snmp::mode::components::network;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::components::psu;
package hardware::server::hp::bladechassis::snmp::mode::components::psu;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::components::temperature;
package hardware::server::hp::bladechassis::snmp::mode::components::temperature;
use strict;
use warnings;

View File

@ -33,20 +33,20 @@
#
####################################################################################
package hardware::server::hpbladechassis::mode::hardware;
package hardware::server::hp::bladechassis::snmp::mode::hardware;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use hardware::server::hpbladechassis::mode::components::enclosure;
use hardware::server::hpbladechassis::mode::components::manager;
use hardware::server::hpbladechassis::mode::components::fan;
use hardware::server::hpbladechassis::mode::components::blade;
use hardware::server::hpbladechassis::mode::components::network;
use hardware::server::hpbladechassis::mode::components::psu;
use hardware::server::hpbladechassis::mode::components::temperature;
use hardware::server::hpbladechassis::mode::components::fuse;
use hardware::server::hp::bladechassis::snmp::mode::components::enclosure;
use hardware::server::hp::bladechassis::snmp::mode::components::manager;
use hardware::server::hp::bladechassis::snmp::mode::components::fan;
use hardware::server::hp::bladechassis::snmp::mode::components::blade;
use hardware::server::hp::bladechassis::snmp::mode::components::network;
use hardware::server::hp::bladechassis::snmp::mode::components::psu;
use hardware::server::hp::bladechassis::snmp::mode::components::temperature;
use hardware::server::hp::bladechassis::snmp::mode::components::fuse;
sub new {
my ($class, %options) = @_;
@ -71,14 +71,14 @@ sub check_options {
sub global {
my ($self, %options) = @_;
hardware::server::hpbladechassis::mode::components::enclosure::check($self);
hardware::server::hpbladechassis::mode::components::manager::check($self);
hardware::server::hpbladechassis::mode::components::fan::check($self);
hardware::server::hpbladechassis::mode::components::blade::check($self);
hardware::server::hpbladechassis::mode::components::network::check($self);
hardware::server::hpbladechassis::mode::components::psu::check($self);
hardware::server::hpbladechassis::mode::components::temperature::check($self);
hardware::server::hpbladechassis::mode::components::fuse::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::enclosure::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::manager::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::fan::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::blade::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::network::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::psu::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::temperature::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::fuse::check($self);
}
sub run {
@ -89,21 +89,21 @@ sub run {
if ($self->{option_results}->{component} eq 'all') {
$self->global();
} elsif ($self->{option_results}->{component} eq 'enclosure') {
hardware::server::hpbladechassis::mode::components::enclosure::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::enclosure::check($self);
} elsif ($self->{option_results}->{component} eq 'manager') {
hardware::server::hpbladechassis::mode::components::manager::check($self, force => 1);
hardware::server::hp::bladechassis::snmp::mode::components::manager::check($self, force => 1);
} elsif ($self->{option_results}->{component} eq 'fan') {
hardware::server::hpbladechassis::mode::components::fan::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'blade') {
hardware::server::hpbladechassis::mode::components::blade::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::blade::check($self);
} elsif ($self->{option_results}->{component} eq 'network') {
hardware::server::hpbladechassis::mode::components::network::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::network::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
hardware::server::hpbladechassis::mode::components::psu::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'temperature') {
hardware::server::hpbladechassis::mode::components::temperature::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::temperature::check($self);
} elsif ($self->{option_results}->{component} eq 'fuse') {
hardware::server::hpbladechassis::mode::components::fuse::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::fuse::check($self);
} else {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpbladechassis::plugin;
package hardware::server::hp::bladechassis::snmp::plugin;
use strict;
use warnings;
@ -47,7 +47,7 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'hardware' => 'hardware::server::hpbladechassis::mode::hardware',
'hardware' => 'hardware::server::hp::bladechassis::snmp::mode::hardware',
);
return $self;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::cpu;
package hardware::server::hp::proliant::snmp::mode::components::cpu;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::fan;
package hardware::server::hp::proliant::snmp::mode::components::fan;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::fca;
package hardware::server::hp::proliant::snmp::mode::components::fca;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::ida;
package hardware::server::hp::proliant::snmp::mode::components::ida;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::ide;
package hardware::server::hp::proliant::snmp::mode::components::ide;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::network;
package hardware::server::hp::proliant::snmp::mode::components::network;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::pc;
package hardware::server::hp::proliant::snmp::mode::components::pc;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::psu;
package hardware::server::hp::proliant::snmp::mode::components::psu;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::sas;
package hardware::server::hp::proliant::snmp::mode::components::sas;
use strict;
use warnings;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::scsi;
package hardware::server::hp::proliant::snmp::mode::components::scsi;
# In 'CPQSCSI-MIB.mib'
use strict;

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::mode::components::temperature;
package hardware::server::hp::proliant::snmp::mode::components::temperature;
use strict;
use warnings;

View File

@ -33,24 +33,24 @@
#
####################################################################################
package hardware::server::hpproliant::mode::hardware;
package hardware::server::hp::proliant::snmp::mode::hardware;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
use hardware::server::hpproliant::mode::components::cpu;
use hardware::server::hpproliant::mode::components::psu;
use hardware::server::hpproliant::mode::components::pc;
use hardware::server::hpproliant::mode::components::fan;
use hardware::server::hpproliant::mode::components::temperature;
use hardware::server::hpproliant::mode::components::network;
use hardware::server::hpproliant::mode::components::ida;
use hardware::server::hpproliant::mode::components::fca;
use hardware::server::hpproliant::mode::components::ide;
use hardware::server::hpproliant::mode::components::sas;
use hardware::server::hpproliant::mode::components::scsi;
use hardware::server::hp::proliant::snmp::mode::components::cpu;
use hardware::server::hp::proliant::snmp::mode::components::psu;
use hardware::server::hp::proliant::snmp::mode::components::pc;
use hardware::server::hp::proliant::snmp::mode::components::fan;
use hardware::server::hp::proliant::snmp::mode::components::temperature;
use hardware::server::hp::proliant::snmp::mode::components::network;
use hardware::server::hp::proliant::snmp::mode::components::ida;
use hardware::server::hp::proliant::snmp::mode::components::fca;
use hardware::server::hp::proliant::snmp::mode::components::ide;
use hardware::server::hp::proliant::snmp::mode::components::sas;
use hardware::server::hp::proliant::snmp::mode::components::scsi;
sub new {
my ($class, %options) = @_;
@ -92,31 +92,31 @@ sub global {
my ($self, %options) = @_;
$self->get_system_information();
hardware::server::hpproliant::mode::components::cpu::check($self);
hardware::server::hpproliant::mode::components::psu::check($self);
hardware::server::hpproliant::mode::components::pc::check($self);
hardware::server::hpproliant::mode::components::fan::check($self);
hardware::server::hpproliant::mode::components::temperature::check($self);
hardware::server::hpproliant::mode::components::network::physical_nic($self);
hardware::server::hpproliant::mode::components::network::logical_nic($self);
hardware::server::hpproliant::mode::components::ida::array_controller($self);
hardware::server::hpproliant::mode::components::ida::array_accelerator($self);
hardware::server::hpproliant::mode::components::ida::logical_drive($self);
hardware::server::hpproliant::mode::components::ida::physical_drive($self);
hardware::server::hpproliant::mode::components::fca::host_array_controller($self);
hardware::server::hpproliant::mode::components::fca::external_array_controller($self);
hardware::server::hpproliant::mode::components::fca::external_array_accelerator($self);
hardware::server::hpproliant::mode::components::fca::logical_drive($self);
hardware::server::hpproliant::mode::components::fca::physical_drive($self);
hardware::server::hpproliant::mode::components::ide::controller($self);
hardware::server::hpproliant::mode::components::ide::logical_drive($self);
hardware::server::hpproliant::mode::components::ide::physical_drive($self);
hardware::server::hpproliant::mode::components::sas::controller($self);
hardware::server::hpproliant::mode::components::sas::logical_drive($self);
hardware::server::hpproliant::mode::components::sas::physical_drive($self);
hardware::server::hpproliant::mode::components::scsi::controller($self);
hardware::server::hpproliant::mode::components::scsi::logical_drive($self);
hardware::server::hpproliant::mode::components::scsi::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::cpu::check($self);
hardware::server::hp::proliant::snmp::mode::components::psu::check($self);
hardware::server::hp::proliant::snmp::mode::components::pc::check($self);
hardware::server::hp::proliant::snmp::mode::components::fan::check($self);
hardware::server::hp::proliant::snmp::mode::components::temperature::check($self);
hardware::server::hp::proliant::snmp::mode::components::network::physical_nic($self);
hardware::server::hp::proliant::snmp::mode::components::network::logical_nic($self);
hardware::server::hp::proliant::snmp::mode::components::ida::array_controller($self);
hardware::server::hp::proliant::snmp::mode::components::ida::array_accelerator($self);
hardware::server::hp::proliant::snmp::mode::components::ida::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::ida::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::fca::host_array_controller($self);
hardware::server::hp::proliant::snmp::mode::components::fca::external_array_controller($self);
hardware::server::hp::proliant::snmp::mode::components::fca::external_array_accelerator($self);
hardware::server::hp::proliant::snmp::mode::components::fca::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::fca::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::ide::controller($self);
hardware::server::hp::proliant::snmp::mode::components::ide::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::ide::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::sas::controller($self);
hardware::server::hp::proliant::snmp::mode::components::sas::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::sas::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::scsi::controller($self);
hardware::server::hp::proliant::snmp::mode::components::scsi::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::scsi::physical_drive($self);
my $total_components = 0;
my $display_by_component = '';
@ -146,37 +146,37 @@ sub component {
my ($self, %options) = @_;
if ($self->{option_results}->{component} eq 'cpu') {
hardware::server::hpproliant::mode::components::cpu::check($self);
hardware::server::hp::proliant::snmp::mode::components::cpu::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
hardware::server::hpproliant::mode::components::psu::check($self);
hardware::server::hp::proliant::snmp::mode::components::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'pc') {
hardware::server::hpproliant::mode::components::pc::check($self);
hardware::server::hp::proliant::snmp::mode::components::pc::check($self);
} elsif ($self->{option_results}->{component} eq 'fan') {
hardware::server::hpproliant::mode::components::fan::check($self);
hardware::server::hp::proliant::snmp::mode::components::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'temperature') {
hardware::server::hpproliant::mode::components::temperature::check($self);
hardware::server::hp::proliant::snmp::mode::components::temperature::check($self);
} elsif ($self->{option_results}->{component} eq 'network') {
hardware::server::hpproliant::mode::components::network::physical_nic($self);
hardware::server::hpproliant::mode::components::network::logical_nic($self);
hardware::server::hp::proliant::snmp::mode::components::network::physical_nic($self);
hardware::server::hp::proliant::snmp::mode::components::network::logical_nic($self);
} elsif ($self->{option_results}->{component} eq 'storage') {
hardware::server::hpproliant::mode::components::ida::array_controller($self);
hardware::server::hpproliant::mode::components::ida::array_accelerator($self);
hardware::server::hpproliant::mode::components::ida::logical_drive($self);
hardware::server::hpproliant::mode::components::ida::physical_drive($self);
hardware::server::hpproliant::mode::components::fca::host_array_controller($self);
hardware::server::hpproliant::mode::components::fca::external_array_controller($self);
hardware::server::hpproliant::mode::components::fca::external_array_accelerator($self);
hardware::server::hpproliant::mode::components::fca::logical_drive($self);
hardware::server::hpproliant::mode::components::fca::physical_drive($self);
hardware::server::hpproliant::mode::components::ide::controller($self);
hardware::server::hpproliant::mode::components::ide::logical_drive($self);
hardware::server::hpproliant::mode::components::ide::physical_drive($self);
hardware::server::hpproliant::mode::components::sas::controller($self);
hardware::server::hpproliant::mode::components::sas::logical_drive($self);
hardware::server::hpproliant::mode::components::sas::physical_drive($self);
hardware::server::hpproliant::mode::components::scsi::controller($self);
hardware::server::hpproliant::mode::components::scsi::logical_drive($self);
hardware::server::hpproliant::mode::components::scsi::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::ida::array_controller($self);
hardware::server::hp::proliant::snmp::mode::components::ida::array_accelerator($self);
hardware::server::hp::proliant::snmp::mode::components::ida::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::ida::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::fca::host_array_controller($self);
hardware::server::hp::proliant::snmp::mode::components::fca::external_array_controller($self);
hardware::server::hp::proliant::snmp::mode::components::fca::external_array_accelerator($self);
hardware::server::hp::proliant::snmp::mode::components::fca::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::fca::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::ide::controller($self);
hardware::server::hp::proliant::snmp::mode::components::ide::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::ide::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::sas::controller($self);
hardware::server::hp::proliant::snmp::mode::components::sas::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::sas::physical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::scsi::controller($self);
hardware::server::hp::proliant::snmp::mode::components::scsi::logical_drive($self);
hardware::server::hp::proliant::snmp::mode::components::scsi::physical_drive($self);
} else {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::server::hpproliant::plugin;
package hardware::server::hp::proliant::snmp::plugin;
use strict;
use warnings;
@ -47,7 +47,7 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'hardware' => 'hardware::server::hpproliant::mode::hardware',
'hardware' => 'hardware::server::hp::proliant::snmp::mode::hardware',
);
return $self;

View File

@ -59,12 +59,14 @@ sub new {
"command1:s" => { name => 'command1', default => 'vxdisk' },
"command1-path:s" => { name => 'command1_path', default => '/usr/sbin' },
"command1-options:s" => { name => 'command1_options', default => 'list 2>&1' },
"skip-vxdisk" => { name => 'skip_vxdisk' },
"sudo2" => { name => 'sudo2' },
"command2:s" => { name => 'command2', default => 'vxprint' },
"command2-path:s" => { name => 'command2_path', default => '/usr/sbin' },
"command2-options:s" => { name => 'command2_options', default => '-Ath 2>&1' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
"skip-vxprint" => { name => 'skip_vxprint' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
return $self;
}
@ -83,9 +85,9 @@ sub check_options {
}
}
sub run {
sub vdisk_execute {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo1},
@ -95,43 +97,58 @@ sub run {
my $long_msg = $stdout;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
my $stdout2 = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo2},
command => $self->{option_results}->{command2},
command_path => $self->{option_results}->{command2_path},
command_options => $self->{option_results}->{command2_options});
$long_msg = $stdout2;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
my $num_errors = 0;
my $vxdisks_name = '';
foreach (split /\n/, $stdout) {
if (/(failed)/i ) {
my $status = $1;
next if (! /\S+\s+\S+\s+(\S+)\s+/);
$num_errors++;
$vxdisks_name .= ' [' . $1 . '/' . $status . ']';
$self->{num_errors}++;
$self->{vxdisks_name} .= ' [' . $1 . '/' . $status . ']';
}
}
}
sub vxprint_execute {
my ($self, %options) = @_;
my $vxprint_name = '';
foreach (split /\n/, $stdout2) {
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo2},
command => $self->{option_results}->{command2},
command_path => $self->{option_results}->{command2_path},
command_options => $self->{option_results}->{command2_options});
my $long_msg = $stdout;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
foreach (split /\n/, $stdout) {
if (/(NODEVICE|FAILING)/i ) {
my $status = $1;
next if (! /\S+\s+(\S+)\s+/);
$num_errors++;
$vxprint_name .= ' [' . $1 . '/' . $status . ']';
next if (! /^\s*\S+\s+(\S+)\s+/);
$self->{num_errors}++;
$self->{vxprint_name} .= ' [' . $1 . '/' . $status . ']';
}
}
}
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_errors,
sub run {
my ($self, %options) = @_;
$self->{num_errors} = 0;
$self->{vxdisks_name} = '';
$self->{vxprint_name} = '';
if (!defined($self->{option_results}->{skip_vxdisk})) {
$self->vdisk_execute();
}
if (!defined($self->{option_results}->{skip_vxprint})) {
$self->vxprint_execute();
}
my ($exit_code) = $self->{perfdata}->threshold_check(value => $self->{num_errors},
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if ($num_errors > 0) {
if ($self->{num_errors} > 0) {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Problems on some disks:" . $vxdisks_name . $vxdisks_name));
short_msg => sprintf("Problems on some disks:" . $self->{vxdisks_name} . $self->{vxprint_name}));
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on disks.");
@ -217,6 +234,15 @@ Command path (Default: '/usr/sbin').
Command options (Default: '-Ath 2>&1').
=item B<--skip-vxdisk>
Skip 'vxdisk' command (not executed).
=item B<--skip-vxprint>
Skip 'vxprint' command (not executed).
=back
=cut