diff --git a/hardware/server/huawei/hmm/snmp/mode/blade.pm b/hardware/server/huawei/hmm/snmp/mode/blade.pm new file mode 100644 index 000000000..6c4ecb8c2 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/blade.pm @@ -0,0 +1,130 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package hardware::server::huawei::hmm::snmp::mode::blade; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(cpu|temperature)$'; + $self->{regexp_threshold_overload_check_section_option} = '^(cpu|disk|memory|mezz|raidcontroller)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + 'default' => [ + ['normal', 'OK'], + ['minor', 'WARNING'], + ['major', 'CRITICAL'], + ['critical', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::server::huawei::hmm::snmp::mode::components'; + $self->{components_module} = ['cpu', 'disk', 'memory', 'mezz', 'raidcontroller', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +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 => + { + "blade-id:s" => { name => 'blade_id' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (!defined($self->{option_results}->{blade_id}) || $self->{option_results}->{blade_id} eq '') { + $self->{output}->add_option_msg(short_msg => "Please set --blade-id option."); + $self->{output}->option_exit(); + } + + $self->{blade_id} = $self->{option_results}->{blade_id}; +} + +1; + +__END__ + +=head1 MODE + +Check blade components. + +=over 8 + +=item B<--blade-id> + +Set blade ID. + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'cpu', 'disk', 'memory', 'mezz', 'raidcontroller', 'temperature'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=cpu) +Can also exclude specific instance: --filter=cpu,1 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='cpu,CRITICAL,^(?!(ok)$)' + +=item B<--warning> + +Set warning threshold (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + +=back + +=cut + diff --git a/hardware/server/huawei/hmm/snmp/mode/chassis.pm b/hardware/server/huawei/hmm/snmp/mode/chassis.pm new file mode 100644 index 000000000..da7d510ea --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/chassis.pm @@ -0,0 +1,102 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package hardware::server::huawei::hmm::snmp::mode::chassis; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(blade|fan|psu|switch)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + 'default' => [ + ['normal', 'OK'], + ['minor', 'WARNING'], + ['major', 'CRITICAL'], + ['critical', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::server::huawei::hmm::snmp::mode::components'; + $self->{components_module} = ['blade', 'fan', 'psu', 'switch']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +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 => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check chassis components. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'blade', 'fan', 'psu', 'switch'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=psu,1 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='psu,CRITICAL,^(?!(ok)$)' + +=back + +=cut + diff --git a/hardware/server/huawei/hmm/snmp/mode/components/blade.pm b/hardware/server/huawei/hmm/snmp/mode/components/blade.pm index bc4e4470a..74d986d45 100644 --- a/hardware/server/huawei/hmm/snmp/mode/components/blade.pm +++ b/hardware/server/huawei/hmm/snmp/mode/components/blade.pm @@ -1,51 +1,72 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + package hardware::server::huawei::hmm::snmp::mode::components::blade; use strict; use warnings; -sub check { +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my $mapping = { + mBladeLocation => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1.2' }, + mBladeHealth => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1.3', map => \%map_status }, +}; +my $oid_bladeManagementEntry = '.1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1'; + +sub load { my ($self) = @_; - my %statusHash = ("0"=>"ok","1"=>"warning","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); - my %eachStatus = ("0"=>"ok","1"=>"minor","2"=>"major","3"=>"major","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); - - my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; - my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.8.0", $self->{option_results}->{bladeNum}; - my $componentTemperatureOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2012.1.2.1", $self->{option_results}->{bladeNum}; - my $tmpShortMessage = ""; - my $tmpSeverity = "unknown"; - - my $result= $self->{snmp}->get_leef(oids =>[$componentPresentOid]); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."Get blade info error."; - }else - { - if ($result->{$componentPresentOid} eq "0") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$componentPresentOid} eq "2") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$componentPresentOid} eq "1") - { - $result= $self->{snmp}->get_leef(oids =>[$componentStatusOid]); - $tmpSeverity = $statusHash{$result->{$componentStatusOid}}; - $tmpShortMessage = $tmpShortMessage. "Blade".$self->{option_results}->{bladeNum}.":".$eachStatus{$result->{$componentStatusOid}}; - $result = $self->{snmp}->get_leef(oids =>[$componentTemperatureOid] ); - $tmpShortMessage = $tmpShortMessage." Temperature:".$result->{$componentTemperatureOid}."℃"; - }else - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; - } - } - - $self->{output}->output_add(severity => $tmpSeverity, - short_msg => $tmpShortMessage); - $self->{output}->display(); - $self->{output}->exit(); + push @{$self->{request}}, { oid => $oid_bladeManagementEntry }; } -1; - - \ No newline at end of file +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking blades"); + $self->{components}->{blade} = {name => 'blades', total => 0, skip => 0}; + return if ($self->check_filter(section => 'blade')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeManagementEntry}})) { + next if ($oid !~ /^$mapping->{mBladeHealth}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeManagementEntry}, instance => $instance); + + next if ($self->check_filter(section => 'blade', instance => $instance)); + $self->{components}->{blade}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Blade '%s' status is '%s' [instance = %s]", + $result->{mBladeLocation}, $result->{mBladeHealth}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'blade', value => $result->{mBladeHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Blade '%s' status is '%s'", $result->{mBladeLocation}, $result->{mBladeHealth})); + } + } +} + +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/cpu.pm b/hardware/server/huawei/hmm/snmp/mode/components/cpu.pm index 07aa2acfa..8abf9f560 100644 --- a/hardware/server/huawei/hmm/snmp/mode/components/cpu.pm +++ b/hardware/server/huawei/hmm/snmp/mode/components/cpu.pm @@ -1,101 +1,101 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + package hardware::server::huawei::hmm::snmp::mode::components::cpu; use strict; use warnings; +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my %map_installation_status = ( + 0 => 'absence', + 1 => 'presence', + 2 => 'poweroff', +); + +my $mapping = { + bladeCPUMark => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2006.1.2' }, + bladeCPUPresent => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2006.1.4', map => \%map_installation_status }, + bladeCPUHealth => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2006.1.5', map => \%map_status }, + bladeCPUTemperature => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2006.1.7' }, +}; +my $oid_bladeCPUTable = '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2006.1'; + +sub load { + my ($self) = @_; + + $oid_bladeCPUTable =~ s/#/$self->{blade_id}/; + push @{$self->{request}}, { oid => $oid_bladeCPUTable }; +} + sub check { my ($self) = @_; - - my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown"); - my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"unknown"); - - my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; - - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - - my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."Get blade info error."; - }else - { - if ($result->{$bladePresentOid} eq "0") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "2") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "1") - { - my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2006.1.4", $self->{option_results}->{bladeNum}; - my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2006.1.5", $self->{option_results}->{bladeNum}; - my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2006.1.2", $self->{option_results}->{bladeNum}; - - $self->{snmp}->{snmp_force_getnext} = 1; - my $result = $self->{snmp}->get_table(oid => $componentPresentOid); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."No cpu presence."; - }else - { - my $endKey; - my $temnameOid; - my $statusOid; - my $tmpMsg; - my $tmpresult; - my $totalPresent = 0; - my $totalComponent = 0; - my $v; - foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) - { - $v = $result->{$k}; - $endKey = "0"; - $temnameOid = ""; - $statusOid = ""; - $tmpMsg = ""; - $totalComponent++; - if ($v eq "1") # presence status: 0-not presence,1-presence - { - $totalPresent++; - $k =~ /\.([0-9]+)$/; - $endKey = $1; - $temnameOid = $componentMarkOid.".".$endKey; - $statusOid = $componentStatusOid.".".$endKey; - $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); - - $tmpMsg = $tmpresult->{$temnameOid}.":"; - $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); - $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; - $tmpShortMessage = $tmpShortMessage.$tmpMsg; - if($statusHash{$tmpresult->{$statusOid}} eq "critical") - { - $componentStatus = "critical"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) - { - $componentStatus = "warning"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") - { - if ($componentStatus eq "unknown") - { - $componentStatus = "ok"; - } - } - } - } - $tmpShortMessage = "cpuPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + + foreach my $entry (keys $mapping) { + $mapping->{$entry}->{oid} =~ s/#/$self->{blade_id}/; + } + + $self->{output}->output_add(long_msg => "Checking CPUs"); + $self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0}; + return if ($self->check_filter(section => 'cpu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeCPUTable}})) { + next if ($oid !~ /^$mapping->{bladeCPUHealth}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeCPUTable}, instance => $instance); + + next if ($self->check_filter(section => 'cpu', instance => $instance)); + next if ($result->{bladeCPUPresent} !~ /presence/); + $self->{components}->{cpu}->{total}++; + + if (defined($result->{bladeCPUTemperature}) && $result->{bladeCPUTemperature} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'cpu', instance => $instance, value => $result->{bladeCPUTemperature}); + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cpu '%s' temperature is %s celsius degrees", $result->{bladeCPUMark}, $result->{bladeCPUTemperature})); } - }else - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + $self->{output}->perfdata_add(label => 'temperature_' . $result->{bladeCPUMark}, unit => 'C', + value => $result->{bladeCPUTemperature}, + warning => $warn, + critical => $crit, + min => 0 + ); } + $self->{output}->output_add(long_msg => sprintf("Cpu '%s' status is '%s' [instance = %s]", + $result->{bladeCPUMark}, $result->{bladeCPUHealth}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'Cpu', value => $result->{bladeCPUHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cpu '%s' status is '%s'", $result->{bladeCPUMark}, $result->{bladeCPUHealth})); + } } - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage ); - - $self->{output}->display(); - $self->{output}->exit(); } + 1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/disk.pm b/hardware/server/huawei/hmm/snmp/mode/components/disk.pm index 75744e5d6..95fb2047a 100644 --- a/hardware/server/huawei/hmm/snmp/mode/components/disk.pm +++ b/hardware/server/huawei/hmm/snmp/mode/components/disk.pm @@ -1,100 +1,85 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + package hardware::server::huawei::hmm::snmp::mode::components::disk; use strict; use warnings; +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my %map_installation_status = ( + 0 => 'absence', + 1 => 'presence', + 2 => 'poweroff', +); + +my $mapping = { + bladeDiskMark => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2009.1.2' }, + bladeDiskPresent => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2009.1.4', map => \%map_installation_status }, + bladeDiskHealth => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2009.1.5', map => \%map_status }, +}; +my $oid_bladeDiskTable = '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2009.1'; + +sub load { + my ($self) = @_; + + $oid_bladeDiskTable =~ s/#/$self->{blade_id}/; + push @{$self->{request}}, { oid => $oid_bladeDiskTable }; +} + sub check { my ($self) = @_; - - my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown"); - my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"unknown"); - - my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; - - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - - my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."Get blade info error."; - }else - { - if ($result->{$bladePresentOid} eq "0") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "2") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "1") - { - my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2009.1.4", $self->{option_results}->{bladeNum}; - my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2009.1.5", $self->{option_results}->{bladeNum}; - my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2009.1.2", $self->{option_results}->{bladeNum}; - - $self->{snmp}->{snmp_force_getnext} = 1; - my $result = $self->{snmp}->get_table(oid => $componentPresentOid); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."No disk presence."; - }else - { - my $endKey; - my $temnameOid; - my $statusOid; - my $tmpMsg; - my $tmpresult; - my $totalPresent = 0; - my $totalComponent = 0; - my $v; - foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) - { - $v = $result->{$k}; - $endKey = "0"; - $temnameOid = ""; - $statusOid = ""; - $tmpMsg = ""; - $totalComponent++; - if ($v eq "1") # presence status: 0-not presence,1-presence - { - $totalPresent++; - $k =~ /\.([0-9]+)$/; - $endKey = $1; - $temnameOid = $componentMarkOid.".".$endKey; - $statusOid = $componentStatusOid.".".$endKey; - $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); - - $tmpMsg = $tmpresult->{$temnameOid}.":"; - $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); - $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; - $tmpShortMessage = $tmpShortMessage.$tmpMsg; - if($statusHash{$tmpresult->{$statusOid}} eq "critical") - { - $componentStatus = "critical"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) - { - $componentStatus = "warning"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") - { - if ($componentStatus eq "unknown") - { - $componentStatus = "ok"; - } - } - } - } - $tmpShortMessage = "diskPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; - } - }else - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + + foreach my $entry (keys $mapping) { + $mapping->{$entry}->{oid} =~ s/#/$self->{blade_id}/; + } + + $self->{output}->output_add(long_msg => "Checking disks"); + $self->{components}->{disk} = {name => 'disks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'disk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeDiskTable}})) { + next if ($oid !~ /^$mapping->{bladeDiskHealth}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeDiskTable}, instance => $instance); + + next if ($self->check_filter(section => 'disk', instance => $instance)); + next if ($result->{bladeDiskPresent} !~ /presence/); + $self->{components}->{disk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Disk '%s' status is '%s' [instance = %s]", + $result->{bladeDiskMark}, $result->{bladeDiskHealth}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'disk', value => $result->{bladeDiskHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Disk '%s' status is '%s'", $result->{bladeDiskMark}, $result->{bladeDiskHealth})); } } - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); } + 1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/fan.pm b/hardware/server/huawei/hmm/snmp/mode/components/fan.pm index 490090389..3540bc49c 100644 --- a/hardware/server/huawei/hmm/snmp/mode/components/fan.pm +++ b/hardware/server/huawei/hmm/snmp/mode/components/fan.pm @@ -1,70 +1,72 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + package hardware::server::huawei::hmm::snmp::mode::components::fan; use strict; use warnings; -sub check { +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my $mapping = { + mfanLocation => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1.2' }, + mfanHealth => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1.3', map => \%map_status }, +}; +my $oid_fanManagementEntry = '.1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1'; + +sub load { my ($self) = @_; - my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical"); - my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical"); - - my $fanStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1.3"; - my $fanPresenceOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1.1"; - - my $tmpShortMessage; - my $componentStatus ="unknown"; - - $self->{snmp}->{snmp_force_getnext} = 1; - my $result = $self->{snmp}->get_table(oid => $fanPresenceOid); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."No fan presence."; - }else - { - my $endKey; - my $statusOid; - my $tmpMsg; - my $tmpResult; - my $totalPresence = 0; - my $totalComponent = 14; - my $v; - foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) - { - $v = $result->{$k}; - $endKey = "0"; - $statusOid = ""; - $tmpMsg = ""; - $totalPresence++; - $k =~ /\.([0-9]+)$/; - $endKey = $1; - $tmpMsg = "Fan".$endKey.":"; - $statusOid = $fanStatusOid.".".$endKey; - $tmpResult = $self->{snmp}->get_leef(oids =>[$statusOid]); - $tmpMsg = $tmpMsg.$eachStatus{$tmpResult->{$statusOid}}." "; - $tmpShortMessage = $tmpShortMessage.$tmpMsg; - - if($statusHash{$tmpResult->{$statusOid}} eq "critical") - { - $componentStatus = "critical"; - }elsif (($statusHash{$tmpResult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) - { - $componentStatus = "warning"; - }elsif (($statusHash{$tmpResult->{$statusOid}}) eq "ok") - { - if ($componentStatus eq "unknown") - { - $componentStatus = "ok"; - } - } - } - $tmpShortMessage = "fanPresence:".$totalPresence."\/".$totalComponent." ".$tmpShortMessage; - } - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); + push @{$self->{request}}, { oid => $oid_fanManagementEntry }; } + +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_filter(section => 'fan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanManagementEntry}})) { + next if ($oid !~ /^$mapping->{mfanHealth}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanManagementEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance)); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]", + $result->{mfanLocation}, $result->{mfanHealth}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{mfanHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan '%s' status is '%s'", $result->{mfanLocation}, $result->{mfanHealth})); + } + } +} + 1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/memory.pm b/hardware/server/huawei/hmm/snmp/mode/components/memory.pm index 1bbf87bdd..1ceb44da9 100644 --- a/hardware/server/huawei/hmm/snmp/mode/components/memory.pm +++ b/hardware/server/huawei/hmm/snmp/mode/components/memory.pm @@ -1,100 +1,85 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + package hardware::server::huawei::hmm::snmp::mode::components::memory; use strict; use warnings; +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my %map_installation_status = ( + 0 => 'absence', + 1 => 'presence', + 2 => 'poweroff', +); + +my $mapping = { + bladeMemoryMark => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2007.1.2' }, + bladeMemoryPresent => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2007.1.4', map => \%map_installation_status }, + bladeMemoryHealth => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2007.1.5', map => \%map_status }, +}; +my $oid_bladeMemoryTable = '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2007.1'; + +sub load { + my ($self) = @_; + + $oid_bladeMemoryTable =~ s/#/$self->{blade_id}/; + push @{$self->{request}}, { oid => $oid_bladeMemoryTable }; +} + sub check { my ($self) = @_; - - my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown"); - my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"unknown"); - - my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; - - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - - my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."Get blade info error."; - }else - { - if ($result->{$bladePresentOid} eq "0") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "2") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "1") - { - my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2007.1.4", $self->{option_results}->{bladeNum}; - my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2007.1.5", $self->{option_results}->{bladeNum}; - my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2007.1.2", $self->{option_results}->{bladeNum}; - - $self->{snmp}->{snmp_force_getnext} = 1; - my $result = $self->{snmp}->get_table(oid => $componentPresentOid); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."No memory presence."; - }else - { - my $endKey; - my $temnameOid; - my $statusOid; - my $tmpMsg; - my $tmpresult; - my $totalPresent = 0; - my $totalComponent = 0; - my $v; - foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) - { - $v = $result->{$k}; - $endKey = "0"; - $temnameOid = ""; - $statusOid = ""; - $tmpMsg = ""; - $totalComponent++; - if ($v eq "1") # presence status: 0-not presence,1-presence - { - $totalPresent++; - $k =~ /\.([0-9]+)$/; - $endKey = $1; - $temnameOid = $componentMarkOid.".".$endKey; - $statusOid = $componentStatusOid.".".$endKey; - $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); - - $tmpMsg = $tmpresult->{$temnameOid}.":"; - $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); - $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; - $tmpShortMessage = $tmpShortMessage.$tmpMsg; - if($statusHash{$tmpresult->{$statusOid}} eq "critical") - { - $componentStatus = "critical"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) - { - $componentStatus = "warning"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") - { - if ($componentStatus eq "unknown") - { - $componentStatus = "ok"; - } - } - } - } - $tmpShortMessage = "memoryPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; - } - }else - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + + foreach my $entry (keys $mapping) { + $mapping->{$entry}->{oid} =~ s/#/$self->{blade_id}/; + } + + $self->{output}->output_add(long_msg => "Checking memory slots"); + $self->{components}->{memory} = {name => 'memory slots', total => 0, skip => 0}; + return if ($self->check_filter(section => 'memory')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeMemoryTable}})) { + next if ($oid !~ /^$mapping->{bladeMemoryHealth}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeMemoryTable}, instance => $instance); + + next if ($self->check_filter(section => 'memory', instance => $instance)); + next if ($result->{bladeMemoryPresent} !~ /presence/); + $self->{components}->{memory}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Memory '%s' status is '%s' [instance = %s]", + $result->{bladeMemoryMark}, $result->{bladeMemoryHealth}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'memory', value => $result->{bladeMemoryHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory '%s' status is '%s'", $result->{bladeMemoryMark}, $result->{bladeMemoryHealth})); } } - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); } + 1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/mezz.pm b/hardware/server/huawei/hmm/snmp/mode/components/mezz.pm index d1675ad15..7ea666135 100644 --- a/hardware/server/huawei/hmm/snmp/mode/components/mezz.pm +++ b/hardware/server/huawei/hmm/snmp/mode/components/mezz.pm @@ -1,100 +1,85 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + package hardware::server::huawei::hmm::snmp::mode::components::mezz; use strict; use warnings; +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my %map_installation_status = ( + 0 => 'absence', + 1 => 'presence', + 2 => 'poweroff', +); + +my $mapping = { + bladeMezzMark => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2008.1.2' }, + bladeMezzPresent => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2008.1.4', map => \%map_installation_status }, + bladeMezzHealth => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2008.1.5', map => \%map_status }, +}; +my $oid_bladeMezzTable = '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2008.1'; + +sub load { + my ($self) = @_; + + $oid_bladeMezzTable =~ s/#/$self->{blade_id}/; + push @{$self->{request}}, { oid => $oid_bladeMezzTable }; +} + sub check { my ($self) = @_; - - my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown"); - my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"unknown"); - - my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; - - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - - my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."Get blade info error."; - }else - { - if ($result->{$bladePresentOid} eq "0") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "2") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "1") - { - my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2008.1.4", $self->{option_results}->{bladeNum}; - my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2008.1.5", $self->{option_results}->{bladeNum}; - my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2008.1.2", $self->{option_results}->{bladeNum}; - - $self->{snmp}->{snmp_force_getnext} = 1; - my $result = $self->{snmp}->get_table(oid => $componentPresentOid); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."No mezz presence."; - }else - { - my $endKey; - my $temnameOid; - my $statusOid; - my $tmpMsg; - my $tmpresult; - my $totalPresent = 0; - my $totalComponent = 0; - my $v; - foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) - { - $v = $result->{$k}; - $endKey = "0"; - $temnameOid = ""; - $statusOid = ""; - $tmpMsg = ""; - $totalComponent++; - if ($v eq "1") # presence status: 0-not presence,1-presence - { - $totalPresent++; - $k =~ /\.([0-9]+)$/; - $endKey = $1; - $temnameOid = $componentMarkOid.".".$endKey; - $statusOid = $componentStatusOid.".".$endKey; - $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); - - $tmpMsg = $tmpresult->{$temnameOid}.":"; - $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); - $tmpMsg = $tmpMsg. $eachStatus{ $tmpresult->{$statusOid}}." "; - $tmpShortMessage = $tmpShortMessage.$tmpMsg; - if($statusHash{$tmpresult->{$statusOid}} eq "critical") - { - $componentStatus = "critical"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) - { - $componentStatus = "warning"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") - { - if ($componentStatus eq "unknown") - { - $componentStatus = "ok"; - } - } - } - } - $tmpShortMessage = "mezzPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; - } - }else - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + + foreach my $entry (keys $mapping) { + $mapping->{$entry}->{oid} =~ s/#/$self->{blade_id}/; + } + + $self->{output}->output_add(long_msg => "Checking mezz cards"); + $self->{components}->{mezz} = {name => 'mezz cards', total => 0, skip => 0}; + return if ($self->check_filter(section => 'mezz')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeMezzTable}})) { + next if ($oid !~ /^$mapping->{bladeMezzHealth}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeMezzTable}, instance => $instance); + + next if ($self->check_filter(section => 'mezz', instance => $instance)); + next if ($result->{bladeMezzPresent} !~ /presence/); + $self->{components}->{mezz}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Mezz card '%s' status is '%s' [instance = %s]", + $result->{bladeMezzMark}, $result->{bladeMezzHealth}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'mezz', value => $result->{bladeMezzHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Mezz card '%s' status is '%s'", $result->{bladeMezzMark}, $result->{bladeMezzHealth})); } } - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); } + 1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/psu.pm b/hardware/server/huawei/hmm/snmp/mode/components/psu.pm index 7472dd036..94073cbed 100644 --- a/hardware/server/huawei/hmm/snmp/mode/components/psu.pm +++ b/hardware/server/huawei/hmm/snmp/mode/components/psu.pm @@ -1,70 +1,72 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + package hardware::server::huawei::hmm::snmp::mode::components::psu; use strict; use warnings; -sub check { +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my $mapping = { + mpsuLocation => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.100.4.2001.1.2' }, + mpsuHealth => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.100.4.2001.1.3', map => \%map_status }, +}; +my $oid_psuManagementEntry = '.1.3.6.1.4.1.2011.2.82.1.82.100.4.2001.1'; + +sub load { my ($self) = @_; - my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical"); - my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical"); - - my $psuPresenceOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.4.2001.1.1"; - my $psuStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.4.2001.1.3"; - - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - - $self->{snmp}->{snmp_force_getnext} = 1; - my $result = $self->{snmp}->get_table(oid => $psuPresenceOid); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."No psu presence."; - }else - { - my $endKey; - my $statusOid; - my $tmpMsg; - my $tmpResult; - my $totalPresence = 0; - my $totalComponent = 6; - my $v; - foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) - { - $v = $result->{$k}; - $endKey = "0"; - $statusOid = ""; - $tmpMsg = ""; - $totalPresence++; - $k =~ /\.([0-9]+)$/; - $endKey = $1 ; - $tmpMsg = "Psu".$endKey.":"; - $statusOid = $psuStatusOid.".".$endKey; - $tmpResult = $self->{snmp}->get_leef(oids =>[$statusOid]); - $tmpMsg = $tmpMsg.$eachStatus{$tmpResult->{$statusOid}}." "; - $tmpShortMessage = $tmpShortMessage.$tmpMsg; - - if($statusHash{$tmpResult->{$statusOid}} eq "critical") - { - $componentStatus = "critical"; - }elsif (($statusHash{$tmpResult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) - { - $componentStatus = "warning"; - }elsif (($statusHash{$tmpResult->{$statusOid}}) eq "ok") - { - if ($componentStatus eq "unknown") - { - $componentStatus = "ok"; - } - } - } - $tmpShortMessage = "psuPresence:".$totalPresence."\/".$totalComponent." ".$tmpShortMessage; - } - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); + push @{$self->{request}}, { oid => $oid_psuManagementEntry }; } + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; + return if ($self->check_filter(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_psuManagementEntry}})) { + next if ($oid !~ /^$mapping->{mpsuHealth}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_psuManagementEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Power supplies '%s' status is '%s' [instance = %s]", + $result->{mpsuLocation}, $result->{mpsuHealth}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{mpsuHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power supplies '%s' status is '%s'", $result->{mpsuLocation}, $result->{mpsuHealth})); + } + } +} + 1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/raid.pm b/hardware/server/huawei/hmm/snmp/mode/components/raid.pm deleted file mode 100644 index 234bf317d..000000000 --- a/hardware/server/huawei/hmm/snmp/mode/components/raid.pm +++ /dev/null @@ -1,105 +0,0 @@ -package hardware::server::huawei::hmm::snmp::mode::components::raid; - -use strict; -use warnings; - -sub check { - my ($self) = @_; - - my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; - - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - - my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."Get blade info error."; - }else - { - if ($result->{$bladePresentOid} eq "0") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "2") - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; - }elsif ($result->{$bladePresentOid} eq "1") - { - my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2011.1.2", $self->{option_results}->{bladeNum}; - my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2011.1.7", $self->{option_results}->{bladeNum}; - my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2011.1.3", $self->{option_results}->{bladeNum}; - - $self->{snmp}->{snmp_force_getnext} = 1; - my $result = $self->{snmp}->get_table(oid => $componentPresentOid); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."No raid presence."; - }else - { - my $endKey; - my $temnameOid; - my $statusOid; - my $tmpMsg; - my $tmpResult; - my $totalPresent = 0; - my $totalComponent = 0; - my $v; - foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) - { - $v = $result->{$k}; - $endKey = "0"; - $temnameOid = ""; - $statusOid = ""; - $tmpMsg = ""; - $totalComponent++; - if ($v eq "2") # presence status: 1-not presence,2-presence - { - $totalPresent++; - $k =~ /\.([0-9]+)$/; - $endKey = $1 ; - $temnameOid = $componentMarkOid.".".$endKey; - $statusOid = $componentStatusOid.".".$endKey; - $tmpResult = $self->{snmp}->get_leef(oids =>[$temnameOid]); - - $tmpMsg = $tmpResult->{$temnameOid}.":"; - $tmpResult = $self->{snmp}->get_leef(oids =>[$statusOid]); - my $tmpStatus; - if ($tmpResult->{$statusOid} eq "-1"){ - $tmpStatus = "unknown"; - }elsif($tmpResult->{$statusOid} eq "1") - { - $tmpStatus = "ok"; - }else - { - $tmpStatus = "warning"; - } - $tmpMsg = $tmpMsg.$tmpStatus." "; - $tmpShortMessage = $tmpShortMessage.$tmpMsg; - if($tmpStatus eq "warning") - { - $componentStatus = "warning"; - }elsif ($tmpStatus eq "ok") - { - if ($componentStatus eq "unknown") - { - $componentStatus = "ok"; - } - } - } - } - $tmpShortMessage = "raidPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; - } - }else - { - $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; - } - } - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); - -} -1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/raidcontroller.pm b/hardware/server/huawei/hmm/snmp/mode/components/raidcontroller.pm new file mode 100644 index 000000000..7d725dedf --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/raidcontroller.pm @@ -0,0 +1,84 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package hardware::server::huawei::hmm::snmp::mode::components::raidcontroller; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my %map_installation_status = ( + 1 => 'absent', + 2 => 'present', +); + +my $mapping = { + bladeRAIDControllerIndex => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2011.1.1' }, + bladeRAIDControllerPresence => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2011.1.2', map => \%map_installation_status }, + bladeRAIDControllerHealthState => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2011.1.7', map => \%map_status }, +}; +my $oid_bladeRAIDControllerTable = '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2011.1'; + +sub load { + my ($self) = @_; + + $oid_bladeRAIDControllerTable =~ s/#/$self->{blade_id}/; + push @{$self->{request}}, { oid => $oid_bladeRAIDControllerTable }; +} + +sub check { + my ($self) = @_; + + foreach my $entry (keys $mapping) { + $mapping->{$entry}->{oid} =~ s/#/$self->{blade_id}/; + } + + $self->{output}->output_add(long_msg => "Checking RAID controllers"); + $self->{components}->{raidcontroller} = {name => 'raid controllers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'raidcontroller')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeRAIDControllerTable}})) { + next if ($oid !~ /^$mapping->{bladeRAIDControllerHealthState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeRAIDControllerTable}, instance => $instance); + + next if ($self->check_filter(section => 'raidcontroller', instance => $instance)); + next if ($result->{bladeRAIDControllerPresence} !~ /present/); + $self->{components}->{raidcontroller}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Raid controller '%s' status is '%s' [instance = %s]", + $result->{bladeRAIDControllerIndex}, $result->{bladeRAIDControllerHealthState}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'raidcontroller', value => $result->{bladeRAIDControllerHealthState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Raid controller '%s' status is '%s'", $result->{bladeRAIDControllerIndex}, $result->{bladeRAIDControllerHealthState})); + } + } +} + +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/shelf.pm b/hardware/server/huawei/hmm/snmp/mode/components/shelf.pm deleted file mode 100644 index 52f3a352f..000000000 --- a/hardware/server/huawei/hmm/snmp/mode/components/shelf.pm +++ /dev/null @@ -1,27 +0,0 @@ -package hardware::server::huawei::hmm::snmp::mode::components::shelf; - -use strict; -use warnings; - -sub check { - my ($self) = @_; - - my %statusHash = ("0"=>"ok","1"=>"warning","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); - - my $componentStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.2.5.0"; - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - my $tmpResult; - - $tmpResult = $self->{snmp}->get_leef(oids =>[$componentStatusOid]); - - $componentStatus = $statusHash{$tmpResult->{$componentStatusOid}}; - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); - } -1; - \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/smm.pm b/hardware/server/huawei/hmm/snmp/mode/components/smm.pm deleted file mode 100644 index 20d88b3d4..000000000 --- a/hardware/server/huawei/hmm/snmp/mode/components/smm.pm +++ /dev/null @@ -1,27 +0,0 @@ -package hardware::server::huawei::hmm::snmp::mode::components::smm; - -use strict; -use warnings; - -sub check { - my ($self) = @_; - - my %statusHash = ("0"=>"ok","1"=>"warning","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); - - my $componentStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.3.9.0"; - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - my $tmpResult; - - $tmpResult = $self->{snmp}->get_leef(oids =>[$componentStatusOid]); - - $componentStatus = $statusHash{$tmpResult->{$componentStatusOid}}; - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); - } -1; - \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/switch.pm b/hardware/server/huawei/hmm/snmp/mode/components/switch.pm index 391ad14c1..630264752 100644 --- a/hardware/server/huawei/hmm/snmp/mode/components/switch.pm +++ b/hardware/server/huawei/hmm/snmp/mode/components/switch.pm @@ -1,71 +1,72 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + package hardware::server::huawei::hmm::snmp::mode::components::switch; use strict; use warnings; -sub check { +my %map_status = ( + 1 => 'normal', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', +); + +my $mapping = { + mSwiLocation => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.100.2.2001.1.2' }, + mSwiHealth => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.100.2.2001.1.3', map => \%map_status }, +}; +my $oid_swiManagementEntry = '.1.3.6.1.4.1.2011.2.82.1.82.100.2.2001.1'; + +sub load { my ($self) = @_; - my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical"); - my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical"); - - my $switchPresenceOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.2.2001.1.1"; - my $switchStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.2.2001.1.3"; - - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - - $self->{snmp}->{snmp_force_getnext} = 1; - my $result = $self->{snmp}->get_table(oid => $switchPresenceOid); - if (scalar(keys %$result) <= 0) - { - $tmpShortMessage = $tmpShortMessage."No switch presence."; - }else - { - my $endKey; - my $statusOid; - my $tmpMsg; - my $tmpresult; - my $totalPresence = 0; - my $totalComponent = 4; - my $v; - foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) - { - $v = $result->{$k}; - $endKey = "0"; - $statusOid = ""; - $tmpMsg = ""; - $totalPresence++; - $k =~ /\.([0-9]+)$/; - $endKey = $1; - $tmpMsg = "Switch".$endKey.":"; - $statusOid = $switchStatusOid.".".$endKey; - $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); - $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; - $tmpShortMessage = $tmpShortMessage.$tmpMsg; - - if($statusHash{$tmpresult->{$statusOid}} eq "critical") - { - $componentStatus = "critical"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) - { - $componentStatus = "warning"; - }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") - { - if ($componentStatus eq "unknown") - { - $componentStatus = "ok"; - } - } - } - $tmpShortMessage = "switchPresence:".$totalPresence."\/".$totalComponent." ".$tmpShortMessage; - } - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); + push @{$self->{request}}, { oid => $oid_swiManagementEntry }; } -1; - \ No newline at end of file + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking switches"); + $self->{components}->{swi} = {name => 'switches', total => 0, skip => 0}; + return if ($self->check_filter(section => 'swi')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_swiManagementEntry}})) { + next if ($oid !~ /^$mapping->{mSwiHealth}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swiManagementEntry}, instance => $instance); + + next if ($self->check_filter(section => 'swi', instance => $instance)); + $self->{components}->{swi}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Switch '%s' status is '%s' [instance = %s]", + $result->{mSwiLocation}, $result->{mSwiHealth}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'swi', value => $result->{mSwiHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Switch '%s' status is '%s'", $result->{mSwiLocation}, $result->{mSwiHealth})); + } + } +} + +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/system.pm b/hardware/server/huawei/hmm/snmp/mode/components/system.pm deleted file mode 100644 index cb60fb712..000000000 --- a/hardware/server/huawei/hmm/snmp/mode/components/system.pm +++ /dev/null @@ -1,27 +0,0 @@ -package hardware::server::huawei::hmm::snmp::mode::components::system; - -use strict; -use warnings; - -sub check { - my ($self) = @_; - - my %statusHash = ("0"=>"ok","1"=>"warning","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); - - my $componentStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.1.1.0"; - my $tmpShortMessage = ""; - my $componentStatus = "unknown"; - my $tmpResult; - - $tmpResult = $self->{snmp}->get_leef(oids =>[$componentStatusOid]); - - $componentStatus = $statusHash{$tmpResult->{$componentStatusOid}}; - - $self->{output}->output_add(severity => $componentStatus, - short_msg => $tmpShortMessage); - - $self->{output}->display(); - $self->{output}->exit(); - } -1; - \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/temperature.pm b/hardware/server/huawei/hmm/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..2b2208127 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/temperature.pm @@ -0,0 +1,75 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package hardware::server::huawei::hmm::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + bladeTemperatureIndex => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2012.1.1' }, + bladeTemperatureReading => { oid => '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2012.1.2' }, +}; +my $oid_bladeTemperatureTable = '.1.3.6.1.4.1.2011.2.82.1.82.4.#.2012.1'; + +sub load { + my ($self) = @_; + + $oid_bladeTemperatureTable =~ s/#/$self->{blade_id}/; + push @{$self->{request}}, { oid => $oid_bladeTemperatureTable }; +} + +sub check { + my ($self) = @_; + + foreach my $entry (keys $mapping) { + $mapping->{$entry}->{oid} =~ s/#/$self->{blade_id}/; + } + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeTemperatureTable}})) { + next if ($oid !~ /^$mapping->{oid_bladeTemperatureTable}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeTemperatureTable}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Temperature '%s' is '%s' celsius degrees [instance = %s]", + $result->{bladeTemperatureIndex}, $result->{bladeTemperatureReading}, $instance, + )); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{bladeTemperatureReading}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' is '%s' celsius degrees", $result->{bladeTemperatureIndex}, $result->{bladeTemperatureReading})); + } + + $self->{output}->perfdata_add(label => 'temperature_' . $result->{bladeTemperatureIndex}, unit => 'C', + value => $result->{bladeTemperatureReading}, + warning => $warn, + critical => $crit + ); + } +} + +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/hardwares.pm b/hardware/server/huawei/hmm/snmp/mode/hardwares.pm deleted file mode 100644 index 80dae8254..000000000 --- a/hardware/server/huawei/hmm/snmp/mode/hardwares.pm +++ /dev/null @@ -1,81 +0,0 @@ -package hardware::server::huawei::hmm::snmp::mode::hardwares; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; -use hardware::server::huawei::hmm::snmp::mode::components::blade; -use hardware::server::huawei::hmm::snmp::mode::components::switch; -use hardware::server::huawei::hmm::snmp::mode::components::shelf; -use hardware::server::huawei::hmm::snmp::mode::components::smm; -use hardware::server::huawei::hmm::snmp::mode::components::system; -use hardware::server::huawei::hmm::snmp::mode::components::cpu; -use hardware::server::huawei::hmm::snmp::mode::components::fan; -use hardware::server::huawei::hmm::snmp::mode::components::raid; -use hardware::server::huawei::hmm::snmp::mode::components::memory; -use hardware::server::huawei::hmm::snmp::mode::components::psu; -use hardware::server::huawei::hmm::snmp::mode::components::disk; -use hardware::server::huawei::hmm::snmp::mode::components::mezz; - - -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 => - { - "component:s" => { name => 'component', default => 'system' }, - "bladeNum:s" => { name => 'bladeNum', default => '0' }, - }); - $self->{components} = {}; - $self->{no_components} = undef; - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - if ($self->{option_results}->{component} eq 'system') { - hardware::server::huawei::hmm::snmp::mode::components::system::check($self); - } elsif ($self->{option_results}->{component} eq 'cpu') { - hardware::server::huawei::hmm::snmp::mode::components::cpu::check($self); - } elsif ($self->{option_results}->{component} eq 'fan') { - hardware::server::huawei::hmm::snmp::mode::components::fan::check($self); - } elsif ($self->{option_results}->{component} eq 'raid') { - hardware::server::huawei::hmm::snmp::mode::components::raid::check($self); - } elsif ($self->{option_results}->{component} eq 'memory') { - hardware::server::huawei::hmm::snmp::mode::components::memory::check($self); - } elsif ($self->{option_results}->{component} eq 'psu') { - hardware::server::huawei::hmm::snmp::mode::components::psu::check($self); - } elsif ($self->{option_results}->{component} eq 'disk') { - hardware::server::huawei::hmm::snmp::mode::components::disk::check($self); - } elsif ($self->{option_results}->{component} eq 'blade') { - hardware::server::huawei::hmm::snmp::mode::components::blade::check($self); - } elsif ($self->{option_results}->{component} eq 'shelf') { - hardware::server::huawei::hmm::snmp::mode::components::shelf::check($self); - } elsif ($self->{option_results}->{component} eq 'smm') { - hardware::server::huawei::hmm::snmp::mode::components::smm::check($self); - } elsif ($self->{option_results}->{component} eq 'switch') { - hardware::server::huawei::hmm::snmp::mode::components::switch::check($self); - } elsif ($self->{option_results}->{component} eq 'mezz') { - hardware::server::huawei::hmm::snmp::mode::components::mezz::check($self); - } else { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/plugin.pm b/hardware/server/huawei/hmm/snmp/plugin.pm index 0b6b09ad8..00d120c55 100644 --- a/hardware/server/huawei/hmm/snmp/plugin.pm +++ b/hardware/server/huawei/hmm/snmp/plugin.pm @@ -1,3 +1,22 @@ +# +# Copyright 2018 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# package hardware::server::huawei::hmm::snmp::plugin; @@ -12,17 +31,19 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'hardwares' => 'hardware::server::huawei::hmm::snmp::mode::hardwares', + 'blade' => 'hardware::server::huawei::hmm::snmp::mode::blade', + 'chassis' => 'hardware::server::huawei::hmm::snmp::mode::chassis', ); return $self; } -1; -__END__ +1; + +__END__ =head1 PLUGIN DESCRIPTION -Check HUAWEI servers in SNMP. +Check Huawei Management Module in SNMP. =cut