+ work on alcatel isam plugin

This commit is contained in:
garnier-quentin 2017-05-17 10:25:14 +02:00
parent 546c713820
commit dc2d950b29
2 changed files with 158 additions and 9 deletions

View File

@ -0,0 +1,150 @@
#
# Copyright 2017 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::alcatel::isam::snmp::mode::components::sfp;
use strict;
use warnings;
use network::alcatel::isam::snmp::mode::components::resources qw($mapping_slot);
my %map_los = (1 => 'los', 2 => 'noLos', 3 => 'notAvailable');
my $mapping = {
sfpDiagLOS => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.4', map => \%map_los },
sfpDiagTxPower => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.6' },
sfpDiagRxPower => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.7' },
sfpDiagTxBiasCurrent => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.8' },
sfpDiagSupplyVoltage => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.9' },
sfpDiagTemperature => { oid => '.1.3.6.1.4.1.637.61.1.56.5.1.10' },
};
my $oid_sfpDiagEntry = '.1.3.6.1.4.1.637.61.1.56.5.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sfpDiagEntry, start => $mapping->{sfpDiagLOS}->{oid}, end => $mapping->{sfpDiagTemperature}->{oid}, };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking sfp");
$self->{components}->{sfp} = {name => 'sfp', total => 0, skip => 0};
return if ($self->check_filter(section => 'sfp'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_sfpDiagEntry}})) {
next if ($oid !~ /^$mapping->{sfpDiagLOS}->{oid}\.(.*?)\.(.*?)$/);
my ($slot_id, $sfp_faceplate_num) = ($1, $2);
my $result = $self->{snmp}->map_instance(mapping => $mapping_slot, results =>
{ %{$self->{results}->{$mapping_slot->{eqptSlotActualType}->{oid}}}, %{$self->{results}->{$mapping_slot->{eqptBoardInventorySerialNumber}->{oid}}} }, instance => $slot_id);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sfpDiagEntry}, instance => $slot_id . '.' . $sfp_faceplate_num);
next if ($self->check_filter(section => 'sfp', instance => $slot_id . '.' . $sfp_faceplate_num));
my $name = $result->{eqptSlotActualType} . '/' . $result->{eqptBoardInventorySerialNumber} . '/' . $sfp_faceplate_num;
$self->{components}->{sfp}->{total}++;
$self->{output}->output_add(long_msg => sprintf("sfp '%s' signal status is '%s' [instance = %s]",
$name, $result2->{sfpDiagLOS}, $slot_id . '.' . $sfp_faceplate_num));
$exit = $self->get_severity(section => 'sfp', value => $result2->{sfpDiagLOS});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("sfp '%s' signal status is '%s'", $name, $result2->{sfpDiagLOS}));
}
if ($result2->{sfpDiagSupplyVoltage} !~ /(\S+)\s+VDC/i) {
my $value = $1;
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.voltage', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sfp '%s' voltage is %s VDC", $name, $value));
}
$self->{output}->perfdata_add(label => 'sfp_voltage_' . $name,
unit => 'VDC',
value => $value,
warning => $warn,
critical => $crit
);
}
if ($result2->{sfpDiagTemperature} !~ /(\S+)\s+degrees Celsius/i) {
my $value = $1;
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.temperature', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sfp '%s' temperature is %s C", $name, $value));
}
$self->{output}->perfdata_add(label => 'sfp_temperature_' . $name,
unit => 'C',
value => $value,
warning => $warn,
critical => $crit
);
}
if ($result2->{sfpDiagTxPower} !~ /(\S+)\s+dBm/i) {
my $value = $1;
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.txpower', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sfp '%s' tx power is %s dBm", $name, $value));
}
$self->{output}->perfdata_add(label => 'sfp_txpower_' . $name,
unit => 'dBm',
value => $value,
warning => $warn,
critical => $crit
);
}
if ($result2->{sfpDiagRxPower} !~ /(\S+)\s+dBm/i) {
my $value = $1;
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.rxpower', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sfp '%s' rx power is %s dBm", $name, $value));
}
$self->{output}->perfdata_add(label => 'sfp_rxpower_' . $name,
unit => 'dBm',
value => $value,
warning => $warn,
critical => $crit
);
}
if ($result2->{sfpDiagTxBiasCurrent} !~ /(\S+)\s+mA/i) {
my $value = $1;
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sfp.current', instance => $slot_id . '.' . $sfp_faceplate_num, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sfp '%s' current is %s mA", $name, $value));
}
$self->{output}->perfdata_add(label => 'sfp_current_' . $name,
unit => 'mA',
value => $value,
warning => $warn,
critical => $crit
);
}
}
}
1;

View File

@ -28,22 +28,21 @@ use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(cardtemperature)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(cardtemperature)$';
$self->{regexp_threshold_overload_check_section_option} = '^(cardtemperature|sfp)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(cardtemperature|sfp\.(temperature|voltage|current|txpower|rxpower))$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
psu => [
['notPresent', 'OK'],
['presentOK', 'OK'],
['presentPowerOff', 'WARNING'],
['presentNotOK', 'CRITICAL'],
sfp => [
['noLos', 'OK'],
['notAvailable', 'OK'],
['los', 'WARNING'],
],
};
$self->{components_path} = 'network::alcatel::isam::snmp::mode::components';
$self->{components_module} = ['cardtemperature'];
$self->{components_module} = ['cardtemperature', 'sfp'];
}
sub snmp_execute {
@ -82,7 +81,7 @@ Check Hardware.
=item B<--component>
Which component to check (Default: '.*').
Can be: 'cardtemperature'.
Can be: 'cardtemperature', 'sfp'.
=item B<--filter>