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
dcbcc09202
commit
7c314aeba8
|
@ -324,10 +324,10 @@ sub get_multiple_table {
|
|||
# Transform asking
|
||||
if ($entry->{oid} !~ /(.*)\.(\d+)([\.\s]*)$/) {
|
||||
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;
|
||||
}
|
||||
$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});
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ sub get_multiple_table {
|
|||
|
||||
} else {
|
||||
foreach (keys %{$results}) {
|
||||
$total += scalar(%{$results->{$_}});
|
||||
$total += scalar(keys %{$results->{$_}});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ my %states = (
|
|||
4 => ['learning', 'OK'],
|
||||
5 => ['forwarding', 'OK'],
|
||||
6 => ['broken', 'CRITICAL'],
|
||||
|
||||
10 => ['not defined', 'UNKNOWN'], # mine status
|
||||
);
|
||||
|
||||
sub new {
|
||||
|
@ -76,39 +78,43 @@ sub run {
|
|||
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_ifDesc = '.1.3.6.1.2.1.2.2.1.2';
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_dot1dStpPortEnable, nothing_quit => 1);
|
||||
|
||||
foreach my $oid (keys %$result) {
|
||||
my $results = $self->{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $oid_dot1dStpPortEnable },
|
||||
{ oid => $oid_dot1dStpPortState },
|
||||
], nothing_quit => 1);
|
||||
my @instances = ();
|
||||
foreach my $oid (keys %{$results->{$oid_dot1dStpPortEnable}}) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
# '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));
|
||||
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',
|
||||
short_msg => 'Spanning Tree is ok on all interfaces');
|
||||
# Get description
|
||||
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}]);
|
||||
}
|
||||
my $result_desc = $self->{snmp}->get_leef();
|
||||
|
||||
# Parsing ports
|
||||
foreach my $oid (keys %$result) {
|
||||
next if ($oid !~ /^$oid_dot1dStpPortState/);
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $stp_state = $result->{$oid};
|
||||
my $descr = $result_desc->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}};
|
||||
foreach my $instance (@instances) {
|
||||
my $stp_state = defined($results->{$oid_dot1dStpPortState}->{$oid_dot1dStpPortState . '.' . $instance}) ?
|
||||
$results->{$oid_dot1dStpPortState}->{$oid_dot1dStpPortState . '.' . $instance} : 10;
|
||||
my $descr = (defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) && defined($result_desc->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}})) ?
|
||||
$result_desc->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 'unknown';
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Spanning Tree interface '%s' state is %s", $descr,
|
||||
${$states{$stp_state}}[0]));
|
||||
|
|
Loading…
Reference in New Issue