This commit is contained in:
garnier-quentin 2014-02-02 22:31:38 +01:00
parent 66363fbadf
commit 0b19e0d8a8
2 changed files with 124 additions and 13 deletions

View File

@ -57,6 +57,7 @@ sub new {
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude' },
"component:s" => { name => 'component', default => 'all' },
});
$self->{components} = {};
return $self;
@ -67,10 +68,8 @@ sub check_options {
$self->SUPER::init(%options);
}
sub run {
sub global {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
hardware::server::hpbladechassis::mode::components::enclosure::check($self);
hardware::server::hpbladechassis::mode::components::manager::check($self);
@ -80,6 +79,37 @@ sub run {
hardware::server::hpbladechassis::mode::components::psu::check($self);
hardware::server::hpbladechassis::mode::components::temperature::check($self);
hardware::server::hpbladechassis::mode::components::fuse::check($self);
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
'enclosure', 'manager', 'fan', 'blade', 'network', 'psu', 'temperature', 'fuse'
if ($self->{option_results}->{component} eq 'all') {
$self->global();
} elsif ($self->{option_results}->{component} eq 'enclosure') {
hardware::server::hpbladechassis::mode::components::enclosure::check($self);
} elsif ($self->{option_results}->{component} eq 'manager') {
hardware::server::hpbladechassis::mode::components::manager::check($self, force => 1);
} elsif ($self->{option_results}->{component} eq 'fan') {
hardware::server::hpbladechassis::mode::components::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'blade') {
hardware::server::hpbladechassis::mode::components::blade::check($self);
} elsif ($self->{option_results}->{component} eq 'network') {
hardware::server::hpbladechassis::mode::components::network::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
hardware::server::hpbladechassis::mode::components::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'temperature') {
hardware::server::hpbladechassis::mode::components::temperature::check($self);
} elsif ($self->{option_results}->{component} eq 'fuse') {
hardware::server::hpbladechassis::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();
}
my $total_components = 0;
my $display_by_component = '';
@ -96,7 +126,8 @@ sub run {
short_msg => sprintf("All %s components [%s] are ok.",
$total_components,
$display_by_component
));
)
);
$self->{output}->display();
$self->{output}->exit();
@ -122,6 +153,11 @@ Check Hardware (Fans, Power Supplies, Blades, Temperatures, Fuses).
=over 8
=item B<--component>
Which component to check (Default: 'all').
Can be: 'enclosure', 'manager', 'fan', 'blade', 'network', 'psu', 'temperature', 'fuse'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=temperatures,psu).

View File

@ -61,6 +61,7 @@ sub new {
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude' },
"component:s" => { name => 'component', default => 'all' },
});
$self->{product_name} = undef;
@ -75,10 +76,8 @@ sub check_options {
$self->SUPER::init(%options);
}
sub run {
sub global {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->get_system_information();
hardware::server::hpproliant::mode::components::cpu::check($self);
@ -122,7 +121,78 @@ sub run {
short_msg => sprintf("All %s components [%s] are ok - Product Name: %s, Serial: %s, Rom Version: %s",
$total_components,
$display_by_component,
$self->{product_name}, $self->{serial}, $self->{romversion}));
$self->{product_name}, $self->{serial}, $self->{romversion})
);
}
sub component {
my ($self, %options) = @_;
if ($self->{option_results}->{component} eq 'cpu') {
hardware::server::hpproliant::mode::components::cpu::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
hardware::server::hpproliant::mode::components::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'pc') {
hardware::server::hpproliant::mode::components::pc::check($self);
} elsif ($self->{option_results}->{component} eq 'fan') {
hardware::server::hpproliant::mode::components::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'temperature') {
hardware::server::hpproliant::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);
} 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);
} 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);
$total_components += $self->{components}->{$comp}->{total};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $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)
);
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
if ($self->{option_results}->{component} eq 'all') {
$self->global();
} else {
$self->component();
}
$self->{output}->display();
$self->{output}->exit();
@ -163,6 +233,11 @@ Check Hardware (CPUs, Power Supplies, Power converters, Fans).
=over 8
=item B<--component>
Which component to check (Default: 'all').
Can be: 'cpu', 'psu', 'pc', 'fan', 'network', 'temperature', 'storage'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=psu,pc).