| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package storage::dell::equallogic::snmp::mode::components::health; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_health_status = ( |
| 27 |
0 => 'unknown', |
| 28 |
1 => 'normal', |
| 29 |
2 => 'warning', |
| 30 |
3 => 'critical' |
| 31 |
); |
| 32 |
|
| 33 |
my $mapping = { |
| 34 |
health_status => { oid => '.1.3.6.1.4.1.12740.2.1.5.1.1', map => \%map_health_status } # eqlMemberHealthStatus |
| 35 |
}; |
| 36 |
my $mapping_extra_info = { |
| 37 |
major_version => { oid => '.1.3.6.1.4.1.12740.2.1.1.1.21' }, # eqlMemberControllerMajorVersion |
| 38 |
minor_version => { oid => '.1.3.6.1.4.1.12740.2.1.1.1.22' }, # eqlMemberControllerMinorVersion |
| 39 |
maintenance_version => { oid => '.1.3.6.1.4.1.12740.2.1.1.1.23' }, # eqlMemberControllerMaintenanceVersion |
| 40 |
product_family => { oid => '.1.3.6.1.4.1.12740.2.1.11.1.9' } # eqlMemberProductFamily |
| 41 |
}; |
| 42 |
|
| 43 |
sub load { |
| 44 |
my ($self) = @_; |
| 45 |
|
| 46 |
push @{$self->{request}}, { oid => $mapping->{health_status}->{oid} }; |
| 47 |
} |
| 48 |
|
| 49 |
sub get_extra_informations { |
| 50 |
my ($self, %options) = @_; |
| 51 |
|
| 52 |
my $snmp_result = $self->{snmp}->get_leef( |
| 53 |
oids => [ map($_->{oid} . '.' . $options{instance}, values(%$mapping_extra_info)) ], |
| 54 |
); |
| 55 |
return $self->{snmp}->map_instance(mapping => $mapping_extra_info, results => $snmp_result, instance => $options{instance}); |
| 56 |
} |
| 57 |
|
| 58 |
sub check { |
| 59 |
my ($self) = @_; |
| 60 |
|
| 61 |
$self->{output}->output_add(long_msg => "Checking health"); |
| 62 |
$self->{components}->{health} = {name => 'health', total => 0, skip => 0}; |
| 63 |
return if ($self->check_filter(section => 'health')); |
| 64 |
|
| 65 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping->{health_status}->{oid} }})) { |
| 66 |
next if ($oid !~ /^$mapping->{health_status}->{oid}\.(\d+\.\d+)$/); |
| 67 |
my ($member_instance) = ($1); |
| 68 |
my $member_name = $self->get_member_name(instance => $member_instance); |
| 69 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{health_status}->{oid} }, instance => $member_instance); |
| 70 |
|
| 71 |
next if ($self->check_filter(section => 'health', instance => $member_instance)); |
| 72 |
$self->{components}->{health}->{total}++; |
| 73 |
|
| 74 |
my $extra_infos = get_extra_informations($self, instance => $member_instance); |
| 75 |
|
| 76 |
$self->{output}->output_add( |
| 77 |
long_msg => sprintf( |
| 78 |
"health '%s' status is %s [instance: %s, product: %s, version: %s].", |
| 79 |
$member_name, |
| 80 |
$result->{health_status}, |
| 81 |
$member_instance, |
| 82 |
$extra_infos->{product_family}, |
| 83 |
$extra_infos->{major_version} . '.' . $extra_infos->{minor_version} . '.' . $extra_infos->{maintenance_version} |
| 84 |
) |
| 85 |
); |
| 86 |
my $exit = $self->get_severity(section => 'health', value => $result->{health_status}); |
| 87 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 88 |
$self->{output}->output_add( |
| 89 |
severity => $exit, |
| 90 |
short_msg => sprintf( |
| 91 |
"Health '%s' status is %s", |
| 92 |
$member_name, $result->{health_status} |
| 93 |
) |
| 94 |
); |
| 95 |
} |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
1; |