| 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::ibm::bladecenter::snmp::mode::components::blade; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_blade_health_state = ( |
| 27 |
0 => 'unknown', |
| 28 |
1 => 'good', |
| 29 |
2 => 'warning', |
| 30 |
3 => 'critical', |
| 31 |
4 => 'kernelMode', |
| 32 |
5 => 'discovering', |
| 33 |
6 => 'commError', |
| 34 |
7 => 'noPower', |
| 35 |
8 => 'flashing', |
| 36 |
9 => 'initFailure', |
| 37 |
10 => 'insufficientPower', |
| 38 |
11 => 'powerDenied', |
| 39 |
); |
| 40 |
my %map_blade_exists = ( |
| 41 |
0 => 'false', |
| 42 |
1 => 'true', |
| 43 |
); |
| 44 |
my %map_blade_power_state = ( |
| 45 |
0 => 'off', |
| 46 |
1 => 'on', |
| 47 |
3 => 'standby', |
| 48 |
4 => 'hibernate', |
| 49 |
); |
| 50 |
|
| 51 |
# In MIB 'mmblade.mib' and 'cme.mib' |
| 52 |
my $mapping = { |
| 53 |
bladeId => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2' }, |
| 54 |
bladeExists => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3', map => \%map_blade_exists }, |
| 55 |
bladePowerState => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.4', map => \%map_blade_power_state }, |
| 56 |
bladeHealthState => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.5', map => \%map_blade_health_state }, |
| 57 |
bladeName => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.6' }, |
| 58 |
}; |
| 59 |
my $oid_bladeSystemStatusEntry = '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1'; |
| 60 |
|
| 61 |
sub load { |
| 62 |
my ($self) = @_; |
| 63 |
|
| 64 |
push @{$self->{request}}, { oid => $oid_bladeSystemStatusEntry, start => $mapping->{bladeId}->{oid}, end => $mapping->{bladeName}->{oid} }; |
| 65 |
} |
| 66 |
|
| 67 |
sub check { |
| 68 |
my ($self) = @_; |
| 69 |
|
| 70 |
$self->{output}->output_add(long_msg => "Checking blades"); |
| 71 |
$self->{components}->{blade} = {name => 'blades', total => 0, skip => 0}; |
| 72 |
return if ($self->check_filter(section => 'blade')); |
| 73 |
|
| 74 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeSystemStatusEntry}})) { |
| 75 |
next if ($oid !~ /^$mapping->{bladeExists}->{oid}\.(.*)$/); |
| 76 |
my $instance = $1; |
| 77 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeSystemStatusEntry}, instance => $instance); |
| 78 |
|
| 79 |
next if ($self->check_filter(section => 'blade', instance => $result->{bladeId})); |
| 80 |
if ($result->{bladeExists} =~ /false/i) { |
| 81 |
$self->{output}->output_add(long_msg => "skipping blade '" . $instance . "' : not exits"); |
| 82 |
next; |
| 83 |
} |
| 84 |
$self->{components}->{blade}->{total}++; |
| 85 |
$result->{bladeName} = defined($result->{bladeName}) ? $result->{bladeName} : '-'; |
| 86 |
|
| 87 |
if ($result->{bladePowerState} =~ /off/) { |
| 88 |
$self->{output}->output_add(long_msg => sprintf("Blade '%s/%s' power state is %s", |
| 89 |
$result->{bladeName}, $result->{bladeId}, $result->{bladePowerState}, |
| 90 |
)); |
| 91 |
next; |
| 92 |
} |
| 93 |
|
| 94 |
$self->{output}->output_add(long_msg => sprintf("Blade '%s/%s' state is %s [power state: %s]", |
| 95 |
$result->{bladeName}, $result->{bladeId}, $result->{bladeHealthState}, $result->{bladePowerState}, |
| 96 |
)); |
| 97 |
my $exit = $self->get_severity(section => 'blade', value => $result->{bladeHealthState}); |
| 98 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 99 |
$self->{output}->output_add(severity => $exit, |
| 100 |
short_msg => sprintf("Blade '%s/%s' state is %s", |
| 101 |
$result->{bladeName}, $result->{bladeId}, $result->{bladeHealthState})); |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
1; |