diff --git a/agent_based/inv_cisco_wlc_ap_cdp_cache.py b/agent_based/inv_cisco_wlc_ap_cdp_cache.py index 5f58c84d026ab375bce2a8ffffbfb39b0023617f..dd2c0954cf6a2c3b6fb5a3e03e580344b4682cf0 100644 --- a/agent_based/inv_cisco_wlc_ap_cdp_cache.py +++ b/agent_based/inv_cisco_wlc_ap_cdp_cache.py @@ -1,5 +1,5 @@ #!/usr/bin/python -#!/usr/bin/env python3 +# !/usr/bin/env python3 # -*- coding: utf-8 -*- # # License: GNU General Public License v2 @@ -37,17 +37,6 @@ from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( ) -class Neighbour(NamedTuple): - ap_name: str - ap_address: str - neighbour_name: str - neighbour_address: str - neighbour_interface: str - neighbour_platform: str - duplex: str - speed: str - - def _render_ip_address(bytestring): bytestring_clean = bytestring.replace('"', '').replace('|4|', '').replace('.', ' ').strip().split(' ') try: @@ -63,7 +52,6 @@ _cdp_duplex = { 3: 'half duplex', } - _cdp_speed = { 0: 'N/A', 1: 'none', @@ -73,7 +61,6 @@ _cdp_speed = { 5: 'auto', } - _interface_displayhints = { 'ethernet': 'eth', 'fastethernet': 'Fa', @@ -104,9 +91,10 @@ def _get_short_if_name(ifname: str) -> str: return ifname -def parse_cisco_wlc_ap_cdp_cache(string_table: StringTable): # -> List[Neighbour]: - neighbours=[] - for deviceindex, apname, apaddresstype, apaddress, neighname, neighaddresstype, neighaddress, neighinterface, platform, duplex, speed in string_table: +def parse_cisco_wlc_ap_cdp_cache(string_table: StringTable): + neighbours = [] + for deviceindex, apname, apaddresstype, apaddress, neighname, neighaddresstype, neighaddress, neighinterface, \ + platform, duplex, speed in string_table: if int(apaddresstype) == 1: apaddress = _render_ip_address(apaddress) @@ -128,16 +116,10 @@ def parse_cisco_wlc_ap_cdp_cache(string_table: StringTable): # -> List[Neighbour def inventory_cisco_wlc_ap_cdp_cache(params, section) -> InventoryResult: - removecolumns = [] - remove_domain = False - domain_name = '' - use_short_if_name = False - - if params: - removecolumns = params.get('removecolumns', removecolumns) - remove_domain = params.get('remove_domain', remove_domain) - domain_name = params.get('domain_name', domain_name) - use_short_if_name = params.get('use_short_if_name', use_short_if_name) + removecolumns = params['removecolumns'] + remove_domain = params['remove_domain'] + domain_name = params['domain_name'] + use_short_if_name = params['use_short_if_name'] path = ['networking', 'wlan', 'controller', 'ap_cdp_cache'] @@ -170,29 +152,33 @@ register.snmp_section( name='inv_cisco_wlc_ap_cdp_cache', parse_function=parse_cisco_wlc_ap_cdp_cache, fetch= - SNMPTree( - base='.1.3.6.1.4.1.9.9.623.1.3.1.1', # ISCO-LWAPP-CDP-MIB::clcCdpApCacheEntry - oids=[ - '1', # clcCdpApCacheDeviceIndex (1) - '2', # clcCdpApCacheApName (2) - '3', # clcCdpApCacheApAddressType (3) - '4', # clcCdpApCacheApAddress (4) - '6', # clcCdpApCacheNeighName (6) - '7', # clcCdpApCacheNeighAddressType (7) - '8', # clcCdpApCacheNeighAddress (8) - '9', # clcCdpApCacheNeighInterface (9) - '12', # clcCdpApCachePlatform (12) - '15', # clcCdpApCacheDuplex (15) - '16', # clcCdpApCacheInterfaceSpeed (16) - ] - ), + SNMPTree( + base='.1.3.6.1.4.1.9.9.623.1.3.1.1', # CISCO-LWAPP-CDP-MIB::clcCdpApCacheEntry + oids=[ + '1', # clcCdpApCacheDeviceIndex + '2', # clcCdpApCacheApName + '3', # clcCdpApCacheApAddressType + '4', # clcCdpApCacheApAddress + '6', # clcCdpApCacheNeighName + '7', # clcCdpApCacheNeighAddressType + '8', # clcCdpApCacheNeighAddress + '9', # clcCdpApCacheNeighInterface + '12', # clcCdpApCachePlatform + '15', # clcCdpApCacheDuplex + '16', # clcCdpApCacheInterfaceSpeed + ] + ), detect=contains('.1.3.6.1.2.1.1.1.0', 'Cisco Controller'), # sysDescr ) register.inventory_plugin( name='inv_cisco_wlc_ap_cdp_cache', inventory_function=inventory_cisco_wlc_ap_cdp_cache, - inventory_default_parameters={}, + inventory_default_parameters={ + 'removecolumns': [], + 'remove_domain': False, + 'domain_name': '', + 'use_short_if_name': False, + }, inventory_ruleset_name='inv_cisco_wlc_ap_cdp_cache', ) - diff --git a/inv_cisco_wlc_ap_cdp_cache.mkp b/inv_cisco_wlc_ap_cdp_cache.mkp index 6df513ff5db0e7cf10938e6140980f43e12c3733..716d934748dcd524b8bd41d071daba1edddb5b7a 100644 Binary files a/inv_cisco_wlc_ap_cdp_cache.mkp and b/inv_cisco_wlc_ap_cdp_cache.mkp differ