(plugin) network::cisco::wlc::snmp - enhance cisco wlc discovery mode (#4503)

This commit is contained in:
qgarnier 2023-07-03 11:43:59 +02:00 committed by GitHub
parent 3a7cb1bfa4
commit f9c88eac95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 36 deletions

View File

@ -56,27 +56,28 @@ my $map_operation_status = {
my $mapping = {
ap_name => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.3' }, # bsnAPName
ap_ipaddr => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.19' } # bsnApIpAddress
ap_location => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.4' }, # bsnAPLocation
ap_opstatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.6', map => $map_operation_status }, # bsnAPOperationStatus
ap_model => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.16' }, # bsnAPModel
ap_ipaddr => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.19' }, # bsnApIpAddress
ap_admstatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.37', map => $map_admin_status } # bsnAPAdminStatus
};
my $mapping2 = {
opstatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.6', map => $map_operation_status }, # bsnAPOperationStatus
admstatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.37', map => $map_admin_status } # bsnAPAdminStatus
};
my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3';
sub run {
my ($self, %options) = @_;
my %ap;
my @disco_data;
my $disco_stats;
$disco_stats->{start_time} = time();
my $request = [
{ oid => $oid_agentInventoryMachineModel },
{ oid => $mapping->{ap_name}->{oid} },
{ oid => $mapping->{ap_ipaddr}->{oid} }
{ oid => $mapping->{ap_location}->{oid} },
{ oid => $mapping->{ap_opstatus}->{oid} },
{ oid => $mapping->{ap_model}->{oid} },
{ oid => $mapping->{ap_ipaddr}->{oid} },
{ oid => $mapping->{ap_admstatus}->{oid} }
];
my $snmp_result = $options{snmp}->get_multiple_table(
oids => $request,
@ -93,35 +94,19 @@ sub run {
results => $snmp_result,
instance => $instance);
$self->{ap}->{ $result->{ap_name} } = {
next if (defined($self->{option_results}->{filter_admin_down}) && $result->{ap_admstatus} eq 'disable');
my $ap = {
name => $result->{ap_name},
instance => $instance,
location => $result->{ap_location},
model => $result->{ap_model},
ip => $result->{ap_ipaddr},
model => defined($snmp_result->{$oid_agentInventoryMachineModel . '.0'}) ?
$snmp_result->{$oid_agentInventoryMachineModel . '.0'} : 'unknown'
admstatus => $result->{ap_admstatus},
opstatus => $result->{ap_opstatus}
};
}
$options{snmp}->load(
oids => [ map($_->{oid}, values(%$mapping2)) ],
instances => [ map($_->{instance}, values %{$self->{ap}}) ],
instance_regexp => '^(.*)$'
);
$snmp_result = $options{snmp}->get_leef();
foreach my $ap_name (keys %{$self->{ap}}) {
my $result = $options{snmp}->map_instance(
mapping => $mapping2,
results => $snmp_result,
instance => $self->{ap}->{ $ap_name }->{instance}
);
$self->{ap}->{ $ap_name }->{admstatus} = $result->{admstatus};
$self->{ap}->{ $ap_name }->{opstatus} = $result->{opstatus};
next if (defined($self->{option_results}->{filter_admin_down}) && $result->{admstatus} eq 'disable');
push @disco_data, $self->{ap}->{ $ap_name };
push @disco_data, $ap;
}
$disco_stats->{end_time} = time();