From 8602a938cd324dd641469f163a291bb516da931e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 24 Aug 2016 12:06:32 +0200 Subject: [PATCH] + add quantum scalar plugin in snmp --- .../tape/snmp/mode/components/component.pm | 78 ++++++++++++ .../adic/tape/snmp/mode/components/fan.pm | 117 ++++++++++++++++++ .../adic/tape/snmp/mode/components/global.pm | 30 +++-- .../snmp/mode/components/physicaldrive.pm | 60 +++++---- .../tape/snmp/mode/components/temperature.pm | 117 ++++++++++++++++++ .../common/adic/tape/snmp/mode/hardware.pm | 41 +++++- storage/quantum/scalar/snmp/plugin.pm | 48 +++++++ 7 files changed, 458 insertions(+), 33 deletions(-) create mode 100644 centreon/common/adic/tape/snmp/mode/components/component.pm create mode 100644 centreon/common/adic/tape/snmp/mode/components/fan.pm create mode 100644 centreon/common/adic/tape/snmp/mode/components/temperature.pm create mode 100644 storage/quantum/scalar/snmp/plugin.pm diff --git a/centreon/common/adic/tape/snmp/mode/components/component.pm b/centreon/common/adic/tape/snmp/mode/components/component.pm new file mode 100644 index 000000000..50a3bc195 --- /dev/null +++ b/centreon/common/adic/tape/snmp/mode/components/component.pm @@ -0,0 +1,78 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::component; + +use strict; +use warnings; +use centreon::plugins::misc; + +my %map_status = ( + 1 => 'unknown', + 2 => 'unused', + 3 => 'ok', + 4 => 'warning', + 5 => 'failed', +); + +# In MIB 'ADIC-INTELLIGENT-STORAGE-MIB' +my $mapping = { + componentDisplayName => { oid => '.1.3.6.1.4.1.3764.1.1.30.10.1.3' }, + componentStatus => { oid => '.1.3.6.1.4.1.3764.1.1.30.10.1.8', map => \%map_status }, +}; +my $oid_componentEntry = '.1.3.6.1.4.1.3764.1.1.30.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_componentEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking components"); + $self->{components}->{component} = {name => 'components', total => 0, skip => 0}; + return if ($self->check_filter(section => 'component')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_componentEntry}})) { + next if ($oid !~ /^$mapping->{componentStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_componentEntry}, instance => $instance); + + next if ($self->check_filter(section => 'component', instance => $result->{componentDisplayName})); + $self->{components}->{component}->{total}++; + + $result->{componentDisplayName} =~ s/\s+/ /g; + $result->{componentDisplayName} = centreon::plugins::misc::trim($result->{componentDisplayName}); + $self->{output}->output_add(long_msg => sprintf("component '%s' status is %s [instance: %s].", + $result->{componentDisplayName}, $result->{componentStatus}, + $result->{componentDisplayName} + )); + my $exit = $self->get_severity(section => 'component', value => $result->{componentStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Component '%s' status is %s", + $result->{componentDisplayName}, $result->{componentStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon/common/adic/tape/snmp/mode/components/fan.pm b/centreon/common/adic/tape/snmp/mode/components/fan.pm new file mode 100644 index 000000000..2b0d91828 --- /dev/null +++ b/centreon/common/adic/tape/snmp/mode/components/fan.pm @@ -0,0 +1,117 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::fan; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'nominal', + 2 => 'warningLow', 3 => 'warningHigh', + 4 => 'alarmLow', 5 => 'alarmHigh', + 6 => 'notInstalled', 7 => 'noData', +); + +my $mapping = { + coolingFanName => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.2' }, + coolingFanStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.3', map => \%map_status }, + coolingFanRPM => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.4' }, + coolingFanWarningHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.8' }, + coolingFanNominalHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.6' }, + coolingFanNominalLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.5' }, + coolingFanWarningLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.7' }, + coolingFanLocation => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.9' }, +}; +my $oid_coolingFanEntry = '.1.3.6.1.4.1.3764.1.1.200.200.40.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_coolingFanEntry }; +} + +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_coolingFanEntry}})) { + next if ($oid !~ /^$mapping->{coolingFanStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingFanEntry}, instance => $instance); + + $result->{coolingFanName} =~ s/\s+/ /g; + $result->{coolingFanName} = centreon::plugins::misc::trim($result->{coolingFanName}); + $result->{coolingFanLocation} =~ s/,/_/g; + my $id = $result->{coolingFanName} . '_' . $result->{coolingFanLocation}; + + next if ($self->check_filter(section => 'fan', instance => $id)); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s] [value = %s]", + $id, $result->{coolingFanStatus}, $id, + $result->{coolingFanRPM})); + + my $exit = $self->get_severity(label => 'sensor', section => 'fan', value => $result->{coolingFanStatus}); + 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'", $id, $result->{coolingFanStatus})); + next; + } + + if (defined($result->{coolingFanRPM}) && $result->{coolingFanRPM} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{coolingFanRPM}); + if ($checked == 0) { + $result->{coolingFanNominalLo} = (defined($result->{coolingFanNominalLo}) && $result->{coolingFanNominalLo} =~ /[0-9]/) ? + $result->{coolingFanNominalLo} : ''; + $result->{coolingFanWarningLo} = (defined($result->{coolingFanWarningLo}) && $result->{coolingFanWarningLo} =~ /[0-9]/) ? + $result->{coolingFanWarningLo} : ''; + $result->{coolingFanNominalHi} = (defined($result->{coolingFanNominalHi}) && $result->{coolingFanNominalHi} =~ /[0-9]/) ? + $result->{coolingFanNominalHi} : ''; + $result->{coolingFanWarningHi} = (defined($result->{coolingFanWarningHi}) && $result->{coolingFanWarningHi} =~ /[0-9]/) ? + $result->{coolingFanWarningHi} : ''; + my $warn_th = $result->{coolingFanNominalLo} . ':' . $result->{coolingFanNominalHi}; + my $crit_th = $result->{coolingFanWarningLo} . ':' . $result->{coolingFanWarningHi}; + $self->{perfdata}->threshold_validate(label => 'warning-fan-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-fan-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{coolingFanRPM}, threshold => [ { label => 'critical-fan-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-fan-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-fan-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-fan-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan '%s' is %s rpm", $id, $result->{coolingFanRPM})); + } + $self->{output}->perfdata_add(label => 'fan_' . $id, unit => 'rpm', + value => $result->{coolingFanRPM}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon/common/adic/tape/snmp/mode/components/global.pm b/centreon/common/adic/tape/snmp/mode/components/global.pm index cbc31f51c..29914680d 100644 --- a/centreon/common/adic/tape/snmp/mode/components/global.pm +++ b/centreon/common/adic/tape/snmp/mode/components/global.pm @@ -32,16 +32,29 @@ my %map_status = ( 6 => 'unknown', 7 => 'invalid', ); +my %map_agent_status = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'ok', + 4 => 'non-critical', + 5 => 'critical', + 6 => 'non-recoverable', +); # In MIB 'ADIC-TAPE-LIBRARY-MIB' my $mapping = { - libraryGlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.1.8', map => \%map_status }, + GlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.1.8', map => \%map_status }, # libraryGlobalStatus +}; +# In MIB 'ADIC-INTELLIGENT-STORAGE-MIB' +my $mapping2 = { + GlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.1.20.1', map => \%map_agent_status }, # agentGlobalStatus }; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $mapping->{libraryGlobalStatus}->{oid} }; + push @{$self->{request}}, { oid => $mapping->{GlobalStatus}->{oid} }, + { oid => $mapping2->{GlobalStatus}->{oid} }; } sub check { @@ -52,8 +65,11 @@ sub check { return if ($self->check_filter(section => 'global')); my $instance = '0'; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{libraryGlobalStatus}->{oid}}, instance => $instance); - if (!defined($result->{libraryGlobalStatus})) { + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{GlobalStatus}->{oid}}, instance => $instance); + if (!defined($result->{GlobalStatus})) { + $result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{GlobalStatus}->{oid}}, instance => $instance); + } + if (!defined($result->{GlobalStatus})) { $self->{output}->output_add(long_msg => "skipping global status: no value."); return ; } @@ -62,13 +78,13 @@ sub check { $self->{components}->{global}->{total}++; $self->{output}->output_add(long_msg => sprintf("library global status is %s [instance: %s].", - $result->{libraryGlobalStatus}, $instance + $result->{GlobalStatus}, $instance )); - my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{libraryGlobalStatus}); + my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{GlobalStatus}); 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", - $result->{libraryGlobalStatus})); + $result->{GlobalStatus})); } } diff --git a/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm b/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm index f839dd943..650f04205 100644 --- a/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm +++ b/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm @@ -34,18 +34,30 @@ my %map_status = ( 7 => 'invalid', ); -# In MIB 'ADIC-TAPE-LIBRARY-MIB' my $mapping = { - phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.2' }, - phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.3' }, - phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.11', map => \%map_status }, + # 'ADIC-TAPE-LIBRARY-MIB' + adic_tape => { + phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.2' }, + phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.3' }, + phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.11', map => \%map_status }, + }, + # 'ADIC-MANAGEMENT-MIB' + adic_management => { + phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.8' }, + phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.7' }, # phDriveProduct + phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.31', map => \%map_status }, + } }; -my $oid_physicalDriveEntry = '.1.3.6.1.4.1.3764.1.10.10.11.3.1'; + +my %oid_table = ( + adic_tape => '.1.3.6.1.4.1.3764.1.10.10.11.3.1', # physicalDriveEntry + adic_management => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1', # phDriveEntry +); sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_physicalDriveEntry }; + push @{$self->{request}}, { oid => $oid_table{adic_tape} }, { oid => $oid_table{adic_management} }; } sub check { @@ -54,25 +66,29 @@ sub check { $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 $label (keys %{$mapping}) { + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_table{$label}}})) { + next if ($oid !~ /^$mapping->{$label}->{phDriveRasStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping->{$label}, results => $self->{results}->{$oid_table{$label}}, instance => $instance); - 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); + $result->{phDriveSerialNumber} = centreon::plugins::misc::trim($result->{phDriveSerialNumber}); - next if ($self->check_filter(section => 'physicaldrive', instance => $instance)); - $self->{components}->{physicaldrive}->{total}++; + next if ($self->check_filter(section => 'physicaldrive', instance => $result->{phDriveSerialNumber})); + $self->{components}->{physicaldrive}->{total}++; - $self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is %s [instance: %s, model: %s, serial: %s].", - $instance, $result->{phDriveRasStatus}, - $instance, centreon::plugins::misc::trim($result->{phDriveModel}), - centreon::plugins::misc::trim($result->{phDriveSerialNumber}) - )); - my $exit = $self->get_severity(section => 'physicaldrive', label => 'default', 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", - $instance, $result->{phDriveRasStatus})); + $self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is %s [instance: %s, model: %s, serial: %s].", + $result->{phDriveSerialNumber}, $result->{phDriveRasStatus}, + $result->{phDriveSerialNumber}, centreon::plugins::misc::trim($result->{phDriveModel}), + centreon::plugins::misc::trim($result->{phDriveSerialNumber}) + )); + my $exit = $self->get_severity(section => 'physicaldrive', label => 'default', 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->{phDriveSerialNumber}, $result->{phDriveRasStatus})); + } } } } diff --git a/centreon/common/adic/tape/snmp/mode/components/temperature.pm b/centreon/common/adic/tape/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..49821f26a --- /dev/null +++ b/centreon/common/adic/tape/snmp/mode/components/temperature.pm @@ -0,0 +1,117 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::temperature; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'nominal', + 2 => 'warningLow', 3 => 'warningHigh', + 4 => 'alarmLow', 5 => 'alarmHigh', + 6 => 'notInstalled', 7 => 'noData', +); + +my $mapping = { + temperatureSensorName => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.2' }, + temperatureSensorStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.3', map => \%map_status }, + temperatureSensorDegreesCelsius => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.4' }, + temperatureSensorWarningHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.8' }, + temperatureSensorNominalHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.6' }, + temperatureSensorNominalLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.5' }, + temperatureSensorWarningLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.7' }, + temperatureSensorLocation => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.9' }, +}; +my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.3764.1.1.200.200.30.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_temperatureSensorEntry }; +} + +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_temperatureSensorEntry}})) { + next if ($oid !~ /^$mapping->{temperatureSensorStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureSensorEntry}, instance => $instance); + + $result->{temperatureSensorName} =~ s/\s+/ /g; + $result->{temperatureSensorName} = centreon::plugins::misc::trim($result->{temperatureSensorName}); + $result->{temperatureSensorLocation} =~ s/,/_/g; + my $id = $result->{temperatureSensorName} . '_' . $result->{temperatureSensorLocation}; + + next if ($self->check_filter(section => 'temperature', instance => $id)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]", + $id, $result->{temperatureSensorStatus}, $id, + $result->{temperatureSensorDegreesCelsius})); + + my $exit = $self->get_severity(label => 'sensor', section => 'temperature', value => $result->{temperatureSensorStatus}); + 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'", $id, $result->{temperatureSensorStatus})); + next; + } + + if (defined($result->{temperatureSensorDegreesCelsius}) && $result->{temperatureSensorDegreesCelsius} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureSensorDegreesCelsius}); + if ($checked == 0) { + $result->{temperatureSensorNominalLo} = (defined($result->{temperatureSensorNominalLo}) && $result->{temperatureSensorNominalLo} =~ /[0-9]/) ? + $result->{temperatureSensorNominalLo} : ''; + $result->{temperatureSensorWarningLo} = (defined($result->{temperatureSensorWarningLo}) && $result->{temperatureSensorWarningLo} =~ /[0-9]/) ? + $result->{temperatureSensorWarningLo} : ''; + $result->{temperatureSensorNominalHi} = (defined($result->{temperatureSensorNominalHi}) && $result->{temperatureSensorNominalHi} =~ /[0-9]/) ? + $result->{temperatureSensorNominalHi} : ''; + $result->{temperatureSensorWarningHi} = (defined($result->{temperatureSensorWarningHi}) && $result->{temperatureSensorWarningHi} =~ /[0-9]/) ? + $result->{temperatureSensorWarningHi} : ''; + my $warn_th = $result->{temperatureSensorNominalLo} . ':' . $result->{temperatureSensorNominalHi}; + my $crit_th = $result->{temperatureSensorWarningLo} . ':' . $result->{temperatureSensorWarningHi}; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{temperatureSensorDegreesCelsius}, 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 => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' is %s degree centigrade", $id, $result->{temperatureSensorDegreesCelsius})); + } + $self->{output}->perfdata_add(label => 'temp_' . $id, unit => 'C', + value => $result->{temperatureSensorDegreesCelsius}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon/common/adic/tape/snmp/mode/hardware.pm b/centreon/common/adic/tape/snmp/mode/hardware.pm index 9a1ae3f0d..76683d9fd 100644 --- a/centreon/common/adic/tape/snmp/mode/hardware.pm +++ b/centreon/common/adic/tape/snmp/mode/hardware.pm @@ -28,7 +28,8 @@ use warnings; sub set_system { my ($self, %options) = @_; - $self->{regexp_threshold_overload_check_section_option} = '^(global|physicaldrive|subsystem)$'; + $self->{regexp_threshold_overload_check_section_option} = '^(global|physicaldrive|subsystem|component|temperature)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; $self->{cb_hook2} = 'snmp_execute'; @@ -41,11 +42,33 @@ sub set_system { ['informational', 'OK'], ['unknown', 'UNKNOWN'], ['invalid', 'CRITICAL'], + + ['other', 'OK'], + ['ok', 'OK'], + ['non-critical', 'WARNING'], + ['critical', 'CRITICAL'], + ['non-recoverable', 'CRITICAL'], + ], + component => [ + ['unknown', 'UNKNOWN'], + ['unused', 'OK'], + ['ok', 'OK'], + ['warning', 'WARNING'], + ['failed', 'CRITICAL'], + ], + sensor => [ + ['nominal', 'OK'], + ['warningLow', 'WARNING'], + ['warningHigh', 'CRITICAL'], + ['alarmLow', 'CRITICAL'], + ['alarmHigh', 'CRITICAL'], + ['notInstalled', 'OK'], + ['noData', 'OK'], ], }; $self->{components_path} = 'centreon::common::adic::tape::snmp::mode::components'; - $self->{components_module} = ['global', 'physicaldrive', 'subsystem']; + $self->{components_module} = ['global', 'physicaldrive', 'subsystem', 'component', 'temperature', 'fan']; } sub snmp_execute { @@ -57,7 +80,7 @@ sub snmp_execute { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; @@ -81,7 +104,7 @@ Check Hardware. =item B<--component> Which component to check (Default: '.*'). -Can be: 'global', 'physicaldrive', 'subsystem'. +Can be: 'global', 'physicaldrive', 'subsystem', 'component', 'temperature', 'fan'. =item B<--filter> @@ -99,6 +122,16 @@ Set to overload default threshold values (syntax: section,[instance,]status,rege It used before default thresholds (order stays). Example: --threshold-overload='physicaldrive,OK,invalid' +=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 \ No newline at end of file diff --git a/storage/quantum/scalar/snmp/plugin.pm b/storage/quantum/scalar/snmp/plugin.pm new file mode 100644 index 000000000..ae3b83bc2 --- /dev/null +++ b/storage/quantum/scalar/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::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 Quantum Scalar (i6000, i500, ...) in SNMP. + +=cut