Fix Cisco WLC AP cleanup (#13615)

* Fix Cisco WLC AP cleanup

* missing space
This commit is contained in:
Tony Murray
2021-12-12 22:33:54 -06:00
committed by GitHub
parent edd645264c
commit a0de9083b5
4 changed files with 509 additions and 136 deletions

View File

@@ -26,7 +26,6 @@
namespace LibreNMS\OS;
use App\Models\AccessPoint;
use Illuminate\Support\Arr;
use LibreNMS\Device\WirelessSensor;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessApCountDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
@@ -42,17 +41,18 @@ class Ciscowlc extends Cisco implements
public function pollOS(): void
{
$device = $this->getDeviceArray();
$stats = snmpwalk_cache_oid($device, 'bsnAPEntry', [], 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb');
$radios = snmpwalk_cache_oid($device, 'bsnAPIfEntry', [], 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb');
$APstats = snmpwalk_cache_oid($device, 'bsnApIfNoOfUsers', [], 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb');
$loadParams = snmpwalk_cache_oid($device, 'bsnAPIfLoadChannelUtilization', [], 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb');
$interferences = snmpwalk_cache_oid($device, 'bsnAPIfInterferencePower', [], 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb');
$apNames = \SnmpQuery::enumStrings()->walk('AIRESPACE-WIRELESS-MIB::bsnAPName')->table(1);
$radios = \SnmpQuery::enumStrings()->walk('AIRESPACE-WIRELESS-MIB::bsnAPIfTable')->table(2);
\SnmpQuery::walk('AIRESPACE-WIRELESS-MIB::bsnAPIfLoadChannelUtilization')->table(2, $radios);
$interferences = \SnmpQuery::walk('AIRESPACE-WIRELESS-MIB::bsnAPIfInterferencePower')->table(3);
$numAccessPoints = is_countable($stats) ? count($stats) : 0;
$numAccessPoints = count($apNames);
$numClients = 0;
foreach (Arr::wrap($APstats) as $value) {
$numClients += $value['bsnApIfNoOfUsers'];
foreach ($radios as $radio) {
foreach ($radio as $slot) {
$numClients += $slot['AIRESPACE-WIRELESS-MIB::bsnApIfNoOfUsers'];
}
}
$rrd_def = RrdDefinition::make()
@@ -68,24 +68,25 @@ class Ciscowlc extends Cisco implements
data_update($device, 'ciscowlc', $tags, $fields);
$db_aps = $this->getDevice()->accessPoints->keyBy->getCompositeKey();
$valid_ap_ids = [];
foreach ($radios as $key => $value) {
$indexName = substr($key, 0, -2);
$channel = str_replace('ch', '', $value['bsnAPIfPhyChannelNumber'] ?? '');
foreach ($radios as $mac => $radio) {
foreach ($radio as $slot => $value) {
$channel = str_replace('ch', '', $value['AIRESPACE-WIRELESS-MIB::bsnAPIfPhyChannelNumber'] ?? '');
$ap = new AccessPoint([
'device_id' => $device['device_id'],
'name' => $stats[$indexName]['bsnAPName'] ?? '',
'radio_number' => Arr::first(explode('.', $key)),
'type' => $value['bsnAPIfType'] ?? '',
'mac_addr' => str_replace(' ', ':', $stats[$indexName]['bsnAPDot3MacAddress'] ?? ''),
'device_id' => $this->getDeviceId(),
'name' => $apNames[$mac]['AIRESPACE-WIRELESS-MIB::bsnAPName'] ?? '',
'radio_number' => $slot,
'type' => $value['AIRESPACE-WIRELESS-MIB::bsnAPIfType'] ?? '',
'mac_addr' => $mac,
'channel' => $channel,
'txpow' => $value['bsnAPIfPhyTxPowerLevel'] ?? 0,
'radioutil' => $loadParams[$key]['bsnAPIfLoadChannelUtilization'] ?? 0,
'numasoclients' => $value['bsnApIfNoOfUsers'] ?? 0,
'txpow' => $value['AIRESPACE-WIRELESS-MIB::bsnAPIfPhyTxPowerLevel'] ?? 0,
'radioutil' => $value['AIRESPACE-WIRELESS-MIB::bsnAPIfLoadChannelUtilization'] ?? 0,
'numasoclients' => $value['AIRESPACE-WIRELESS-MIB::bsnApIfNoOfUsers'] ?? 0,
'nummonclients' => 0,
'nummonbssid' => 0,
'interference' => 128 + ($interferences[$key . '.' . $channel]['bsnAPIfInterferencePower'] ?? -128),
'interference' => 128 + ($interferences[$mac][$slot][$channel]['AIRESPACE-WIRELESS-MIB::bsnAPIfInterferencePower'] ?? -128), // why are we adding 128?
]);
d_echo($ap->toArray());
@@ -121,14 +122,16 @@ class Ciscowlc extends Cisco implements
/** @var AccessPoint $db_ap */
if ($db_ap = $db_aps->get($ap->getCompositeKey())) {
$db_aps->forget($ap->getCompositeKey());
$ap = $db_ap->fill($ap->getAttributes());
}
$ap->save(); // persist ap
$valid_ap_ids[] = $ap->accesspoint_id;
}
}
$db_aps->each->delete(); // delete those not removed
// delete invalid aps
$this->getDevice()->accessPoints->whereNotIn('accesspoint_id', $valid_ap_ids)->each->delete();
}
/**

View File

@@ -1,3 +1,25 @@
-- **********************************************************
-- Airespace Reference MIB
-- Copyright 2005 Cisco Systems, Inc. All rights reserved.
-- This SNMP Management Information Specification
-- embodies Cisco's confidential and proprietary
-- intellectual property. Cisco retains all title
-- and ownership in the Specification including any revisions.
-- This Specification is supplied "AS IS", Cisco
-- makes no warranty, either expressed or implied,
-- as to the use, operation, condition, or performance of the
-- Specification.
-- Status: Release
-- Version: 4.0
-- Internal Source Code Version:1.268
-- Date: 01 Jan 2006
-- **********************************************************
AIRESPACE-REF-MIB DEFINITIONS ::= BEGIN
IMPORTS
@@ -5,6 +27,7 @@ IMPORTS
enterprises
FROM SNMPv2-SMI;
airespace MODULE-IDENTITY
LAST-UPDATED "200512190000Z" -- December 19, 2005
ORGANIZATION "Airespace, Inc."
@@ -23,6 +46,7 @@ airespace MODULE-IDENTITY
REVISION "200512190000Z" -- December 19, 2005
DESCRIPTION
"Initial version of this MIB module."
::= { enterprises 14179 } -- assigned by IANA
END

View File

@@ -1,3 +1,25 @@
-- *******************************************************************
-- Airespace Switching MIB
-- Copyright 2001 Airespace, Inc. All rights reserved.
-- This SNMP Management Information Specification
-- embodies Airespace's confidential and proprietary
-- intellectual property. LVL7 Systems retains all title
-- and ownership in the Specification including any revisions.
-- This Specification is supplied "AS IS", Airespace
-- makes no warranty, either expressed or implied,
-- as to the use, operation, condition, or performance of the
-- Specification.
-- Status: Release
-- Version: 3.2
-- Internal Source Code Version:1.75
-- Date: 19 Dec 2005
-- *******************************************************************
AIRESPACE-SWITCHING-MIB DEFINITIONS ::= BEGIN
IMPORTS
@@ -71,6 +93,7 @@ IMPORTS
+ + + + + + + + + +
+......+ +......+ +......+ +......+ +......+
The LWAPP tunnel exists between the controller and
the APs. The MNs communicate with the APs through
the protocol defined by the 802.11 standard.
@@ -129,6 +152,7 @@ IMPORTS
802.11 protocol operations by the AP to work
cooperatively with the other APs and 802.11
devices in the network.
REFERENCE
[1] Part 11 Wireless LAN Medium Access Control ( MAC )
@@ -138,8 +162,10 @@ IMPORTS
Weight Access Point Protocol. "
REVISION "200604100000Z"
DESCRIPTION
"Updated MIB with description and format"
::= { airespace 1 }
--********************************************************************
@@ -154,12 +180,15 @@ IMPORTS
bsnSwitchingGroups OBJECT IDENTIFIER ::= { bsnSwitching 51 }
bsnSwitchingCompliances OBJECT IDENTIFIER ::= { bsnSwitching 52 }
--********************************************************************
-- agentInventoryGroup
--********************************************************************
agentInventoryGroup OBJECT IDENTIFIER ::= { agentInfoGroup 1 }
agentInventorySysDescription OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
@@ -192,6 +221,7 @@ IMPORTS
"Serial number of the switch."
::= { agentInventoryGroup 4 }
agentInventoryMaintenanceLevel OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
@@ -200,12 +230,14 @@ IMPORTS
"The switch's Inventory Maintenance Level"
::= { agentInventoryGroup 6 }
agentInventoryBurnedInMacAddress OBJECT-TYPE
SYNTAX PhysAddress
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Burned-In MAC Address"
::= { agentInventoryGroup 9 }
agentInventoryOperatingSystem OBJECT-TYPE
@@ -267,6 +299,7 @@ IMPORTS
Access Points."
::= { agentInventoryGroup 17 }
agentInventoryMaxNumberOfAPsSupported OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
@@ -274,6 +307,7 @@ IMPORTS
DESCRIPTION
"Maximum number of APs supported with this
Controller."
::= { agentInventoryGroup 18 }
agentInventoryIsCryptoCard2Present OBJECT-TYPE
@@ -298,6 +332,7 @@ IMPORTS
DEFVAL {false}
::= { agentInventoryGroup 20 }
--********************************************************************
-- agentTrapLogGroup
--********************************************************************
@@ -357,6 +392,7 @@ IMPORTS
traps sent since last reset."
::= { agentTrapLogGroup 8 }
agentApInterferenceProfileFailTrapCount OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
@@ -375,6 +411,7 @@ IMPORTS
traps sent since last reset."
::= { agentTrapLogGroup 10 }
--********************************************************************
-- agentTrapLogTable
--********************************************************************
@@ -428,12 +465,14 @@ IMPORTS
"Description of the trap sent."
::= { agentTrapLogEntry 22 }
--********************************************************************
-- agentSwitchInfoGroup
--********************************************************************
agentSwitchInfoGroup OBJECT IDENTIFIER ::= { agentInfoGroup 3 }
agentSwitchInfoLwappTransportMode OBJECT-TYPE
SYNTAX INTEGER {
layer2(1),
@@ -504,6 +543,7 @@ IMPORTS
earlier device versions."
::= { agentSwitchInfoGroup 5 }
--********************************************************************
-- agentResourceInfoGroup
--********************************************************************
@@ -538,6 +578,7 @@ IMPORTS
-- agentWcpInfoGroup
--********************************************************************
agentWcpInfoGroup OBJECT IDENTIFIER ::= { agentInfoGroup 6 }
agentWcpDeviceName OBJECT-TYPE
@@ -650,6 +691,7 @@ IMPORTS
"The management IP Address of a controller."
::= { agentWcpControllerInfoEntry 10 }
--********************************************************************
-- agentProductGroup
--********************************************************************
@@ -782,6 +824,7 @@ IMPORTS
this user."
::= { agentLoginSessionEntry 26 }
--********************************************************************
-- agentTelnetConfigGroup
--********************************************************************
@@ -981,6 +1024,7 @@ IMPORTS
"Agent Lag If Index"
::= { agentLagSummaryConfigEntry 2 }
agentLagSummaryFlushTimer OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-create
@@ -1062,6 +1106,7 @@ IMPORTS
Lag."
::= { agentLagSummaryConfigEntry 30 }
--*******************************************************************
-- agentLagDetailedConfigTable
--*******************************************************************
@@ -1116,6 +1161,7 @@ IMPORTS
description and list of valid values."
::= { agentLagDetailedConfigEntry 22 }
agentLagConfigMode OBJECT-TYPE
SYNTAX INTEGER {
off(1),
@@ -1129,6 +1175,7 @@ IMPORTS
aggregated link."
::= { agentLagConfigGroup 4 }
--********************************************************************
-- agentNetworkConfigGroup
--********************************************************************
@@ -1234,6 +1281,7 @@ IMPORTS
"Sets the idle user timeout."
::= { agentNetworkConfigGroup 12 }
agentNetworkArpTimeout OBJECT-TYPE
SYNTAX Unsigned32(10..2147483647)
MAX-ACCESS read-write
@@ -1358,6 +1406,7 @@ IMPORTS
"Multicast group address for access points."
::= { agentNetworkConfigGroup 25 }
--********************************************************************
-- agentNeworkRouteTable
--********************************************************************
@@ -1418,6 +1467,8 @@ IMPORTS
"Network Route Row Status."
::= { agentNetworkRouteConfigEntry 23 }
--********************************************************************
-- agentInterfaceConfigTable
--********************************************************************
@@ -1667,6 +1718,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"The interface entry Row status."
::= { agentInterfaceConfigEntry 31 }
--********************************************************************
-- agentNtpConfigGroup - Configuration of Switch Network Time Protocol
--********************************************************************
@@ -1717,6 +1769,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"NTP Server priority index."
::= { agentNtpServerEntry 1 }
agentNtpServerAddress OBJECT-TYPE
SYNTAX IpAddress
MAX-ACCESS read-create
@@ -1733,6 +1786,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"NTP server entry row status."
::= { agentNtpServerEntry 20 }
--********************************************************************
-- agentDhcpConfigGroup - Configuration of Switch DHCP Server and
-- its Scopes
@@ -1943,6 +1997,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"Dhcp Scope entry row status."
::= { agentDhcpScopeEntry 30 }
--********************************************************************
-- agentServicePortConfigGroup
-- (Interface of type service-port in agentInterfaceConfigTable
@@ -2013,12 +2068,14 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
of this group)"
::= { agentServicePortConfigGroup 5 }
--********************************************************************
-- agentSnmpConfigGroup
--********************************************************************
agentSnmpConfigGroup OBJECT IDENTIFIER ::= {agentConfigGroup 5}
agentSnmpTrapPortNumber OBJECT-TYPE
SYNTAX Unsigned32(1..65534)
MAX-ACCESS read-write
@@ -2043,6 +2100,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"Snmp Version 2c Status"
::= { agentSnmpConfigGroup 3 }
--********************************************************************
-- agentSnmpCommunityConfigTable
--********************************************************************
@@ -2190,6 +2248,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
community from the agent."
::= { agentSnmpCommunityConfigEntry 25 }
--********************************************************************
-- agentSnmpTrapReceiverConfigTable
--********************************************************************
@@ -2357,6 +2416,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
agentSnmpV3ConfigGroup OBJECT IDENTIFIER ::= {agentConfigGroup 6}
agentSnmpVersion3Status OBJECT-TYPE
SYNTAX INTEGER{disable(0),enable(1)}
MAX-ACCESS read-write
@@ -2417,6 +2477,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"Agent User Access Mode"
::= { agentSnmpV3UserConfigEntry 2 }
agentSnmpV3UserAuthenticationType OBJECT-TYPE
SYNTAX INTEGER {
none(1),
@@ -2475,12 +2536,14 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
user account."
::= { agentSnmpV3UserConfigEntry 26 }
--********************************************************************
-- agentSpanningTreePortTable
--********************************************************************
agentSpanningTreeConfigGroup OBJECT IDENTIFIER ::=
{ agentConfigGroup 7 }
agentSpanningTreeMode OBJECT-TYPE
SYNTAX INTEGER {
enable(1),
@@ -2492,6 +2555,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"The switch's Spanning Tree Switch Status"
::= { agentSpanningTreeConfigGroup 1 }
--********************************************************************
-- agentSwitchConfigGroup
--********************************************************************
@@ -2581,6 +2645,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
change to take effect."
::= { agentSwitchConfigGroup 5 }
--********************************************************************
-- agentTransferConfigGroup
--********************************************************************
@@ -2588,6 +2653,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
agentTransferConfigGroup OBJECT IDENTIFIER ::=
{ agentConfigGroup 9 }
--*******************************************************************
-- agentTransferUploadGroup
--*******************************************************************
@@ -2680,6 +2746,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"
::= { agentTransferUploadGroup 5 }
agentTransferUploadStart OBJECT-TYPE
SYNTAX INTEGER {
enable(1),
@@ -2743,6 +2810,8 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
the switch."
::= { agentTransferConfigGroup 4 }
--********************************************************************
-- agentTransferDownloadGroup
--********************************************************************
@@ -2807,6 +2876,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
and File Name set to e1r1v1.opr. Note: File
Name, File Path, and TFTP Server IP Address are
applicable only if the Transfer Mode is TFTP."
::= { agentTransferDownloadGroup 4 }
agentTransferDownloadDataType OBJECT-TYPE
@@ -2832,6 +2902,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
- customWebauth- custom webauth tar ball"
::= { agentTransferDownloadGroup 5 }
agentTransferDownloadStart OBJECT-TYPE
SYNTAX INTEGER {
enable(1),
@@ -2940,6 +3011,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"Enable/disable 802.3ad LACP on this port"
::= { agentDot3adAggPortEntry 21 }
--********************************************************************
-- agentPortConfigTable
--
@@ -3147,6 +3219,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
dot3MauType100BaseTXFD
dot3MauType100BaseFXFD
dot3MauType1000BaseSXFD"
REFERENCE "RFC 2668"
::= { agentPortConfigEntry 11 }
@@ -3184,6 +3257,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
dot3MauType100BaseTXFD
dot3MauType100BaseFXFD
dot3MauType1000BaseSXFD"
REFERENCE "RFC 2668"
::= { agentPortConfigEntry 12 }
@@ -3199,6 +3273,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
auto negotiation for this port."
::= { agentPortConfigEntry 13 }
agentPortDot3FlowControlMode OBJECT-TYPE
SYNTAX INTEGER {
enable(1),
@@ -3315,6 +3390,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"The current operational state of the port."
::= { agentPortConfigEntry 40 }
--********************************************************************
-- agentSystemGroup
--********************************************************************
@@ -3396,6 +3472,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"clear trap log"
::= { agentSystemGroup 8 }
agentResetSystem OBJECT-TYPE
SYNTAX INTEGER {
enable(1),
@@ -3407,6 +3484,7 @@ agentInterfaceVlanQuarantine OBJECT-TYPE
"reset the switch"
::= { agentSystemGroup 10 }
--********************************************************************
-- portStatsTable
-- Enterprise portion of Ethernet Statistics Group
@@ -3548,6 +3626,7 @@ PortStatsEntry ::= SEQUENCE {
(excluding framing bits but including FCS octets)."
::= { portStatsEntry 9 }
portStatsPktsTxOversizeOctets OBJECT-TYPE
SYNTAX Counter32
UNITS "Packets"
@@ -3560,6 +3639,7 @@ PortStatsEntry ::= SEQUENCE {
(excluding framing bits but including FCS octets)."
::= { portStatsEntry 30 }
--********************************************************************
-- switchingTraps
--********************************************************************
@@ -3654,6 +3734,7 @@ PortStatsEntry ::= SEQUENCE {
"Power Supply Status Change Trap"
::= { switchingTraps 12 }
--********************************************************************
--* Compliance statements
--********************************************************************
@@ -3725,6 +3806,7 @@ bsnSwitchingAgentInfoGroup OBJECT-GROUP
"This collection of objects provide switching information."
::= { bsnSwitchingGroups 1}
bsnSwitchingAgentConfigGroup OBJECT-GROUP
OBJECTS {
agentLoginSessionIndex,
@@ -3900,6 +3982,7 @@ bsnSwitchingAgentSystemGroup OBJECT-GROUP
information and config."
::= { bsnSwitchingGroups 3 }
bsnSwitchingAgentStatsGroup OBJECT-GROUP
OBJECTS {
portStatsIndex,
@@ -3980,4 +4063,6 @@ bsnSwitchingTrap NOTIFICATION-GROUP
--* End of units of conformance
--********************************************************************
END

File diff suppressed because it is too large Load Diff