diff --git a/agent_based/inv_cisco_wlc_ap_cdp_cache.py b/agent_based/inv_cisco_wlc_ap_cdp_cache.py deleted file mode 100644 index b983c818a08f366a1380b48b51a36edd7aff4c53..0000000000000000000000000000000000000000 --- a/agent_based/inv_cisco_wlc_ap_cdp_cache.py +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# License: GNU General Public License v2 -# -# Author: thl-cmk[at]outlook[dot]com -# URL : https://thl-cmk.hopto.org -# Date : 2016-04-08 -# -# inventory of cisco wlc ap cdp cache -# -# 2016-08-22: removed index column -# 2018-08-03: code cleanup -# 2018-09-04: changes for CMK 1.5.x (inv_tree --> inv_tree_list) -# 2020-03-15: added support for CMK1.6x -# 2021-07-10: rewritten vor CMK 2.0 -# 2021-07-15 : added support for Catalyst 9800 Controllers -# 2023-06-07: moved gui files to ~/local/lib/chek_mk/gui/plugins/... -# - -from cmk.base.plugins.agent_based.agent_based_api.v1 import ( - register, - SNMPTree, - TableRow, - contains, - any_of, -) -from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( - StringTable, - InventoryResult, -) - - -def _render_ip_address(bytestring): - if len(bytestring) == 4: - return '.'.join(['%s' % ord(m) for m in bytestring]) - else: - bytestring_clean = bytestring.replace('"', '').replace('|4|', '').replace('.', ' ').strip().split(' ') - try: - return '.'.join(['%s' % int(m, 16) for m in bytestring_clean]) - except ValueError: - return bytestring - - -_cdp_duplex = { - '0': 'N/A', - '1': 'unknown', - '2': 'full duplex', - '3': 'half duplex', -} - -_cdp_speed = { - '0': 'N/A', - '1': 'none', - '2': '10Mbps', - '3': '100Mbps', - '4': '1000Mbps', - '5': 'auto', -} - -_interface_displayhints = { - 'ethernet': 'eth', - 'fastethernet': 'Fa', - 'gigabitethernet': 'Gi', - 'tengigabitethernet': 'Te', - 'fortygigabitethernet': 'Fo', - 'hundredgigabitethernet': 'Hu', - 'port-channel': 'Po', - 'tunnel': 'Tu', - 'loopback': 'Lo', - 'cellular': 'Cel', - 'vlan': 'Vlan', - 'management': 'Ma', -} - - -def _get_short_if_name(ifname: str) -> str: - """ - returns short interface name from long interface name - ifname: is the long interface name - :type ifname: str - """ - - for ifname_prefix in _interface_displayhints.keys(): - if ifname.lower().startswith(ifname_prefix.lower()): - ifname_short = _interface_displayhints[ifname_prefix] - return ifname.lower().replace(ifname_prefix.lower(), ifname_short, 1) - return ifname - - -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) - - if int(neighaddresstype) == 1: - neighaddress = _render_ip_address(neighaddress) - - neighbours.append({ - 'ap_name': apname, - 'ap_address': apaddress, - 'neighbour_name': neighname, - 'neighbour_address': neighaddress, - 'neighbour_interface': neighinterface, - 'neighbour_platform': platform, - 'duplex': _cdp_duplex.get(duplex), - 'speed': _cdp_speed.get(speed), - }) - - return neighbours - - -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) - - path = ['networking', 'wlan', 'controller', 'ap_cdp_cache'] - - for neighbour in section: - if remove_domain: - if not domain_name == '': - neighbour['neighbour_name'] = neighbour['neighbour_name'].replace(domain_name, '') - else: - neighbour['neighbour_name'] = neighbour['neighbour_name'].split('.')[0] - - if use_short_if_name: - neighbour['neighbour_interface'] = _get_short_if_name(neighbour['neighbour_interface']) - - key_columns = {'ap_name': neighbour['ap_name']} - - for key in key_columns.keys(): - neighbour.pop(key) - - for entry in removecolumns: - neighbour.pop(entry) - - yield TableRow( - path=path, - key_columns=key_columns, - inventory_columns=neighbour - ) - - -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', # 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=any_of( - contains('.1.3.6.1.2.1.1.1.0', 'Cisco Controller'), # sysDescr - contains('.1.3.6.1.2.1.1.1.0', 'C9800 Software'), # sysDescr - ) -) - -register.inventory_plugin( - name='inv_cisco_wlc_ap_cdp_cache', - inventory_function=inventory_cisco_wlc_ap_cdp_cache, - inventory_default_parameters={}, - inventory_ruleset_name='inv_cisco_wlc_ap_cdp_cache', -) diff --git a/gui/views/inv_cisco_wlc_ap_cdp_cache.py b/gui/views/inv_cisco_wlc_ap_cdp_cache.py deleted file mode 100644 index 08a3932ff7db406732b9f5fbfb2d414e21d1509b..0000000000000000000000000000000000000000 --- a/gui/views/inv_cisco_wlc_ap_cdp_cache.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# License: GNU General Public License v2 -# -# Author: thl-cmk[at]outlook[dot]com -# URL : https://thl-cmk.hopto.org -# Date : 2016-04-08 -# -# -# 2023-06-14: removed declare_invtable_view from view definition on cmk 2.2 (see werk 15493) -# changed inventory_displayhints import (see werk 15493) - - -from cmk.gui.i18n import _ -from cmk.gui.views.inventory.registry import inventory_displayhints - -inventory_displayhints.update({ - '.networking.wlan.controller.ap_cdp_cache:': {'title': _('Access Points CDP Cache'), - 'keyorder': ['ap_name', 'ap_address', 'neighbour_name', - 'neighbour_address', 'neighbour_interface', - 'neighbour_platform', ], - 'view': 'invwlcapcdpcache_of_host', - }, - '.networking.wlan.controller.ap_cdp_cache:*.ap_name': {'title': _('AP name'), }, - '.networking.wlan.controller.ap_cdp_cache:*.ap_address': {'title': _('AP address'), }, - '.networking.wlan.controller.ap_cdp_cache:*.neighbour_name': {'title': _('Neighbour name'), }, - '.networking.wlan.controller.ap_cdp_cache:*.neighbour_address': {'title': _('Neighbour address'), }, - '.networking.wlan.controller.ap_cdp_cache:*.neighbour_interface': {'title': _('Neighbour interface'), }, - '.networking.wlan.controller.ap_cdp_cache:*.neighbour_platform': {'title': _('Neighbour platform'), }, - '.networking.wlan.controller.ap_cdp_cache:*.duplex': {'title': _('Duplex'), }, - '.networking.wlan.controller.ap_cdp_cache:*.speed': {'title': _('Speed'), }, -}) diff --git a/gui/wato/check_parameters/inv_cisco_wlc_ap_cdp_cache.py b/gui/wato/check_parameters/inv_cisco_wlc_ap_cdp_cache.py deleted file mode 100644 index d24febe6fe6a8a3518589439eeb41a9b48736f93..0000000000000000000000000000000000000000 --- a/gui/wato/check_parameters/inv_cisco_wlc_ap_cdp_cache.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# License: GNU General Public License v2 -# -# Author: thl-cmk[at]outlook[dot]com -# URL : https://thl-cmk.hopto.org -# Date : 2016-04-08 -# -# -# 2023-06-14: moved wato file to check_parameters sub directory - -from cmk.gui.i18n import _ -from cmk.gui.plugins.wato.utils import ( - HostRulespec, - rulespec_registry, -) -from cmk.gui.valuespec import ( - Dictionary, - FixedValue, - TextAscii, - ListChoice, -) - -from cmk.gui.plugins.wato.inventory import ( - RulespecGroupInventory, -) - -_removecolumns_cisco_wlc_ap_cdp_cache = [ - ('duplex', 'Duplex'), - ('speed', 'Speed'), -] - - -def _valuespec_inv_cisco_wlc_ap_cdp_cache(): - return Dictionary( - title=_('Cisco WLC AP CDP cache'), - elements=[ - ('remove_domain', - FixedValue( - True, - title=_('Remove domain name from neighbour device name'), - totext=_('Remove the domain name enabled'), - default_value=False, - )), - ('domain_name', - TextAscii( - title=_('Specific domain name to remove from neighbour device name'), - allow_empty=False, - default_value='', - )), - ('removecolumns', - ListChoice( - title=_('List of columns to remove'), - help=_('information to remove from inventory'), - choices=_removecolumns_cisco_wlc_ap_cdp_cache, - default_value=[], - )), - ('use_short_if_name', - FixedValue( - True, - title=_('use short interface names (i.e. Gi0/0 for GigabitEthernet0/0)'), - totext=_('use short interface names enabled'), - default_value=False, - )), - ], - ) - - -rulespec_registry.register( - HostRulespec( - group=RulespecGroupInventory, - match_type='dict', - name='inv_parameters:inv_cisco_wlc_ap_cdp_cache', - valuespec=_valuespec_inv_cisco_wlc_ap_cdp_cache, - )) diff --git a/mkp/inv_cisco_wlc_ap_cdp_cache-0.4.1-20240308.mkp b/mkp/inv_cisco_wlc_ap_cdp_cache-0.4.1-20240308.mkp index f1ee1d7d9944f04d602f8ed2914c9608b3ba91c8..5475aeec6c66d759562d2892098da906e6400ab6 100644 Binary files a/mkp/inv_cisco_wlc_ap_cdp_cache-0.4.1-20240308.mkp and b/mkp/inv_cisco_wlc_ap_cdp_cache-0.4.1-20240308.mkp differ diff --git a/packages/inv_cisco_wlc_ap_cdp_cache b/packages/inv_cisco_wlc_ap_cdp_cache deleted file mode 100644 index 835b039dd882e124eb4e98ac97fae5b844114fc0..0000000000000000000000000000000000000000 --- a/packages/inv_cisco_wlc_ap_cdp_cache +++ /dev/null @@ -1,21 +0,0 @@ -{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)', - 'description': 'SNMP inventory for Cisco WLC AP CDP cache ' - '(CISCO-LWAPP-CDP-MIB).\n' - '\n' - 'via WATO you can:\n' - ' - you can add/remove some fields\n' - ' - remove domain from neighbor name\n' - ' - use short interface names\n' - '\n' - '2020-03.15: added support for CMK1.6x\n' - '2021-07-10: rewritten for CMK 2.0\n', - 'download_url': 'https://thl-cmk.hopto.org', - 'files': {'agent_based': ['inv_cisco_wlc_ap_cdp_cache.py'], - 'gui': ['views/inv_cisco_wlc_ap_cdp_cache.py', - 'wato/check_parameters/inv_cisco_wlc_ap_cdp_cache.py']}, - 'name': 'inv_cisco_wlc_ap_cdp_cache', - 'title': 'inventory for Cisco WLC AP CDP cache (CISCO-LWAPP-CDP-MIB)', - 'version': '0.4.0-20230614', - 'version.min_required': '2.2.0b1', - 'version.packaged': '2.2.0p2', - 'version.usable_until': None}