| 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 network::nokia::isam::snmp::mode::components::sfp; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use network::nokia::isam::snmp::mode::components::resources qw($mapping_slot); |
| 26 |
|
| 27 |
my %map_los = (1 => 'los', 2 => 'noLos', 3 => 'notAvailable'); |
| 28 |
|
| 29 |
my $mapping = { |
| 30 |
sfpDiagLOS => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.4', map => \%map_los }, |
| 31 |
sfpDiagTxPower => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.6' }, |
| 32 |
sfpDiagRxPower => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.7' }, |
| 33 |
sfpDiagTxBiasCurrent => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.8' }, |
| 34 |
sfpDiagSupplyVoltage => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.9' }, |
| 35 |
sfpDiagTemperature => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.10' }, |
| 36 |
}; |
| 37 |
my $oid_sfpDiagEntry = '.1.3.6.1.4.1.637.61.1.56.5.1'; |
| 38 |
|
| 39 |
sub load { |
| 40 |
my ($self) = @_; |
| 41 |
|
| 42 |
foreach (keys %$mapping) { |
| 43 |
push @{$self->{request}}, { oid => $mapping->{$_}->{oid} }; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
sub check { |
| 48 |
my ($self) = @_; |
| 49 |
|
| 50 |
$self->{output}->output_add(long_msg => "Checking sfp"); |
| 51 |
$self->{components}->{sfp} = {name => 'sfp', total => 0, skip => 0}; |
| 52 |
return if ($self->check_filter(section => 'sfp')); |
| 53 |
|
| 54 |
my $results = {}; |
| 55 |
foreach (keys %$mapping) { |
| 56 |
$results = { %$results, %{$self->{results}->{$mapping->{$_}->{oid}}} }; |
| 57 |
} |
| 58 |
|
| 59 |
my ($exit, $warn, $crit, $checked); |
| 60 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{sfpDiagLOS}->{oid}}})) { |
| 61 |
$oid =~ /^$mapping->{sfpDiagLOS}->{oid}\.(.*?)\.(.*?)$/; |
| 62 |
my ($slot_id, $sfp_faceplate_num) = ($1, $2); |
| 63 |
|
| 64 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_slot, results => |
| 65 |
{ %{$self->{results}->{$mapping_slot->{eqptSlotActualType}->{oid}}}, %{$self->{results}->{$mapping_slot->{eqptBoardInventorySerialNumber}->{oid}}} }, instance => $slot_id); |
| 66 |
my $result2 = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $slot_id . '.' . $sfp_faceplate_num); |
| 67 |
|
| 68 |
next if ($self->check_filter(section => 'sfp', instance => $slot_id . '.' . $sfp_faceplate_num)); |
| 69 |
|
| 70 |
my $name = $result->{eqptSlotActualType} . '/' . $result->{eqptBoardInventorySerialNumber} . '/' . $sfp_faceplate_num; |
| 71 |
$self->{components}->{sfp}->{total}++; |
| 72 |
$self->{output}->output_add(long_msg => sprintf("sfp '%s' signal status is '%s' [instance = %s]", |
| 73 |
$name, $result2->{sfpDiagLOS}, $slot_id . '.' . $sfp_faceplate_num)); |
| 74 |
$exit = $self->get_severity(section => 'sfp', instance => $slot_id . '.' . $sfp_faceplate_num, value => $result2->{sfpDiagLOS}); |
| 75 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 76 |
$self->{output}->output_add(severity => $exit, |
| 77 |
short_msg => sprintf("sfp '%s' signal status is '%s'", $name, $result2->{sfpDiagLOS})); |
| 78 |
} |
| 79 |
|
| 80 |
if ($result2->{sfpDiagSupplyVoltage} =~ /(\S+)\s+VDC/i) { |
| 81 |
my $value = $1; |
| 82 |
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.voltage', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value); |
| 83 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 84 |
$self->{output}->output_add(severity => $exit, |
| 85 |
short_msg => sprintf("Sfp '%s' voltage is %s VDC", $name, $value)); |
| 86 |
} |
| 87 |
$self->{output}->perfdata_add( |
| 88 |
label => 'sfp_voltage', unit => 'vdc', |
| 89 |
nlabel => 'hardware.sfp.voltage.voltdc', |
| 90 |
instances => $name, |
| 91 |
value => $value, |
| 92 |
warning => $warn, |
| 93 |
critical => $crit |
| 94 |
); |
| 95 |
} |
| 96 |
|
| 97 |
if ($result2->{sfpDiagTemperature} =~ /(\S+)\s+degrees Celsius/i) { |
| 98 |
my $value = $1; |
| 99 |
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.temperature', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value); |
| 100 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 101 |
$self->{output}->output_add(severity => $exit, |
| 102 |
short_msg => sprintf("Sfp '%s' temperature is %s C", $name, $value)); |
| 103 |
} |
| 104 |
$self->{output}->perfdata_add( |
| 105 |
label => 'sfp_temperature', unit => 'C', |
| 106 |
nlabel => 'hardware.sfp.temperature.celsius', |
| 107 |
instances => $name, |
| 108 |
value => $value, |
| 109 |
warning => $warn, |
| 110 |
critical => $crit |
| 111 |
); |
| 112 |
} |
| 113 |
|
| 114 |
if ($result2->{sfpDiagTxPower} =~ /(\S+)\s+dBm/i) { |
| 115 |
my $value = $1; |
| 116 |
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.txpower', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value); |
| 117 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 118 |
$self->{output}->output_add(severity => $exit, |
| 119 |
short_msg => sprintf("Sfp '%s' tx power is %s dBm", $name, $value)); |
| 120 |
} |
| 121 |
$self->{output}->perfdata_add( |
| 122 |
label => 'sfp_txpower', unit => 'dBm', |
| 123 |
nlabel => 'hardware.sfp.txpower.dbm', |
| 124 |
instances => $name, |
| 125 |
value => $value, |
| 126 |
warning => $warn, |
| 127 |
critical => $crit |
| 128 |
); |
| 129 |
} |
| 130 |
|
| 131 |
if ($result2->{sfpDiagRxPower} =~ /(\S+)\s+dBm/i) { |
| 132 |
my $value = $1; |
| 133 |
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.rxpower', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value); |
| 134 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 135 |
$self->{output}->output_add(severity => $exit, |
| 136 |
short_msg => sprintf("Sfp '%s' rx power is %s dBm", $name, $value)); |
| 137 |
} |
| 138 |
$self->{output}->perfdata_add( |
| 139 |
label => 'sfp_rxpower', unit => 'dBm', |
| 140 |
nlabel => 'hardware.sfp.rxpower.dbm', |
| 141 |
instances => $name, |
| 142 |
value => $value, |
| 143 |
warning => $warn, |
| 144 |
critical => $crit |
| 145 |
); |
| 146 |
} |
| 147 |
|
| 148 |
if ($result2->{sfpDiagTxBiasCurrent} =~ /(\S+)\s+mA/i) { |
| 149 |
my $value = $1; |
| 150 |
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.current', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value); |
| 151 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 152 |
$self->{output}->output_add(severity => $exit, |
| 153 |
short_msg => sprintf("Sfp '%s' current is %s mA", $name, $value)); |
| 154 |
} |
| 155 |
$self->{output}->perfdata_add( |
| 156 |
label => 'sfp_current', unit => 'mA', |
| 157 |
nlabel => 'hardware.sfp.current.milliampere', |
| 158 |
instances => $name, |
| 159 |
value => $value, |
| 160 |
warning => $warn, |
| 161 |
critical => $crit |
| 162 |
); |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
1; |