From 50dff05054b7ff8880a3d41226c322f47b2bfa0b Mon Sep 17 00:00:00 2001 From: Colin GAGNAIRE Date: Fri, 9 Mar 2018 18:10:25 +0100 Subject: [PATCH] add ibm fs900 plugin --- storage/ibm/fs900/snmp/mode/arraysstatus.pm | 172 +++++++++++++++ storage/ibm/fs900/snmp/mode/arraysusage.pm | 183 ++++++++++++++++ .../ibm/fs900/snmp/mode/components/battery.pm | 114 ++++++++++ storage/ibm/fs900/snmp/mode/components/fan.pm | 114 ++++++++++ .../snmp/mode/components/fibrechannel.pm | 66 ++++++ .../fs900/snmp/mode/components/flashcard.pm | 116 ++++++++++ storage/ibm/fs900/snmp/mode/components/psu.pm | 103 +++++++++ storage/ibm/fs900/snmp/mode/fcusage.pm | 205 ++++++++++++++++++ storage/ibm/fs900/snmp/mode/hardware.pm | 122 +++++++++++ storage/ibm/fs900/snmp/plugin.pm | 51 +++++ 10 files changed, 1246 insertions(+) create mode 100644 storage/ibm/fs900/snmp/mode/arraysstatus.pm create mode 100644 storage/ibm/fs900/snmp/mode/arraysusage.pm create mode 100644 storage/ibm/fs900/snmp/mode/components/battery.pm create mode 100644 storage/ibm/fs900/snmp/mode/components/fan.pm create mode 100644 storage/ibm/fs900/snmp/mode/components/fibrechannel.pm create mode 100644 storage/ibm/fs900/snmp/mode/components/flashcard.pm create mode 100644 storage/ibm/fs900/snmp/mode/components/psu.pm create mode 100644 storage/ibm/fs900/snmp/mode/fcusage.pm create mode 100644 storage/ibm/fs900/snmp/mode/hardware.pm create mode 100644 storage/ibm/fs900/snmp/plugin.pm diff --git a/storage/ibm/fs900/snmp/mode/arraysstatus.pm b/storage/ibm/fs900/snmp/mode/arraysstatus.pm new file mode 100644 index 000000000..c43e6ea60 --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/arraysstatus.pm @@ -0,0 +1,172 @@ +# +# 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 storage::ibm::fs900::snmp::mode::arraysstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = sprintf("Status is '%s'", $self->{result_values}->{status}); + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_arrayStatus'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 1, cb_prefix_output => 'prefix_output', message_multiple => "All arrays metrics are ok", message_separator => ' - ' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'arrayStatus' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'vdisk-count', set => { + key_values => [ { name => 'arrayVDiskCount' }, { name => 'arrayId' } ], + output_template => 'VDisk count: %s', + perfdatas => [ + { label => 'vdisk_count', value => 'arrayVDiskCount_absolute', template => '%s', label_extra_instance => 1, + instance_use => 'arrayId_absolute', min => 0 }, + ], + } + }, + ]; +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Array '" . $options{instance_value}->{arrayId} . "' "; +} + +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 => + { + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /degraded/i' }, + }); + + return $self; +} + +my $mapping = { + arrayId => { oid => '.1.3.6.1.4.1.2.6.255.1.1.1.52.1.2' }, + arrayStatus => { oid => '.1.3.6.1.4.1.2.6.255.1.1.1.52.1.3' }, + arrayVDiskCount => { oid => '.1.3.6.1.4.1.2.6.255.1.1.1.52.1.9' }, +}; + +my $oid_arrayIndex = '.1.3.6.1.4.1.2.6.255.1.1.1.52.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table(oid => $oid_arrayIndex, + nothing_quit => 1); + + $self->{global} = {}; + + foreach my $oid (keys %{$snmp_result}) { + next if ($oid !~ /^$mapping->{arrayId}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + $self->{global}->{$result->{arrayId}} = $result; + } +} + +1; + +__END__ + +=head1 MODE + +Check arrays status. + +=over 8 + +=item B<--warning-status> + +Set warning threshold for status. +'status' can be: 'online', 'offline', 'excluded', 'degraded'. + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /degraded/i'). +'status' can be: 'online', 'offline', 'excluded', 'degraded'. + +=item B<--warning-vdisk-count> + +Threshold warning for VDisks count. + +=item B<--critical-vdisk-count> + +Threshold critical for VDisks count. + +=back + +=cut diff --git a/storage/ibm/fs900/snmp/mode/arraysusage.pm b/storage/ibm/fs900/snmp/mode/arraysusage.pm new file mode 100644 index 000000000..28d9d0d89 --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/arraysusage.pm @@ -0,0 +1,183 @@ +# +# 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 storage::ibm::fs900::snmp::mode::arraysusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + + $self->{output}->perfdata_add(label => "used" . $extra_label, + unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-usage'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-usage'), + min => 0, + max => $self->{result_values}->{total}, + ); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{used_prct}, + threshold => [ { label => 'critical-usage', exit_litteral => 'critical' }, + { label => 'warning-usage', exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($used, $used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($free, $free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + + my $msg = sprintf("Usage Total: %s %s, Used: %s %s (%.2f%%), Free: %s %s (%.2f%%)", $total, $total_unit, $used, $used_unit, $self->{result_values}->{used_prct}, $free, $free_unit, $self->{result_values}->{free_prct}); + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + ($self->{result_values}->{total}, $self->{result_values}->{total_unit}) = (split(' ', $options{new_datas}->{$self->{instance} . '_arrayCapacity'})); + ($self->{result_values}->{used}, $self->{result_values}->{used_unit}) = (split(' ', $options{new_datas}->{$self->{instance} . '_arrayCapacityUsed'})); + ($self->{result_values}->{free}, $self->{result_values}->{free_unit}) = (split(' ', $options{new_datas}->{$self->{instance} . '_arrayCapacityFree'})); + + $self->{result_values}->{total} = storage::ibm::fs900::snmp::mode::arraysusage->change_to_bytes(value => $self->{result_values}->{total}, unit => $self->{result_values}->{total_unit}); + $self->{result_values}->{used} = storage::ibm::fs900::snmp::mode::arraysusage->change_to_bytes(value => $self->{result_values}->{used}, unit => $self->{result_values}->{used_unit}); + $self->{result_values}->{free} = storage::ibm::fs900::snmp::mode::arraysusage->change_to_bytes(value => $self->{result_values}->{free}, unit => $self->{result_values}->{free_unit}); + + $self->{result_values}->{used_prct} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{free_prct} = 100 - $self->{result_values}->{used_prct}; + + return 0; +} + +sub change_to_bytes { + my ($self, %options) = @_; + + my $value = ''; + + if ($options{unit} =~ /KiB*/i) { + $value = $options{value} * 1024; + } elsif ($options{unit} =~ /MiB*/i) { + $value = $options{value} * 1024 * 1024; + } elsif ($options{unit} =~ /GiB*/i) { + $value = $options{value} * 1024 * 1024 * 1024; + } elsif ($options{unit} =~ /TiB*/i) { + $value = $options{value} * 1024 * 1024 * 1024 * 1024; + } + + return $value +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 1, cb_prefix_output => 'prefix_output', message_multiple => "All arrays usage are ok" } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'usage', set => { + key_values => [ { name => 'arrayCapacity' }, { name => 'arrayCapacityUsed' }, { name => 'arrayCapacityFree' }, { name => 'arrayId' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Array '" . $options{instance_value}->{arrayId} . "' "; +} + +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; +} + +my $mapping = { + arrayId => { oid => '.1.3.6.1.4.1.2.6.255.1.1.1.52.1.2' }, + arrayCapacity => { oid => '.1.3.6.1.4.1.2.6.255.1.1.1.52.1.4' }, + arrayCapacityUsed => { oid => '.1.3.6.1.4.1.2.6.255.1.1.1.52.1.5' }, + arrayCapacityFree => { oid => '.1.3.6.1.4.1.2.6.255.1.1.1.52.1.6' }, +}; + +my $oid_arrayIndex = '.1.3.6.1.4.1.2.6.255.1.1.1.52.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table(oid => $oid_arrayIndex, + nothing_quit => 1); + + $self->{global} = {}; + + foreach my $oid (keys %{$snmp_result}) { + next if ($oid !~ /^$mapping->{arrayId}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + $self->{global}->{$result->{arrayId}} = $result; + } +} + +1; + +__END__ + +=head1 MODE + +Check arrays usage. + +=over 8 + +=item B<--warning-usage> + +Threshold warning. + +=item B<--critical-usage> + +Threshold critical. + +=back + +=cut diff --git a/storage/ibm/fs900/snmp/mode/components/battery.pm b/storage/ibm/fs900/snmp/mode/components/battery.pm new file mode 100644 index 000000000..d52d9ea4a --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/components/battery.pm @@ -0,0 +1,114 @@ +# +# 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 storage::ibm::fs900::snmp::mode::components::battery; + +use strict; +use warnings; + +# In MIB 'IBM-FLASHSYSTEM.MIB' +my $mapping = { + batteryObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.4.10.1.2' }, + batteryCell1 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.4.10.1.4' }, #mV + batteryCell2 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.4.10.1.5' }, #mV + batteryCell3 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.4.10.1.6' }, #mV + batteryTotal => { oid => '.1.3.6.1.4.1.2.6.255.1.1.4.10.1.7' }, #mV + batteryChgCurr => { oid => '.1.3.6.1.4.1.2.6.255.1.1.4.10.1.8' }, + batteryRmngCap => { oid => '.1.3.6.1.4.1.2.6.255.1.1.4.10.1.9' }, + batteryFullCap => { oid => '.1.3.6.1.4.1.2.6.255.1.1.4.10.1.10' }, +}; +my $oid_batteryTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.4.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_batteryTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking batteries"); + $self->{components}->{battery} = {name => 'batteries', total => 0, skip => 0}; + return if ($self->check_filter(section => 'battery')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_batteryTableEntry}})) { + next if ($oid !~ /^$mapping->{batteryObject}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_batteryTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'battery', instance => $instance)); + + $self->{components}->{battery}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Battery '%s' [instance = %s, cell1 = %s mV, cell2 = %s mV, cell3 = %s mV, total = %s mV, current = %s, capacity remaining = %s, capacity full = %s]", + $result->{batteryObject}, $instance, $result->{batteryCell1}, $result->{batteryCell2}, $result->{batteryCell3}, + $result->{batteryTotal}, $result->{batteryChgCurr}, $result->{batteryRmngCap}, $result->{batteryFullCap})); + + foreach my $cell ('batteryCell1', 'batteryCell2', 'batteryCell3', 'batteryTotal') { + if (defined($result->{$cell}) && $result->{$cell} =~ /[0-9]/) { + my $pretty_cell = $cell; + $pretty_cell =~ s/battery//; + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'battery.cell', instance => $instance, value => $result->{$cell}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Battery '%s' cell '%s' voltage is %s mV", $instance, lc($pretty_cell), $result->{$cell})); + } + $self->{output}->perfdata_add(label => 'battery_voltage_' . $instance . '_' . lc($pretty_cell), + unit => 'mV', + value => $result->{$cell}, + warning => $warn, + critical => $crit, + min => 0, + ); + } + } + + if (defined($result->{batteryChgCurr}) && $result->{batteryChgCurr} =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'battery.current', instance => $instance, value => $result->{batteryChgCurr}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Battery '%s' current is %s", $instance, $result->{batteryChgCurr})); + } + $self->{output}->perfdata_add(label => 'battery_current_' . $instance, + value => $result->{batteryChgCurr}, + warning => $warn, + critical => $crit, + min => 0, + ); + } + + if (defined($result->{batteryRmngCap}) && $result->{batteryRmngCap} =~ /[0-9]/ && defined($result->{batteryFullCap}) && $result->{batteryFullCap} =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'battery.capacity', instance => $instance, value => $result->{batteryRmngCap}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Battery '%s' capacity is %s on %s", $instance, $result->{batteryRmngCap}, $result->{batteryFullCap})); + } + $self->{output}->perfdata_add(label => 'battery_capacity_' . $instance, + value => $result->{batteryRmngCap}, + warning => $warn, + critical => $crit, + min => 0, + max => $result->{batteryFullCap}, + ); + } + } +} + +1; \ No newline at end of file diff --git a/storage/ibm/fs900/snmp/mode/components/fan.pm b/storage/ibm/fs900/snmp/mode/components/fan.pm new file mode 100644 index 000000000..d6b20aba2 --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/components/fan.pm @@ -0,0 +1,114 @@ +# +# 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 storage::ibm::fs900::snmp::mode::components::fan; + +use strict; +use warnings; + +# In MIB 'IBM-FLASHSYSTEM.MIB' +my $mapping = { + fanObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.2' }, + fanPWM => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.4' }, + fanTemp => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.5' }, + fan0 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.6' }, + fan1 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.7' }, + fan2 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.8' }, + fan3 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.9' }, +}; +my $oid_fanTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.6.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_fanTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fan modules"); + $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_fanTableEntry}})) { + next if ($oid !~ /^$mapping->{fanObject}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance)); + + $self->{components}->{fan}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Fan module '%s' [instance = %s, PWM = %s%%, temperature = %sC, fan0 speed = %s%%, fan1 speed = %s%%, fan2 speed = %s%%, fan3 speed = %s%%]", + $result->{fanObject}, $instance, $result->{fanPWM}, $result->{fanTemp} / 10, $result->{fan0}, $result->{fan1}, $result->{fan2}, $result->{fan3})); + + + if (defined($result->{fanPWM}) && $result->{fanPWM} =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'fan.pwm', instance => $instance, value => $result->{fanPWM}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan module '%s' PWM is %s%", $instance, $result->{fanPWM})); + } + $self->{output}->perfdata_add(label => 'fan_pwm_' . $instance, + unit => '%', + value => $result->{fanPWM}, + warning => $warn, + critical => $crit, + min => 0, + max => 100, + ); + } + + if (defined($result->{fanTemp}) && $result->{fanTemp} =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'fan.temperature', instance => $instance, value => $result->{fanTemp} / 10); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan module '%s' temperature is %s degree centigrade", $instance, $result->{fanTemp} / 10)); + } + $self->{output}->perfdata_add(label => 'fan_temp_' . $instance, + unit => 'C', + value => $result->{fanTemp} / 10, + warning => $warn, + critical => $crit, + min => 0, + ); + } + + foreach my $fan ('fan0', 'fan1', 'fan2', 'fan3') { + if (defined($result->{$fan}) && $result->{$fan} =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, value => $result->{$fan}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan module '%s' fan '%s' speed is %s%%", $instance, $fan, $result->{$fan})); + } + $self->{output}->perfdata_add(label => 'fan_speed_' . $instance . '_' . $fan, + unit => '%', + value => $result->{$fan}, + warning => $warn, + critical => $crit, + min => 0, + max => 100, + ); + } + } + } +} + +1; \ No newline at end of file diff --git a/storage/ibm/fs900/snmp/mode/components/fibrechannel.pm b/storage/ibm/fs900/snmp/mode/components/fibrechannel.pm new file mode 100644 index 000000000..b482f53bf --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/components/fibrechannel.pm @@ -0,0 +1,66 @@ +# +# 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 storage::ibm::fs900::snmp::mode::components::fibrechannel; + +use strict; +use warnings; + +# In MIB 'IBM-FLASHSYSTEM.MIB' +my $mapping = { + fcObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.2' }, + fcState => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.5' }, +}; +my $oid_fcTableIndex = '.1.3.6.1.4.1.2.6.255.1.1.2.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_fcTableIndex }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fibre channels"); + $self->{components}->{fibrechannel} = {name => 'fibrechannels', total => 0, skip => 0}; + return if ($self->check_filter(section => 'fibrechannel')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fcTableIndex}})) { + next if ($oid !~ /^$mapping->{fcObject}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fcTableIndex}, instance => $instance); + + next if ($self->check_filter(section => 'fibrechannel', instance => $instance)); + + $self->{components}->{fibrechannel}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Fibre channel '%s' [instance = %s, state = %s]", + $result->{fcObject}, $instance, $result->{fcState})); + + my $exit = $self->get_severity(section => 'fibrechannel', value => $result->{fcState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fibre channel '%s' state is %s", + $instance, $result->{fcState})); + } + } +} + +1; \ No newline at end of file diff --git a/storage/ibm/fs900/snmp/mode/components/flashcard.pm b/storage/ibm/fs900/snmp/mode/components/flashcard.pm new file mode 100644 index 000000000..4ffaa65cc --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/components/flashcard.pm @@ -0,0 +1,116 @@ +# +# 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 storage::ibm::fs900::snmp::mode::components::flashcard; + +use strict; +use warnings; + +# In MIB 'IBM-FLASHSYSTEM.MIB' +my $mapping = { + flashObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.2' }, + flashTempGW => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.7' }, + flashTempFPGA0 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.8' }, + flashTempFPGA1 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.9' }, + flashTempFPGA2 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.10' }, + flashTempFPGA3 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.11' }, + flashPower => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.12' }, + flashOverallHealth => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.14' }, +}; +my $oid_flashcardTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.3.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_flashcardTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking flashcards"); + $self->{components}->{flashcard} = {name => 'flashcards', total => 0, skip => 0}; + return if ($self->check_filter(section => 'flashcard')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_flashcardTableEntry}})) { + next if ($oid !~ /^$mapping->{flashObject}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_flashcardTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'flashcard', instance => $instance)); + + $self->{components}->{flashcard}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Flashcard '%s' [instance = %s, overall health = %s%%, temp gateway = %sC, temp FPGA0 = %sC, temp FPGA1 = %sC, temp FPGA2 = %sC, temp FPGA3 = %sC, power = %sW]", + $result->{flashObject}, $instance, $result->{flashOverallHealth}, $result->{flashTempGW} / 10, $result->{flashTempFPGA0} / 10, + $result->{flashTempFPGA1} / 10, $result->{flashTempFPGA2} / 10, $result->{flashTempFPGA3} / 10, $result->{flashPower})); + + foreach my $temp ('flashTempGW', 'flashTempFPGA0', 'flashTempFPGA1', 'flashTempFPGA2', 'flashTempFPGA3') { + if (defined($result->{$temp}) && $result->{$temp} =~ /[0-9]/) { + my $pretty_temp = $temp; + $pretty_temp =~ s/flashTemp//; + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'flashcard.temperature', instance => $instance, value => $result->{$temp} / 10); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Flashcard '%s' temperature '%s' is %sC", $instance, uc($pretty_temp), $result->{$temp} / 10)); + } + $self->{output}->perfdata_add(label => 'flashcard_temperature_' . $instance . '_' . lc($pretty_temp), unit => 'C', + value => $result->{$temp} / 10, + warning => $warn, + critical => $crit, + unit => 'C', + min => 0, + ); + } + } + + if (defined($result->{flashPower}) && $result->{flashPower} =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'flashcard.power', instance => $instance, value => $result->{flashPower}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Flashcard '%s' power is %sW", $instance, $result->{flashPower})); + } + $self->{output}->perfdata_add(label => 'flashcard_power_' . $instance, + unit => 'W', + value => $result->{flashPower}, + warning => $warn, + critical => $crit, + min => 0, + ); + } + + if (defined($result->{flashOverallHealth}) && $result->{flashOverallHealth} =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'flashcard.overallhealth', instance => $instance, value => $result->{flashOverallHealth}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Flashcard '%s' overall health is %s%%", $instance, $result->{flashOverallHealth})); + } + $self->{output}->perfdata_add(label => 'flashcard_overallhealth_' . $instance, + unit => '%', + value => $result->{flashOverallHealth}, + warning => $warn, + critical => $crit, + min => 0, + max => 100, + ); + } + } +} + +1; \ No newline at end of file diff --git a/storage/ibm/fs900/snmp/mode/components/psu.pm b/storage/ibm/fs900/snmp/mode/components/psu.pm new file mode 100644 index 000000000..a5f975a85 --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/components/psu.pm @@ -0,0 +1,103 @@ +# +# 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 storage::ibm::fs900::snmp::mode::components::psu; + +use strict; +use warnings; + +my %map_psu_state = ( + 0 => 'success', + 1 => 'error', +); + +# In MIB 'IBM-FLASHSYSTEM.MIB' +my $mapping = { + psuObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.2' }, + psuCommErr => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.3', map => \%map_psu_state }, + psuACGood => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.4', map => \%map_psu_state }, + psuDCGood => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.5', map => \%map_psu_state }, + psuFan => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.6' }, +}; +my $oid_powerTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.5.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_powerTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking psu"); + $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_powerTableEntry}})) { + next if ($oid !~ /^$mapping->{psuObject}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + + $self->{components}->{psu}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Psu '%s' [instance = %s, communications = %s, AC = %s, DC = %s, fan = %s rpm]", + $result->{psuObject}, $instance, $result->{psuCommErr}, $result->{psuACGood}, $result->{psuDCGood}, $result->{psuFan})); + + my $exit = $self->get_severity(section => 'psu', value => $result->{psuCommErr}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Psu '%s' communications state is %s", + $instance, $result->{psuCommErr})); + } + + $exit = $self->get_severity(section => 'psu', value => $result->{psuACGood}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Psu '%s' AC state is %s", + $instance, $result->{psuACGood})); + } + + $exit = $self->get_severity(section => 'psu', value => $result->{psuDCGood}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Psu '%s' DC state is %s", + $instance, $result->{psuDCGood})); + } + + if (defined($result->{psuFan}) && $result->{psuFan} =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'psu.fan', instance => $instance, value => $result->{psuFan}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Psu '%s' fan speed is %s rpm", $instance, $result->{psuFan})); + } + $self->{output}->perfdata_add(label => 'psu_fan_' . $instance, + unit => 'rpm', + value => $result->{psuFan}, + warning => $warn, + critical => $crit, + min => 0, + ); + } + } +} + +1; \ No newline at end of file diff --git a/storage/ibm/fs900/snmp/mode/fcusage.pm b/storage/ibm/fs900/snmp/mode/fcusage.pm new file mode 100644 index 000000000..e4033c27e --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/fcusage.pm @@ -0,0 +1,205 @@ +# +# 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 storage::ibm::fs900::snmp::mode::fcusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_bandwidth_perfdata { + my ($self, %options) = @_; + + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + + $self->{output}->perfdata_add(label => lc($self->{result_values}->{type}) . "_bandwidth" . $extra_label, + unit => 'B/s', + value => $self->{result_values}->{bandwidth}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{type}) . '-bandwidth'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{type}) . '-bandwidth'), + ); +} + +sub custom_bandwidth_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{bandwidth}, + threshold => [ { label => 'critical-' . lc($self->{result_values}->{type}) . '-bandwidth', exit_litteral => 'critical' }, + { label => 'warning-' . lc($self->{result_values}->{type}) . '-bandwidth', exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_bandwidth_output { + my ($self, %options) = @_; + + my ($bandwidth, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{bandwidth}); + + my $msg = sprintf("%s bandwidth: %s %s/s", $self->{result_values}->{type}, $bandwidth, $unit); + return $msg; +} + +sub custom_bandwidth_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_fcObject'}; + $self->{result_values}->{type} = $options{extra_options}->{type}; + $self->{result_values}->{bandwidth} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{bandwidth}} *1024 * 1024; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 1, cb_prefix_output => 'prefix_output', message_multiple => "All fibre channels read/write metrics are ok", skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'read-bandwidth', set => { + key_values => [ { name => 'fcReadBW' }, { name => 'fcObject' } ], + closure_custom_calc => $self->can('custom_bandwidth_calc'), + closure_custom_calc_extra_options => { type => 'Read', bandwidth => 'fcReadBW' }, + closure_custom_output => $self->can('custom_bandwidth_output'), + closure_custom_perfdata => $self->can('custom_bandwidth_perfdata'), + closure_custom_threshold_check => $self->can('custom_bandwidth_threshold'), + } + }, + { label => 'write-bandwidth', set => { + key_values => [ { name => 'fcWriteBW' }, { name => 'fcObject' } ], + closure_custom_calc => $self->can('custom_bandwidth_calc'), + closure_custom_calc_extra_options => { type => 'Write', bandwidth => 'fcWriteBW' }, + closure_custom_output => $self->can('custom_bandwidth_output'), + closure_custom_perfdata => $self->can('custom_bandwidth_perfdata'), + closure_custom_threshold_check => $self->can('custom_bandwidth_threshold'), + } + }, + { label => 'read-iops', set => { + key_values => [ { name => 'fcReadIOPS' }, { name => 'fcObject' } ], + output_template => 'Read IOPS: %s iops', + perfdatas => [ + { label => 'read_iops', value => 'fcReadIOPS_absolute', template => '%s', label_extra_instance => 1, + instance_use => 'fcObject_absolute', min => 0, unit => 'iops' }, + ], + } + }, + { label => 'write-iops', set => { + key_values => [ { name => 'fcWriteIOPS' }, { name => 'fcObject' } ], + output_template => 'Write IOPS: %s iops', + perfdatas => [ + { label => 'write_iops', value => 'fcWriteIOPS_absolute', template => '%s', label_extra_instance => 1, + instance_use => 'fcObject_absolute', min => 0, unit => 'iops' }, + ], + } + }, + { label => 'read-queue-depth', set => { + key_values => [ { name => 'fcReadQueueDepth' }, { name => 'fcObject' } ], + output_template => 'Read queue depth: %s', + perfdatas => [ + { label => 'read_queue_depth', value => 'fcReadQueueDepth_absolute', template => '%s', label_extra_instance => 1, + instance_use => 'fcObject_absolute', min => 0, unit => 'iops' }, + ], + } + }, + { label => 'write-queue-depth', set => { + key_values => [ { name => 'fcWriteQueueDepth' }, { name => 'fcObject' } ], + output_template => 'Write queue depth: %s', + perfdatas => [ + { label => 'write_queue_depth', value => 'fcWriteQueueDepth_absolute', template => '%s', label_extra_instance => 1, + instance_use => 'fcObject_absolute', min => 0, unit => 'iops' }, + ], + } + }, + ]; +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Fibre channel '" . $options{instance_value}->{fcObject} . "' "; +} + +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; +} + +my $mapping = { + fcObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.2' }, + fcReadBW => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.13' }, #MB/s + fcWriteBW => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.14' }, #MB/s + fcReadIOPS => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.16' }, + fcWriteIOPS => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.17' }, + fcReadQueueDepth => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.19' }, + fcWriteQueueDepth => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.20' }, +}; + +my $oid_fcTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.2.1.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table(oid => $oid_fcTableEntry, + nothing_quit => 1); + + $self->{global} = {}; + + foreach my $oid (keys %{$snmp_result}) { + next if ($oid !~ /^$mapping->{fcObject}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + $self->{global}->{$result->{fcObject}} = $result; + } +} + +1; + +__END__ + +=head1 MODE + +Check fibre channels usage. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'read-bandwidth', 'write-bandwidth', 'read-iops', 'write-iops', 'read-queue-depth', 'write-queue-depth'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'read-bandwidth', 'write-bandwidth', 'read-iops', 'write-iops', 'read-queue-depth', 'write-queue-depth'. + +=back + +=cut diff --git a/storage/ibm/fs900/snmp/mode/hardware.pm b/storage/ibm/fs900/snmp/mode/hardware.pm new file mode 100644 index 000000000..c6e37eb20 --- /dev/null +++ b/storage/ibm/fs900/snmp/mode/hardware.pm @@ -0,0 +1,122 @@ +# +# 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 storage::ibm::fs900::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} = '^(psu|fibrechannel)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(battery.capacity|battery.current|battery.voltage|fan.pwm|fan.temperature|fan.speed|flashcard.health|flashcard.power|flashcard.temperature|psu.fan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + psu => [ + ['success', 'OK'], + ['error', 'CRITICAL'], + ], + fibrechannel => [ + ['None', 'UNKNOWN'], + ['No Light', 'OK'], + ['Offline', 'CRITICAL'], + ['Online', 'OK'], + ['Disabled', 'OK'], + ], + }; + + $self->{components_path} = 'storage::ibm::fs900::snmp::mode::components'; + $self->{components_module} = ['battery', 'fan', 'fibrechannel', 'flashcard', 'psu']; +} + +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 (batteries, fan modules, fibre channels, flashcards, power supplies). + +=over 8 + +=item B<--component> + +Which component to check (Default: 'all'). +Can be: 'battery', 'fan', 'fibrechannel', 'flashcard', 'psu'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,1 + +=item B<--absent-problem> + +Return an error if an entity is not 'notAvailable' (default is skipping) (comma seperated list) +Can be specific or global: --absent-problem=fan,2 + +=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,OK,error' + +=item B<--warning> + +Set warning threshold (syntax: type,instance,threshold) +Example: --warning='battery.capacity,0,10' + +=item B<--critical> + +Set critical threshold (syntax: type,instance,threshold) +Example: --critical='battery.voltage,1,1000' + +=back + +=cut \ No newline at end of file diff --git a/storage/ibm/fs900/snmp/plugin.pm b/storage/ibm/fs900/snmp/plugin.pm new file mode 100644 index 000000000..b47a1bd51 --- /dev/null +++ b/storage/ibm/fs900/snmp/plugin.pm @@ -0,0 +1,51 @@ +# +# 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 storage::ibm::fs900::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}} = ( + 'fc-usage' => 'storage::ibm::fs900::snmp::mode::fcusage', + 'arrays-status' => 'storage::ibm::fs900::snmp::mode::arraysstatus', + 'arrays-usage' => 'storage::ibm::fs900::snmp::mode::arraysusage', + 'hardware' => 'storage::ibm::fs900::snmp::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check IBM FlashSystem 900 in SNMP. + +=cut