| 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::ibm::fs900::snmp::mode::components::flashcard; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
# In MIB 'IBM-FLASHSYSTEM.MIB' |
| 27 |
my $mapping = { |
| 28 |
flashObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.2' }, |
| 29 |
flashTempGW => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.7' }, |
| 30 |
flashTempFPGA0 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.8' }, |
| 31 |
flashTempFPGA1 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.9' }, |
| 32 |
flashTempFPGA2 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.10' }, |
| 33 |
flashTempFPGA3 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.11' }, |
| 34 |
flashPower => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.12' }, |
| 35 |
flashOverallHealth => { oid => '.1.3.6.1.4.1.2.6.255.1.1.3.1.1.14' }, |
| 36 |
}; |
| 37 |
my $oid_flashcardTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.3.1.1'; |
| 38 |
|
| 39 |
sub load { |
| 40 |
my ($self) = @_; |
| 41 |
|
| 42 |
push @{$self->{request}}, { oid => $oid_flashcardTableEntry }; |
| 43 |
} |
| 44 |
|
| 45 |
sub check { |
| 46 |
my ($self) = @_; |
| 47 |
|
| 48 |
$self->{output}->output_add(long_msg => "Checking flashcards"); |
| 49 |
$self->{components}->{flashcard} = {name => 'flashcards', total => 0, skip => 0}; |
| 50 |
return if ($self->check_filter(section => 'flashcard')); |
| 51 |
|
| 52 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_flashcardTableEntry}})) { |
| 53 |
next if ($oid !~ /^$mapping->{flashObject}->{oid}\.(.*)$/); |
| 54 |
my $instance = $1; |
| 55 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_flashcardTableEntry}, instance => $instance); |
| 56 |
|
| 57 |
next if ($self->check_filter(section => 'flashcard', instance => $instance)); |
| 58 |
|
| 59 |
$self->{components}->{flashcard}->{total}++; |
| 60 |
$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]", |
| 61 |
$result->{flashObject}, $instance, $result->{flashOverallHealth}, $result->{flashTempGW} / 10, $result->{flashTempFPGA0} / 10, |
| 62 |
$result->{flashTempFPGA1} / 10, $result->{flashTempFPGA2} / 10, $result->{flashTempFPGA3} / 10, $result->{flashPower})); |
| 63 |
|
| 64 |
foreach my $temp ('flashTempGW', 'flashTempFPGA0', 'flashTempFPGA1', 'flashTempFPGA2', 'flashTempFPGA3') { |
| 65 |
if (defined($result->{$temp}) && $result->{$temp} =~ /[0-9]/) { |
| 66 |
my $pretty_temp = $temp; |
| 67 |
$pretty_temp =~ s/flashTemp//; |
| 68 |
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'flashcard.temperature', instance => $instance, value => $result->{$temp} / 10); |
| 69 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 70 |
$self->{output}->output_add(severity => $exit, |
| 71 |
short_msg => sprintf("Flashcard '%s' temperature '%s' is %sC", $instance, uc($pretty_temp), $result->{$temp} / 10)); |
| 72 |
} |
| 73 |
$self->{output}->perfdata_add( |
| 74 |
label => 'flashcard_temperature', unit => 'C', |
| 75 |
nlabel => 'hardware.flashcard.temperature.celsius', |
| 76 |
instances => [$instance, lc($pretty_temp)], |
| 77 |
value => $result->{$temp} / 10, |
| 78 |
warning => $warn, |
| 79 |
critical => $crit, |
| 80 |
min => 0, |
| 81 |
); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
if (defined($result->{flashPower}) && $result->{flashPower} =~ /[0-9]/) { |
| 86 |
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'flashcard.power', instance => $instance, value => $result->{flashPower}); |
| 87 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 88 |
$self->{output}->output_add(severity => $exit, |
| 89 |
short_msg => sprintf("Flashcard '%s' power is %sW", $instance, $result->{flashPower})); |
| 90 |
} |
| 91 |
$self->{output}->perfdata_add( |
| 92 |
label => 'flashcard_power', unit => 'W', |
| 93 |
nlabel => 'hardware.flashcard.power.watt', |
| 94 |
instances => $instance, |
| 95 |
value => $result->{flashPower}, |
| 96 |
warning => $warn, |
| 97 |
critical => $crit, |
| 98 |
min => 0, |
| 99 |
); |
| 100 |
} |
| 101 |
|
| 102 |
if (defined($result->{flashOverallHealth}) && $result->{flashOverallHealth} =~ /[0-9]/) { |
| 103 |
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'flashcard.overallhealth', instance => $instance, value => $result->{flashOverallHealth}); |
| 104 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 105 |
$self->{output}->output_add(severity => $exit, |
| 106 |
short_msg => sprintf("Flashcard '%s' overall health is %s%%", $instance, $result->{flashOverallHealth})); |
| 107 |
} |
| 108 |
$self->{output}->perfdata_add( |
| 109 |
label => 'flashcard_overallhealth', unit => '%', |
| 110 |
nlabel => 'hardware.flashcard.overallhealth.percentage', |
| 111 |
instances => $instance, |
| 112 |
value => $result->{flashOverallHealth}, |
| 113 |
warning => $warn, |
| 114 |
critical => $crit, |
| 115 |
min => 0, max => 100, |
| 116 |
); |
| 117 |
} |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
1; |