From f3d51ccf7239d15b1d85809e094b97bc2b92c8ef Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 16 May 2017 16:43:07 +0200 Subject: [PATCH] + Fix #336 --- .../snmp/mode/components/raiddisk.pm | 77 +++++++++++++++++++ network/checkpoint/snmp/mode/hardware.pm | 17 +++- 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 network/checkpoint/snmp/mode/components/raiddisk.pm diff --git a/network/checkpoint/snmp/mode/components/raiddisk.pm b/network/checkpoint/snmp/mode/components/raiddisk.pm new file mode 100644 index 000000000..5762c7b74 --- /dev/null +++ b/network/checkpoint/snmp/mode/components/raiddisk.pm @@ -0,0 +1,77 @@ +# +# Copyright 2017 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 network::checkpoint::snmp::mode::components::raiddisk; + +use strict; +use warnings; +use centreon::plugins::misc; + +my %map_states_disk = ( + 0 => 'online', + 1 => 'missing', + 2 => 'not_compatible', + 3 => 'failed', + 4 => 'initializing', + 5 => 'offline_requested', + 6 => 'failed_requested', + 255 => 'other_offline', +); + +my $mapping = { + raidDiskProductID => { oid => '.1.3.6.1.4.1.2620.1.6.7.7.2.1.6' }, + raidDiskSyncState => { oid => '.1.3.6.1.4.1.2620.1.6.7.7.2.1.11', map => \%map_states_disk }, +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{raidDiskProductID}->{oid} }, + { oid => $mapping->{raidDiskSyncState}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking raid disks"); + $self->{components}->{raiddisk} = {name => 'raiddisk', total => 0, skip => 0}; + return if ($self->check_filter(section => 'raiddisk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{raidDiskProductID}->{oid}}})) { + $oid =~ /^$mapping->{raidDiskProductID}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{raidDiskSyncState}->{oid}}, instance => $instance); + + next if ($self->check_filter(section => 'raiddisk', instance => $instance)); + + my $name = centreon::plugins::misc::trim($self->{results}->{$mapping->{raidDiskProductID}->{oid}}->{$oid}); + $self->{components}->{raiddisk}->{total}++; + $self->{output}->output_add(long_msg => sprintf("raid disk '%s' status is '%s'", + $name, $result->{raidDiskSyncState})); + my $exit = $self->get_severity(section => 'raiddisk', value => $result->{raidDiskSyncState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Raid disk '%s' status is '%s'", + $name, $result->{raidDiskSyncState})); + } + } +} + +1; diff --git a/network/checkpoint/snmp/mode/hardware.pm b/network/checkpoint/snmp/mode/hardware.pm index ee7efa1c5..575a49779 100644 --- a/network/checkpoint/snmp/mode/hardware.pm +++ b/network/checkpoint/snmp/mode/hardware.pm @@ -28,7 +28,7 @@ use warnings; sub set_system { my ($self, %options) = @_; - $self->{regexp_threshold_overload_check_section_option} = '^(temperature|voltage|fan|psu)$'; + $self->{regexp_threshold_overload_check_section_option} = '^(temperature|voltage|fan|psu|raiddisk)$'; $self->{cb_hook2} = 'snmp_execute'; @@ -52,11 +52,22 @@ sub set_system { ['up', 'OK'], ['down', 'CRITICAL'], ['.*', 'UNKNOWN'], + ], + raiddisk => [ + ['online', 'OK'], + ['missing', 'OK'], + ['not_compatible', 'CRITICAL'], + ['failed', 'CRITICAL'], + ['initializing', 'OK'], + ['offline_requested', 'OK'], + ['failed_requested', 'OK'], + ['other_offline', 'WARNING'], + ['.*', 'UNKNOWN'], ], }; $self->{components_path} = 'network::checkpoint::snmp::mode::components'; - $self->{components_module} = ['voltage', 'fan', 'temperature', 'psu']; + $self->{components_module} = ['voltage', 'fan', 'temperature', 'psu', 'raiddisk']; } sub snmp_execute { @@ -92,7 +103,7 @@ Check hardware (fans, power supplies, temperatures, voltages). =item B<--component> Which component to check (Default: '.*'). -Can be: 'psu', 'fan', 'temperature', 'voltage'. +Can be: 'psu', 'fan', 'temperature', 'voltage', 'raiddisk'. =item B<--filter>