diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/disk.pm b/hardware/server/lenovo/xcc/snmp/mode/components/disk.pm new file mode 100644 index 000000000..378c0ed94 --- /dev/null +++ b/hardware/server/lenovo/xcc/snmp/mode/components/disk.pm @@ -0,0 +1,66 @@ +# +# Copyright 2019 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::lenovo::xcc::snmp::mode::components::disk; + +use strict; +use warnings; +use centreon::plugins::misc; + +my $mapping = { + diskFruName => { oid => '.1.3.6.1.4.1.19046.11.1.1.12.2.1.2' }, + diskHealthStatus => { oid => '.1.3.6.1.4.1.19046.11.1.1.12.2.1.3' }, +}; +my $oid_diskEntry = '.1.3.6.1.4.1.19046.11.1.1.12.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_diskEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking disks"); + $self->{components}->{disk} = { name => 'disk', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'disk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_diskEntry}})) { + next if ($oid !~ /^$mapping->{diskFruName}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_diskEntry}, instance => $instance); + + next if ($self->check_filter(section => 'disk', instance => $instance)); + $result->{diskFruName} = centreon::plugins::misc::trim($result->{diskFruName}); + $self->{components}->{disk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("disk '%s' status is %s [instance: %s].", + $result->{diskFruName}, $result->{diskHealthStatus}, $instance)); + + my $exit = $self->get_severity(label => 'default', section => 'disk', value => $result->{diskHealthStatus}); + 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->{diskFruName}, $result->{diskHealthStatus})); + } + } +} + +1; diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/fan.pm b/hardware/server/lenovo/xcc/snmp/mode/components/fan.pm new file mode 100644 index 000000000..87d531b48 --- /dev/null +++ b/hardware/server/lenovo/xcc/snmp/mode/components/fan.pm @@ -0,0 +1,82 @@ +# +# Copyright 2019 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::lenovo::xcc::snmp::mode::components::fan; + +use strict; +use warnings; +use centreon::plugins::misc; + +my $mapping = { + fanDescr => { oid => '.1.3.6.1.4.1.19046.11.1.1.3.2.1.2' }, + fanSpeed => { oid => '.1.3.6.1.4.1.19046.11.1.1.3.2.1.3' }, + fanHealthStatus => { oid => '.1.3.6.1.4.1.19046.11.1.1.3.2.1.10' }, +}; +my $oid_fanEntry = '.1.3.6.1.4.1.19046.11.1.1.3.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_fanEntry }; +} + +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_fanEntry}})) { + next if ($oid !~ /^$mapping->{fanSpeed}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanEntry}, instance => $instance); + $result->{fanDescr} = centreon::plugins::misc::trim($result->{fanDescr}); + $result->{fanSpeed} = centreon::plugins::misc::trim($result->{fanSpeed}); + + 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][value: %s]", + $result->{fanDescr}, $result->{fanHealthStatus}, $instance, $result->{fanSpeed})); + + my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{fanHealthStatus}); + 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->{fanDescr}, $result->{fanHealthStatus})); + } + + next if ($result->{fanSpeed} !~ /(\d+)/); + + my $fan_speed = $1; + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $fan_speed); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Fan '%s' is '%s' %%", $result->{fanDescr}, $fan_speed)); + } + $self->{output}->perfdata_add(label => 'fan_' . $result->{fanDescr}, unit => '%', + value => $fan_speed, + warning => $warn, + critical => $crit, min => 0, max => 100 + ); + } +} + +1; diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/psu.pm b/hardware/server/lenovo/xcc/snmp/mode/components/psu.pm new file mode 100644 index 000000000..aa358147c --- /dev/null +++ b/hardware/server/lenovo/xcc/snmp/mode/components/psu.pm @@ -0,0 +1,66 @@ +# +# Copyright 2019 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::lenovo::xcc::snmp::mode::components::psu; + +use strict; +use warnings; +use centreon::plugins::misc; + +my $mapping = { + powerFruName => { oid => '.1.3.6.1.4.1.19046.11.1.1.11.2.1.2' }, + powerHealthStatus => { oid => '.1.3.6.1.4.1.19046.11.1.1.11.2.1.6' }, +}; +my $oid_powerEntry = '.1.3.6.1.4.1.19046.11.1.1.11.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_powerEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerEntry}})) { + next if ($oid !~ /^$mapping->{powerFruName}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + $result->{powerFruName} = centreon::plugins::misc::trim($result->{powerFruName}); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is %s [instance: %s].", + $result->{powerFruName}, $result->{powerHealthStatus}, $instance)); + + my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{powerHealthStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power supply '%s' status is '%s'", $result->{powerFruName}, $result->{powerHealthStatus})); + } + } +} + +1; diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/raidvolume.pm b/hardware/server/lenovo/xcc/snmp/mode/components/raidvolume.pm new file mode 100644 index 000000000..886dc7a14 --- /dev/null +++ b/hardware/server/lenovo/xcc/snmp/mode/components/raidvolume.pm @@ -0,0 +1,66 @@ +# +# Copyright 2019 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::lenovo::xcc::snmp::mode::components::raidvolume; + +use strict; +use warnings; +use centreon::plugins::misc; + +my $mapping = { + raidVolumeName => { oid => '.1.3.6.1.4.1.19046.11.1.1.13.1.7.1.2' }, + raidVolumeStatus => { oid => '.1.3.6.1.4.1.19046.11.1.1.13.1.7.1.4' }, +}; +my $oid_raidVolumeEntry = '.1.3.6.1.4.1.19046.11.1.1.13.1.7.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_raidVolumeEntry, end => $mapping->{raidVolumeStatus}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking raid volumes"); + $self->{components}->{raidvolume} = { name => 'raidvolume', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'raidvolume')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidVolumeEntry}})) { + next if ($oid !~ /^$mapping->{raidVolumeName}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raidVolumeEntry}, instance => $instance); + + next if ($self->check_filter(section => 'raidvolume', instance => $instance)); + $result->{raidVolumeName} = centreon::plugins::misc::trim($result->{raidVolumeName}); + $self->{components}->{raidvolume}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("raid volume '%s' status is %s [instance: %s].", + $result->{raidVolumeName}, $result->{raidVolumeStatus}, $instance)); + + my $exit = $self->get_severity(section => 'raidvolume', value => $result->{raidVolumeStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Raid volume '%s' status is '%s'", $result->{raidVolumeName}, $result->{raidVolumeStatus})); + } + } +} + +1; diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/temperature.pm b/hardware/server/lenovo/xcc/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..57663586f --- /dev/null +++ b/hardware/server/lenovo/xcc/snmp/mode/components/temperature.pm @@ -0,0 +1,96 @@ +# +# Copyright 2019 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::lenovo::xcc::snmp::mode::components::temperature; + +use strict; +use warnings; +use centreon::plugins::misc; + +my $mapping = { + tempDescr => { oid => '.1.3.6.1.4.1.19046.11.1.1.1.2.1.2' }, + tempReading => { oid => '.1.3.6.1.4.1.19046.11.1.1.1.2.1.3' }, + tempCritLimitHigh => { oid => '.1.3.6.1.4.1.19046.11.1.1.1.2.1.6' }, + tempNonCritLimitHigh => { oid => '.1.3.6.1.4.1.19046.11.1.1.1.2.1.7' }, + tempCritLimitLow => { oid => '.1.3.6.1.4.1.19046.11.1.1.1.2.1.9' }, + tempNonCritLimitLow => { oid => '.1.3.6.1.4.1.19046.11.1.1.1.2.1.10' }, + tempHealthStatus => { oid => '.1.3.6.1.4.1.19046.11.1.1.1.2.1.11' }, +}; +my $oid_tempEntry = '.1.3.6.1.4.1.19046.11.1.1.1.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_tempEntry }; +} + +sub check { + my ($self) = @_; + + $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_tempEntry}})) { + next if ($oid !~ /^$mapping->{tempDescr}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_tempEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $result->{tempDescr} = centreon::plugins::misc::trim($result->{tempDescr}); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is %s [instance: %s][value: %s C].", + $result->{tempDescr}, $result->{tempHealthStatus}, $instance, $result->{tempReading})); + + my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{tempHealthStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", $result->{tempDescr}, $result->{tempHealthStatus})); + } + + if (defined($result->{tempReading})) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{tempReading}); + if ($checked == 0) { + my $warn_th = ($result->{tempNonCritLimitLow} =~ /\d+(\.\d+)?/ ? $result->{tempNonCritLimitLow} : '') . ':' . ($result->{tempNonCritLimitHigh} =~ /\d+(\.\d+)?/ ? $result->{tempNonCritLimitHigh} : ''); + my $crit_th = ($result->{tempCritLimitLow} =~ /\d+(\.\d+)?/ ? $result->{tempCritLimitLow} : '') . ':' . ($result->{tempCritLimitHigh} =~ /\d+(\.\d+)?/ ? $result->{tempCritLimitHigh} : ''); + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th) if ($warn_th ne ':'); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th) if ($crit_th ne ':'); + $exit = $self->{perfdata}->threshold_check( + value => $result->{tempReading}, + threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + } + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Temperature '%s' is %s C", $result->{tempDescr}, $result->{tempReading})); + } + $self->{output}->perfdata_add(label => "temp_" . $result->{tempDescr}, unit => 'C', + value => $result->{tempReading}, + warning => $warn, + critical => $crit); + } + } +} + +1; diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/voltage.pm b/hardware/server/lenovo/xcc/snmp/mode/components/voltage.pm new file mode 100644 index 000000000..a7ebcbc32 --- /dev/null +++ b/hardware/server/lenovo/xcc/snmp/mode/components/voltage.pm @@ -0,0 +1,96 @@ +# +# Copyright 2019 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::lenovo::xcc::snmp::mode::components::voltage; + +use strict; +use warnings; +use centreon::plugins::misc; + +my $mapping = { + voltDescr => { oid => '.1.3.6.1.4.1.19046.11.1.1.2.2.1.2' }, + voltReading => { oid => '.1.3.6.1.4.1.19046.11.1.1.2.2.1.3' }, + voltCritLimitHigh => { oid => '.1.3.6.1.4.1.19046.11.1.1.2.2.1.6' }, + voltNonCritLimitHigh => { oid => '.1.3.6.1.4.1.19046.11.1.1.2.2.1.7' }, + voltCritLimitLow => { oid => '.1.3.6.1.4.1.19046.11.1.1.2.2.1.9' }, + voltNonCritLimitLow => { oid => '.1.3.6.1.4.1.19046.11.1.1.2.2.1.10' }, + voltHealthStatus => { oid => '.1.3.6.1.4.1.19046.11.1.1.2.2.1.11' }, +}; +my $oid_voltEntry = '.1.3.6.1.4.1.19046.11.1.1.2.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_voltEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking voltages"); + $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; + return if ($self->check_filter(section => 'voltage')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_voltEntry}})) { + next if ($oid !~ /^$mapping->{voltDescr}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_voltEntry}, instance => $instance); + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + $result->{voltDescr} = centreon::plugins::misc::trim($result->{voltDescr}); + $self->{components}->{voltage}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("voltage '%s' status is %s [instance: %s][value: %s].", + $result->{voltDescr}, $result->{voltHealthStatus}, $instance, $result->{voltReading})); + + my $exit = $self->get_severity(label => 'default', section => 'voltage', value => $result->{voltHealthStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage '%s' status is '%s'", $result->{voltDescr}, $result->{voltHealthStatus})); + } + + next if (!defined($result->{voltReading})); + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{voltReading}); + if ($checked == 0) { + my $warn_th = ($result->{voltNonCritLimitLow} =~ /\d+(\.\d+)?/ ? $result->{voltNonCritLimitLow} : '') . ':' . ($result->{voltNonCritLimitHigh} =~ /\d+(\.\d+)?/ ? $result->{voltNonCritLimitHigh} : ''); + my $crit_th = ($result->{voltCritLimitLow} =~ /\d+(\.\d+)?/ ? $result->{voltCritLimitLow} : '') . ':' . ($result->{voltCritLimitHigh} =~ /\d+(\.\d+)?/ ? $result->{voltCritLimitHigh} : ''); + $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th) if ($warn_th ne ':'); + $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th) if ($crit_th ne ':'); + $exit = $self->{perfdata}->threshold_check( + value => $result->{voltReading}, + threshold => [ { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } ]); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance); + } + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Voltage '%s' is %s", $result->{voltDescr}, $result->{voltReading})); + } + $self->{output}->perfdata_add(label => "volt_" . $result->{voltDescr}, + value => $result->{voltReading}, + warning => $warn, + critical => $crit); + } +} + +1; diff --git a/hardware/server/lenovo/xcc/snmp/mode/hardware.pm b/hardware/server/lenovo/xcc/snmp/mode/hardware.pm new file mode 100644 index 000000000..b622d5601 --- /dev/null +++ b/hardware/server/lenovo/xcc/snmp/mode/hardware.pm @@ -0,0 +1,115 @@ +# +# Copyright 2019 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::lenovo::xcc::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(temperature|voltage|fan|psu|disk|raidvolume)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|fan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['Normal', 'OK'], + ['.*', 'CRITICAL'], + ], + raidvolume => [ + ['Optimal', 'OK'], + ['.*', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::server::lenovo::xcc::snmp::mode::components'; + $self->{components_module} = ['temperature', 'voltage', 'fan', 'psu', 'disk', 'raidvolume']; +} + +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 hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'temperature', 'voltage', 'fan', 'psu', 'disk', 'raidvolume'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=temperature) +Can also exclude specific instance: --filter=fan,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='fan,OK,offline' + +=item B<--warning> + +Set warning threshold for 'temperature', 'fan', 'voltage' (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold for temperature', 'fan', 'voltage' (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + +=back + +=cut + diff --git a/hardware/server/lenovo/xcc/snmp/plugin.pm b/hardware/server/lenovo/xcc/snmp/plugin.pm new file mode 100644 index 000000000..6017fbd89 --- /dev/null +++ b/hardware/server/lenovo/xcc/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2019 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::lenovo::xcc::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'hardware' => 'hardware::server::lenovo::xcc::snmp::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Lenovo XCC Card in SNMP. + +=cut