mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 15:44:21 +02:00
Refs #5695
Fix spanning-tree (alcatel had some bugs on leef. So we use multiple_table) Fix in snmp
This commit is contained in:
parent
bf16f53d5d
commit
2a89d6b6cb
@ -324,10 +324,10 @@ sub get_multiple_table {
|
|||||||
# Transform asking
|
# Transform asking
|
||||||
if ($entry->{oid} !~ /(.*)\.(\d+)([\.\s]*)$/) {
|
if ($entry->{oid} !~ /(.*)\.(\d+)([\.\s]*)$/) {
|
||||||
if ($dont_quit == 1) {
|
if ($dont_quit == 1) {
|
||||||
$self->set_error(error_status => -1, error_msg => "Method 'get_table': Wrong OID '" . $entry->{oid} . "'.");
|
$self->set_error(error_status => -1, error_msg => "Method 'get_multiple_table': Wrong OID '" . $entry->{oid} . "'.");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
$self->{output}->add_option_msg(short_msg => "Method 'get_table': Wrong OID '" . $entry->{oid} . "'.");
|
$self->{output}->add_option_msg(short_msg => "Method 'get_multiple_table': Wrong OID '" . $entry->{oid} . "'.");
|
||||||
$self->{output}->option_exit(exit_litteral => $self->{snmp_errors_exit});
|
$self->{output}->option_exit(exit_litteral => $self->{snmp_errors_exit});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ sub get_multiple_table {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
foreach (keys %{$results}) {
|
foreach (keys %{$results}) {
|
||||||
$total += scalar(%{$results->{$_}});
|
$total += scalar(keys %{$results->{$_}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ my %states = (
|
|||||||
4 => ['learning', 'OK'],
|
4 => ['learning', 'OK'],
|
||||||
5 => ['forwarding', 'OK'],
|
5 => ['forwarding', 'OK'],
|
||||||
6 => ['broken', 'CRITICAL'],
|
6 => ['broken', 'CRITICAL'],
|
||||||
|
|
||||||
|
10 => ['not defined', 'UNKNOWN'], # mine status
|
||||||
);
|
);
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -76,39 +78,43 @@ sub run {
|
|||||||
my $oid_dot1dStpPortState = '.1.3.6.1.2.1.17.2.15.1.3';
|
my $oid_dot1dStpPortState = '.1.3.6.1.2.1.17.2.15.1.3';
|
||||||
my $oid_dot1dBasePortIfIndex = '.1.3.6.1.2.1.17.1.4.1.2';
|
my $oid_dot1dBasePortIfIndex = '.1.3.6.1.2.1.17.1.4.1.2';
|
||||||
my $oid_ifDesc = '.1.3.6.1.2.1.2.2.1.2';
|
my $oid_ifDesc = '.1.3.6.1.2.1.2.2.1.2';
|
||||||
my $result = $self->{snmp}->get_table(oid => $oid_dot1dStpPortEnable, nothing_quit => 1);
|
my $results = $self->{snmp}->get_multiple_table(oids => [
|
||||||
|
{ oid => $oid_dot1dStpPortEnable },
|
||||||
foreach my $oid (keys %$result) {
|
{ oid => $oid_dot1dStpPortState },
|
||||||
|
], nothing_quit => 1);
|
||||||
|
my @instances = ();
|
||||||
|
foreach my $oid (keys %{$results->{$oid_dot1dStpPortEnable}}) {
|
||||||
$oid =~ /\.([0-9]+)$/;
|
$oid =~ /\.([0-9]+)$/;
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
|
|
||||||
# '2' => disabled, we skip
|
# '2' => disabled, we skip
|
||||||
if ($result->{$oid} == 2) {
|
if ($results->{$oid_dot1dStpPortEnable}->{$oid} == 2) {
|
||||||
$self->{output}->output_add(long_msg => sprintf("Skipping interface '%d': Stp port disabled", $instance));
|
$self->{output}->output_add(long_msg => sprintf("Skipping interface '%d': Stp port disabled", $instance));
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{snmp}->load(oids => [$oid_dot1dStpPortState . "." . $instance, $oid_dot1dBasePortIfIndex . "." . $instance]);
|
push @instances, $instance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $self->{snmp}->get_leef(nothing_quit => 1);
|
$self->{snmp}->load(oids => [$oid_dot1dBasePortIfIndex],
|
||||||
|
instances => [@instances]);
|
||||||
|
my $result = $self->{snmp}->get_leef(nothing_quit => 1);
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(severity => 'OK',
|
||||||
short_msg => 'Spanning Tree is ok on all interfaces');
|
short_msg => 'Spanning Tree is ok on all interfaces');
|
||||||
# Get description
|
# Get description
|
||||||
foreach my $oid (keys %$result) {
|
foreach my $oid (keys %$result) {
|
||||||
next if ($oid !~ /^$oid_dot1dBasePortIfIndex/);
|
next if ($oid !~ /^$oid_dot1dBasePortIfIndex\./ || !defined($result->{$oid}));
|
||||||
|
|
||||||
$self->{snmp}->load(oids => [$oid_ifDesc . "." . $result->{$oid}]);
|
$self->{snmp}->load(oids => [$oid_ifDesc . "." . $result->{$oid}]);
|
||||||
}
|
}
|
||||||
my $result_desc = $self->{snmp}->get_leef();
|
my $result_desc = $self->{snmp}->get_leef();
|
||||||
|
|
||||||
# Parsing ports
|
foreach my $instance (@instances) {
|
||||||
foreach my $oid (keys %$result) {
|
my $stp_state = defined($results->{$oid_dot1dStpPortState}->{$oid_dot1dStpPortState . '.' . $instance}) ?
|
||||||
next if ($oid !~ /^$oid_dot1dStpPortState/);
|
$results->{$oid_dot1dStpPortState}->{$oid_dot1dStpPortState . '.' . $instance} : 10;
|
||||||
$oid =~ /\.([0-9]+)$/;
|
my $descr = (defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) && defined($result_desc->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}})) ?
|
||||||
my $instance = $1;
|
$result_desc->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 'unknown';
|
||||||
|
|
||||||
my $stp_state = $result->{$oid};
|
|
||||||
my $descr = $result_desc->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}};
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Spanning Tree interface '%s' state is %s", $descr,
|
$self->{output}->output_add(long_msg => sprintf("Spanning Tree interface '%s' state is %s", $descr,
|
||||||
${$states{$stp_state}}[0]));
|
${$states{$stp_state}}[0]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user