diff --git a/centreon-plugins/hardware/server/hpbladechassis/mode/hardware.pm b/centreon-plugins/hardware/server/hpbladechassis/mode/hardware.pm index 2442d70a7..91f8f79e4 100644 --- a/centreon-plugins/hardware/server/hpbladechassis/mode/hardware.pm +++ b/centreon-plugins/hardware/server/hpbladechassis/mode/hardware.pm @@ -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 = ''; @@ -94,9 +124,10 @@ sub run { $self->{output}->output_add(severity => 'OK', short_msg => sprintf("All %s components [%s] are ok.", - $total_components, - $display_by_component - )); + $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). diff --git a/centreon-plugins/hardware/server/hpproliant/mode/hardware.pm b/centreon-plugins/hardware/server/hpproliant/mode/hardware.pm index 6320607a0..49bbd461a 100644 --- a/centreon-plugins/hardware/server/hpproliant/mode/hardware.pm +++ b/centreon-plugins/hardware/server/hpproliant/mode/hardware.pm @@ -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,11 +76,9 @@ 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); hardware::server::hpproliant::mode::components::psu::check($self); @@ -120,10 +119,81 @@ sub run { $self->{output}->output_add(severity => 'OK', 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})); + $total_components, + $display_by_component, + $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).