| 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 hardware::server::hp::proliant::snmp::mode::components::memory; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_memory_status = ( |
| 27 |
1 => 'other', |
| 28 |
2 => 'notPresent', |
| 29 |
3 => 'present', |
| 30 |
4 => 'good', |
| 31 |
5 => 'add', |
| 32 |
6 => 'upgrade', |
| 33 |
7 => 'missing', |
| 34 |
8 => 'doesNotMatch', |
| 35 |
9 => 'notSupported', |
| 36 |
10 => 'badConfig', |
| 37 |
11 => 'degraded', |
| 38 |
12 => 'spare', |
| 39 |
13 => 'partial', |
| 40 |
14 => 'configError', |
| 41 |
15 => 'trainingFailure' |
| 42 |
); |
| 43 |
|
| 44 |
my $mapping = { |
| 45 |
size => { oid => '.1.3.6.1.4.1.232.6.2.14.13.1.6' }, # cpqHeResMem2ModuleSize |
| 46 |
location => { oid => '.1.3.6.1.4.1.232.6.2.14.13.1.13' }, # cpqHeResMem2ModuleHwLocation |
| 47 |
status => { oid => '.1.3.6.1.4.1.232.6.2.14.13.1.19', map => \%map_memory_status } # cpqHeResMem2ModuleStatus |
| 48 |
}; |
| 49 |
my $oid_cpqHeResMem2Module = '.1.3.6.1.4.1.232.6.2.14.13.1.1'; |
| 50 |
|
| 51 |
sub load { |
| 52 |
my ($self) = @_; |
| 53 |
|
| 54 |
push @{$self->{request}}, { oid => $oid_cpqHeResMem2Module }; |
| 55 |
} |
| 56 |
|
| 57 |
sub check { |
| 58 |
my ($self) = @_; |
| 59 |
|
| 60 |
$self->{output}->output_add(long_msg => "Checking memory"); |
| 61 |
$self->{components}->{memory} = { name => 'memory', total => 0, skip => 0 }; |
| 62 |
return if ($self->check_filter(section => 'memory')); |
| 63 |
|
| 64 |
return if (scalar(keys %{$self->{results}->{$oid_cpqHeResMem2Module}}) <= 0); |
| 65 |
|
| 66 |
$self->{snmp}->load( |
| 67 |
oids => [map($_->{oid}, values(%$mapping))], |
| 68 |
instances => [values(%{$self->{results}->{$oid_cpqHeResMem2Module}})] |
| 69 |
); |
| 70 |
my $results = $self->{snmp}->get_leef(); |
| 71 |
|
| 72 |
foreach my $instance (sort values(%{$self->{results}->{$oid_cpqHeResMem2Module}})) { |
| 73 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); |
| 74 |
|
| 75 |
next if ($self->check_filter(section => 'memory', instance => $instance)); |
| 76 |
$self->{components}->{memory}->{total}++; |
| 77 |
|
| 78 |
$self->{output}->output_add( |
| 79 |
long_msg => sprintf( |
| 80 |
"memory slot '%s' [location: %s, size: %skB] status is %s", |
| 81 |
$instance, |
| 82 |
defined($result->{location}) ? $result->{location} : '-', |
| 83 |
$result->{size}, |
| 84 |
$result->{status} |
| 85 |
) |
| 86 |
); |
| 87 |
my $exit = $self->get_severity(section => 'memory', value => $result->{status}); |
| 88 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 89 |
$self->{output}->output_add( |
| 90 |
severity => $exit, |
| 91 |
short_msg => sprintf( |
| 92 |
"memory slot '%s' is %s", |
| 93 |
$instance, $result->{status} |
| 94 |
) |
| 95 |
); |
| 96 |
} |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
1; |