From 50ba077fadb5db1cbd118ef47b826f949a8a5f03 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 8 Aug 2019 15:04:58 +0200 Subject: [PATCH] breaking change: create adic tape snmp + update quantum scalar snmp --- storage/adic/tape/snmp/plugin.pm | 49 +++++++ .../scalar/snmp/mode/components/global.pm | 73 ++++++++++ .../scalar/snmp/mode/components/humidity.pm | 89 ++++++++++++ .../snmp/mode/components/physicaldrive.pm | 91 +++++++++++++ .../scalar/snmp/mode/components/psu.pm | 92 +++++++++++++ .../scalar/snmp/mode/components/resources.pm | 43 ++++++ .../scalar/snmp/mode/components/subsystem.pm | 77 +++++++++++ .../snmp/mode/components/temperature.pm | 88 ++++++++++++ .../scalar/snmp/mode/components/voltage.pm | 89 ++++++++++++ storage/quantum/scalar/snmp/mode/hardware.pm | 127 ++++++++++++++++++ storage/quantum/scalar/snmp/plugin.pm | 6 +- 11 files changed, 821 insertions(+), 3 deletions(-) create mode 100644 storage/adic/tape/snmp/plugin.pm create mode 100644 storage/quantum/scalar/snmp/mode/components/global.pm create mode 100644 storage/quantum/scalar/snmp/mode/components/humidity.pm create mode 100644 storage/quantum/scalar/snmp/mode/components/physicaldrive.pm create mode 100644 storage/quantum/scalar/snmp/mode/components/psu.pm create mode 100644 storage/quantum/scalar/snmp/mode/components/resources.pm create mode 100644 storage/quantum/scalar/snmp/mode/components/subsystem.pm create mode 100644 storage/quantum/scalar/snmp/mode/components/temperature.pm create mode 100644 storage/quantum/scalar/snmp/mode/components/voltage.pm create mode 100644 storage/quantum/scalar/snmp/mode/hardware.pm diff --git a/storage/adic/tape/snmp/plugin.pm b/storage/adic/tape/snmp/plugin.pm new file mode 100644 index 000000000..3df2ef86d --- /dev/null +++ b/storage/adic/tape/snmp/plugin.pm @@ -0,0 +1,49 @@ +# +# 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 storage::adic::tape::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' => 'centreon::common::adic::tape::snmp::mode::hardware' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Adic tape library in SNMP. +Buyed by Quantum in 2006. To be tested for some Quantum scalar (i6000, i500, ...). + +=cut diff --git a/storage/quantum/scalar/snmp/mode/components/global.pm b/storage/quantum/scalar/snmp/mode/components/global.pm new file mode 100644 index 000000000..e0e4f0f5f --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/components/global.pm @@ -0,0 +1,73 @@ +# +# 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 storage::quantum::scalar::snmp::mode::components::global; + +use strict; +use warnings; +use storage::quantum::scalar::snmp::mode::components::resources qw($map_rassubsytem_status); + +# In MIB 'QUANTUM-MIDRANGE-TAPE-LIBRARY-MIB' +my $oid_mrTapeLibrary = '.1.3.6.1.4.1.3697.1.10.15.5'; +my $oid_libraryFirmwareVersion = '.1.3.6.1.4.1.3697.1.10.15.5.9'; +my $oid_libraryGlobalStatus = '.1.3.6.1.4.1.3697.1.10.15.5.10'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_mrTapeLibrary, start => $oid_libraryFirmwareVersion, end => $oid_libraryGlobalStatus }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "checking global"); + $self->{components}->{global} = {name => 'global', total => 0, skip => 0}; + return if ($self->check_filter(section => 'global')); + + return if (!defined($self->{results}->{$oid_mrTapeLibrary}) || + scalar(keys %{$self->{results}->{$oid_mrTapeLibrary}}) <= 0); + + my $instance = '0'; + my $status = defined($self->{results}->{$oid_mrTapeLibrary}->{$oid_libraryGlobalStatus . '.0'}) ? + $map_rassubsytem_status->{ $self->{results}->{$oid_mrTapeLibrary}->{$oid_libraryGlobalStatus . '.0'} } : + $map_rassubsytem_status->{ $self->{results}->{$oid_mrTapeLibrary}->{$oid_libraryGlobalStatus} }; + + return if ($self->check_filter(section => 'global', instance => $instance)); + $self->{components}->{global}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + 'library global status is %s [instance: %s]', + $status, $instance + ) + ); + my $exit = $self->get_severity(section => 'global', label => 'default', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => + sprintf("Library global status is %s", $status + ) + ); + } +} + +1; diff --git a/storage/quantum/scalar/snmp/mode/components/humidity.pm b/storage/quantum/scalar/snmp/mode/components/humidity.pm new file mode 100644 index 000000000..2adc20a87 --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/components/humidity.pm @@ -0,0 +1,89 @@ +# +# 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 storage::quantum::scalar::snmp::mode::components::humidity; + +use strict; +use warnings; +use storage::quantum::scalar::snmp::mode::components::resources qw($map_sensor_status); + +# In MIB 'QUANTUM-MIDRANGE-TAPE-LIBRARY-MIB' +my $mapping = { + libraryHumiditySensorName => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.120.1.2.1.2' }, + libraryHumiditySensorLocation => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.120.1.2.1.3' }, + libraryHumiditySensorStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.120.1.2.1.4', map => $map_sensor_status }, + libraryHumiditySensorValue => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.120.1.2.1.5' }, +}; +my $oid_libraryHumiditySensorEntry = '.1.3.6.1.4.1.3697.1.10.15.5.120.1.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_libraryHumiditySensorEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "checking humidities"); + $self->{components}->{humidity} = {name => 'humidity', total => 0, skip => 0}; + return if ($self->check_filter(section => 'humidity')); + + my ($exit, $warn, $crit, $checked); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_libraryHumiditySensorEntry}})) { + next if ($oid !~ /^$mapping->{libraryHumiditySensorStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryHumiditySensorEntry}, instance => $instance); + + next if ($self->check_filter(section => 'humidity', instance => $instance)); + $self->{components}->{humidity}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("humidity '%s' status is '%s' [instance = %s] [value = %s]", + $result->{libraryHumiditySensorLocation}, $result->{libraryHumiditySensorStatus}, $instance, + $result->{libraryHumiditySensorValue})); + + $exit = $self->get_severity(label => 'default', section => 'humidity', instance => $instance, value => $result->{libraryHumiditySensorStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Humidity '%s' status is '%s'", $result->{libraryHumiditySensorLocation}, $result->{libraryHumiditySensorStatus})); + } + + next if (!defined($result->{libraryHumiditySensorValue}) || $result->{libraryHumiditySensorValue} !~ /[0-9]/); + + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{libraryHumiditySensorValue}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Humdity '%s' is %s %%", $result->{libraryHumiditySensorLocation}, $result->{libraryHumiditySensorValue}) + ); + } + + $self->{output}->perfdata_add( + nlabel => 'hardware.sensor.humidity.percentage', unit => '%', + instances => $result->{libraryHumiditySensorLocation}, + value => $result->{libraryHumiditySensorValue}, + warning => $warn, + critical => $crit, + min => 0, max => 100 + ); + } +} + +1; diff --git a/storage/quantum/scalar/snmp/mode/components/physicaldrive.pm b/storage/quantum/scalar/snmp/mode/components/physicaldrive.pm new file mode 100644 index 000000000..cb932fb7f --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/components/physicaldrive.pm @@ -0,0 +1,91 @@ +# +# 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 storage::quantum::scalar::snmp::mode::components::physicaldrive; + +use strict; +use warnings; +use storage::quantum::scalar::snmp::mode::components::resources qw($map_rassubsytem_status); + +my $map_cleaning_status = { + 0 => 'unknown', 1 => 'notNeeded', 2 => 'recommended', 3 => 'required', +}; + +# In MIB 'QUANTUM-MIDRANGE-TAPE-LIBRARY-MIB' +my $mapping = { + phDriveLocation => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.80.2.1.2' }, + phDriveRasStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.80.2.1.13', map => $map_rassubsytem_status }, + phDriveCleaningStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.80.2.1.15', map => $map_cleaning_status }, +}; +my $oid_physicalDriveEntry = '.1.3.6.1.4.1.3697.1.10.15.5.80.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_physicalDriveEntry, end => $mapping->{phDriveCleaningStatus}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking physical drives"); + $self->{components}->{physicaldrive} = {name => 'physical drives', total => 0, skip => 0}; + return if ($self->check_filter(section => 'physicaldrive')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_physicalDriveEntry}})) { + next if ($oid !~ /^$mapping->{phDriveRasStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_physicalDriveEntry}, instance => $instance); + + next if ($self->check_filter(section => 'physicaldrive', instance => $instance)); + $self->{components}->{physicaldrive}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "physical drive '%s' status is %s [instance: %s, cleaning status: %s]", + $result->{phDriveLocation}, $result->{phDriveRasStatus}, + $instance, $result->{phDriveCleaningStatus} + ) + ); + my $exit = $self->get_severity(section => 'physicaldrive.status', label => 'default', instance => $instance, value => $result->{phDriveRasStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Physical drive '%s' status is %s", + $result->{phDriveLocation}, $result->{phDriveRasStatus} + ) + ); + } + + $exit = $self->get_severity(section => 'physicaldrive.cleaning', label => 'cleaning', instance => $instance, value => $result->{phDriveCleaningStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Physical drive '%s' cleaning status is %s", + $result->{phDriveLocation}, $result->{phDriveCleaningStatus} + ) + ); + } + } +} + +1; diff --git a/storage/quantum/scalar/snmp/mode/components/psu.pm b/storage/quantum/scalar/snmp/mode/components/psu.pm new file mode 100644 index 000000000..8dc329ca1 --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/components/psu.pm @@ -0,0 +1,92 @@ +# +# 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 storage::quantum::scalar::snmp::mode::components::psu; + +use strict; +use warnings; + +my $map_psu_status = { + 0 => 'unknown', 1 => 'good', 2 => 'failed', 3 => 'missing' +}; + +# In MIB 'QUANTUM-MIDRANGE-TAPE-LIBRARY-MIB' +my $mapping = { + libraryPSName => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.100.2.1.2' }, + libraryPSLocation => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.100.2.1.3' }, + libraryPSStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.100.2.1.6', map => $map_psu_status }, + libraryPSPowerConsumption => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.100.2.1.7' }, +}; +my $oid_libraryPowerSupplyEntry = '.1.3.6.1.4.1.3697.1.10.15.5.100.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_libraryPowerSupplyEntry }; +} + +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')); + + my ($exit, $warn, $crit, $checked); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_libraryPowerSupplyEntry}})) { + next if ($oid !~ /^$mapping->{libraryPSStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryPowerSupplyEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s] [power consumption = %s]", + $result->{libraryPSLocation}, $result->{libraryPSStatus}, $instance, + $result->{libraryPSPowerConsumption})); + + $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{libraryPSStatus}); + 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->{libraryPSLocation}, $result->{libraryPSStatus})); + } + + next if (!defined($result->{libraryPSPowerConsumption}) || $result->{libraryPSPowerConsumption} !~ /[0-9]/); + + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'power', instance => $instance, value => $result->{libraryPSPowerConsumption}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Power supply consumption '%s' is %s W", $result->{libraryPSLocation}, $result->{libraryPSPowerConsumption}) + ); + } + + $self->{output}->perfdata_add( + nlabel => 'hardware.psu.power.watt', unit => 'W', + instances => $result->{libraryPSLocation}, + value => $result->{libraryPSPowerConsumption}, + warning => $warn, + critical => $crit, + min => 0 + ); + } +} + +1; diff --git a/storage/quantum/scalar/snmp/mode/components/resources.pm b/storage/quantum/scalar/snmp/mode/components/resources.pm new file mode 100644 index 000000000..2c32286f2 --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/components/resources.pm @@ -0,0 +1,43 @@ +# +# 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 storage::quantum::scalar::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our $map_rassubsytem_status; +our $map_sensor_status; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw($map_rassubsytem_status $map_sensor_status); + +$map_rassubsytem_status = { + 0 => 'unknown', 1 => 'redFailure', 2 => 'orangeDegraded', + 3 => 'yellowWarning', 4 => 'blueAttention', + 5 => 'greenInformation', 6 => 'greenGood', +}; + +$map_sensor_status = { + 0 => 'unknown', 1 => 'normal', 2 => 'warning', 3 => 'critical', +}; + +1; diff --git a/storage/quantum/scalar/snmp/mode/components/subsystem.pm b/storage/quantum/scalar/snmp/mode/components/subsystem.pm new file mode 100644 index 000000000..ee25033b8 --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/components/subsystem.pm @@ -0,0 +1,77 @@ +# +# 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 storage::quantum::scalar::snmp::mode::components::subsystem; + +use strict; +use warnings; +use storage::quantum::scalar::snmp::mode::components::resources qw($map_rassubsytem_status); + +# In MIB 'QUANTUM-MIDRANGE-TAPE-LIBRARY-MIB' +my $mapping = { + libraryStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.50.1', label => 'library', instance => 1 }, + driveStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.50.2', label => 'drive', instance => 2 }, + mediaStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.50.3', label => 'media', instance => 3 }, +}; +my $oid_rasSubSystem = '.1.3.6.1.4.1.3697.1.10.15.5.50'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_rasSubSystem }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "checking subsystems"); + $self->{components}->{subsystem} = {name => 'subsystems', total => 0, skip => 0}; + return if ($self->check_filter(section => 'subsystem')); + + return if (!defined($self->{results}->{$oid_rasSubSystem}) || + scalar(keys %{$self->{results}->{$oid_rasSubSystem}}) <= 0); + + foreach (values %$mapping) { + my $status = defined($self->{results}->{$oid_rasSubSystem}->{$_->{oid} . '.0'}) ? + $map_rassubsytem_status->{ $self->{results}->{$oid_rasSubSystem}->{$_->{oid} . '.0'} } : + $map_rassubsytem_status->{ $self->{results}->{$oid_rasSubSystem}->{$_->{oid}} }; + next if (!defined($status)); + + next if ($self->check_filter(section => 'subsystem', instance => $_->{instance})); + $self->{components}->{subsystem}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "subsystem '%s' status is %s [instance: %s].", + $_->{label}, $status, + $_->{instance} + ) + ); + my $exit = $self->get_severity(section => 'subsystem', label => 'default', instance => $_->{instance}, value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("subsystem '%s' status is %s", $_->{label}, $status) + ); + } + } +} + +1; diff --git a/storage/quantum/scalar/snmp/mode/components/temperature.pm b/storage/quantum/scalar/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..9ca6b45d7 --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/components/temperature.pm @@ -0,0 +1,88 @@ +# +# 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 storage::quantum::scalar::snmp::mode::components::temperature; + +use strict; +use warnings; +use storage::quantum::scalar::snmp::mode::components::resources qw($map_sensor_status); + +# In MIB 'QUANTUM-MIDRANGE-TAPE-LIBRARY-MIB' +my $mapping = { + libraryTemperatureSensorName => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.120.2.2.1.2' }, + libraryTemperatureSensorLocation => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.120.2.2.1.3' }, + libraryTemperatureSensorStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.120.2.2.1.4', map => $map_sensor_status }, + libraryTemperatureSensorValue => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.120.2.2.1.5' }, +}; +my $oid_libraryTemperatureSensorEntry = '.1.3.6.1.4.1.3697.1.10.15.5.120.2.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_libraryTemperatureSensorEntry }; +} + +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')); + + my ($exit, $warn, $crit, $checked); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_libraryTemperatureSensorEntry}})) { + next if ($oid !~ /^$mapping->{libraryTemperatureSensorStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryTemperatureSensorEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]", + $result->{libraryTemperatureSensorLocation}, $result->{libraryTemperatureSensorStatus}, $instance, + $result->{libraryTemperatureSensorValue})); + + $exit = $self->get_severity(label => 'default', section => 'temperature', instance => $instance, value => $result->{libraryTemperatureSensorStatus}); + 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->{libraryTemperatureSensorLocation}, $result->{libraryTemperatureSensorStatus})); + } + + next if (!defined($result->{libraryTemperatureSensorValue}) || $result->{libraryTemperatureSensorValue} !~ /[0-9]/); + + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{libraryTemperatureSensorValue}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Temperature '%s' is %s degree centigrade", $result->{libraryTemperatureSensorLocation}, $result->{libraryTemperatureSensorValue}) + ); + } + + $self->{output}->perfdata_add( + nlabel => 'hardware.sensor.temperature.celsius', unit => 'C', + instances => $result->{libraryTemperatureSensorLocation}, + value => $result->{libraryTemperatureSensorValue}, + warning => $warn, + critical => $crit, + ); + } +} + +1; diff --git a/storage/quantum/scalar/snmp/mode/components/voltage.pm b/storage/quantum/scalar/snmp/mode/components/voltage.pm new file mode 100644 index 000000000..f9c030bb4 --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/components/voltage.pm @@ -0,0 +1,89 @@ +# +# 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 storage::quantum::scalar::snmp::mode::components::voltage; + +use strict; +use warnings; +use storage::quantum::scalar::snmp::mode::components::resources qw($map_sensor_status); + +# In MIB 'QUANTUM-MIDRANGE-TAPE-LIBRARY-MIB' +my $mapping = { + libraryVoltageSensorName => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.110.2.1.2' }, + libraryVoltageSensorLocation => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.110.2.1.3' }, + libraryVoltageSensorStatus => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.110.2.1.5', map => $map_sensor_status }, + libraryVoltageSensorValue => { oid => '.1.3.6.1.4.1.3697.1.10.15.5.110.2.1.6' }, # in mV +}; +my $oid_libraryVoltageSensorEntry = '.1.3.6.1.4.1.3697.1.10.15.5.110.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_libraryVoltageSensorEntry }; +} + +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')); + + my ($exit, $warn, $crit, $checked); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_libraryVoltageSensorEntry}})) { + next if ($oid !~ /^$mapping->{libraryVoltageSensorStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryVoltageSensorEntry}, instance => $instance); + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + $self->{components}->{voltage}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s] [value = %s]", + $result->{libraryVoltageSensorLocation}, $result->{libraryVoltageSensorStatus}, $instance, + $result->{libraryVoltageSensorValue})); + + $exit = $self->get_severity(label => 'default', section => 'voltage', instance => $instance, value => $result->{libraryVoltageSensorStatus}); + 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->{libraryVoltageSensorLocation}, $result->{libraryVoltageSensorStatus})); + } + + next if (!defined($result->{libraryVoltageSensorValue}) || $result->{libraryVoltageSensorValue} !~ /[0-9]/); + + $result->{libraryVoltageSensorValue} /= 1000; + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{libraryVoltageSensorValue}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Voltage '%s' is %s V", $result->{libraryVoltageSensorLocation}, $result->{libraryVoltageSensorValue}) + ); + } + + $self->{output}->perfdata_add( + nlabel => 'hardware.sensor.voltage.volt', unit => 'V', + instances => $result->{libraryVoltageSensorLocation}, + value => $result->{libraryVoltageSensorValue}, + warning => $warn, + critical => $crit, + ); + } +} + +1; diff --git a/storage/quantum/scalar/snmp/mode/hardware.pm b/storage/quantum/scalar/snmp/mode/hardware.pm new file mode 100644 index 000000000..c167cd6a6 --- /dev/null +++ b/storage/quantum/scalar/snmp/mode/hardware.pm @@ -0,0 +1,127 @@ +# +# 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 storage::quantum::scalar::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} = '^(?:subsystem|physicaldrive\.(status|cleaning)|psu|voltage|humidity|temperature)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature|humidity|power|voltage)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['normal', 'OK'], + ['greenGood', 'OK'], + ['unknown', 'UNKNOWN'], + ['redFailure', 'CRITICAL'], + ['orangeDegraded', 'WARNING'], + ['yellowWarning', 'WARNING'], + ['blueAttention', 'WARNING'], + ['greenInformation', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ], + cleaning => [ + ['unknown', 'UNKNOWN'], + ['notNeeded', 'OK'], + ['recommended', 'WARNING'], + ['required', 'CRITICAL'], + ], + psu => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['failed', 'CRITICAL'], + ['missing', 'WARNING'], + ], + }; + + $self->{components_path} = 'storage::quantum::scalar::snmp::mode::components'; + $self->{components_module} = ['global', 'subsystem', 'physicaldrive', 'psu', 'temperature', 'humidity', 'voltage']; +} + +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, no_absent => 1, force_new_perfdata => 1); + bless $self, $class; + + $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: 'global', 'subsystem', 'physicaldrive', 'psu', 'voltage', 'humidity', 'temperature'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=subsystem) +Can also exclude specific instance: --filter=physicaldrive,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='physicaldrive.status,OK,yellowWarning' + +=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/storage/quantum/scalar/snmp/plugin.pm b/storage/quantum/scalar/snmp/plugin.pm index 0e91e5433..f8bb61a24 100644 --- a/storage/quantum/scalar/snmp/plugin.pm +++ b/storage/quantum/scalar/snmp/plugin.pm @@ -31,8 +31,8 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'hardware' => 'centreon::common::adic::tape::snmp::mode::hardware', - ); + 'hardware' => 'storage::quantum::scalar::snmp::mode::hardware', + ); return $self; } @@ -43,6 +43,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Quantum Scalar (i6000, i500, ...) in SNMP. +Check Quantum Scalar in SNMP. =cut