diff --git a/agent_based/inv_cisco_wlc_clients.py b/agent_based/inv_cisco_wlc_clients.py index 9151962b07e5e8a2d88f8d105d1426b92638760e..3794c86a9ee45fdca4b6fe52e9e64a0f3894d685 100644 --- a/agent_based/inv_cisco_wlc_clients.py +++ b/agent_based/inv_cisco_wlc_clients.py @@ -15,17 +15,9 @@ # 2020-03-15: added support for CMK1.6x # 2021-07-12: rewritten for 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/... +# - -import re -import time -import binascii -from typing import List, NamedTuple - -from cmk.base.plugins.agent_based.agent_based_api.v1 import ( - OIDEnd, - OIDBytes, -) from cmk.base.plugins.agent_based.agent_based_api.v1 import ( register, SNMPTree, @@ -193,7 +185,8 @@ _powersavemode = { def _render_mac_address(bytestring): macaddress = bytestring - bytestring = bytestring.replace('|4|', ' ').replace('|4.', ' ').replace('"', '').strip(' ').strip('.').replace(' ', ':').replace('.', ':') + bytestring = bytestring.replace('|4|', ' ').replace('|4.', ' ').replace('"', '') + bytestring = bytestring.strip(' ').strip('.').replace(' ', ':').replace('.', ':') if len(bytestring) == 17: return bytestring @@ -223,7 +216,7 @@ def parse_inv_cisco_wlc_clients(string_table: StringTable): client['status_columns']['ipaddress'] = ipaddress client['status_columns']['quarantinevlan'] = quarantinevlan client['status_columns']['accessvlan'] = accessvlan - client['status_columns']['logintime'] =logintime + client['status_columns']['logintime'] = logintime client['status_columns']['uptime'] = uptime client['status_columns']['currenttxrateset'] = currenttxrateset client['status_columns']['datarateset'] = datarateset @@ -309,8 +302,7 @@ def inventory_cisco_wlc_clients(params, section) -> InventoryResult: register.snmp_section( name='inv_cisco_wlc_clients', parse_function=parse_inv_cisco_wlc_clients, - fetch= - SNMPTree( + fetch=SNMPTree( base='.1.3.6.1.4.1.9.9.599.1.3.1.1', # CISCO-LWAPP-DOT11-CLIENT-MIB::cldcClientEntry oids=[ '1', # cldcClientMacAddress diff --git a/gui/views/inv_cisco_wlc_clients.py b/gui/views/inv_cisco_wlc_clients.py new file mode 100644 index 0000000000000000000000000000000000000000..4ef9c43f482dbb148b6a32aef73256e1b85c3a29 --- /dev/null +++ b/gui/views/inv_cisco_wlc_clients.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from cmk.gui.plugins.views.utils import ( + inventory_displayhints, +) +from cmk.gui.i18n import _ +from cmk.gui.plugins.views.inventory import declare_invtable_view + +inventory_displayhints.update({ + '.networking.wlan.controller.clients:': { + 'title': _('WLC clients'), + 'keyorder': [ + 'index', 'username', 'uptime', 'ipaddress', 'apmacaddress', 'ssid', + 'channel', 'accessvlan', 'devicetype', 'protocol', 'status', + ], + 'view': 'invwlcclients_of_host'}, + + '.networking.wlan.controller.clients:*.index': {'title': _('Index'), }, + '.networking.wlan.controller.clients:*.username': {'title': _('Username'), }, + '.networking.wlan.controller.clients:*.uptime': {'title': _('Uptime'), }, + '.networking.wlan.controller.clients:*.ipaddress': {'title': _('IP address'), }, + '.networking.wlan.controller.clients:*.apmacaddress': {'title': _('AP MAC address'), }, + '.networking.wlan.controller.clients:*.ssid': {'title': _('SSID'), }, + '.networking.wlan.controller.clients:*.channel': {'title': _('Channel'), }, + '.networking.wlan.controller.clients:*.accessvlan': {'title': _('Access VLAN'), }, + '.networking.wlan.controller.clients:*.devicetype': {'title': _('Device type'), }, + '.networking.wlan.controller.clients:*.protocol': {'title': _('Protocol'), }, + '.networking.wlan.controller.clients:*.status': {'title': _('Status'), }, + + '.networking.wlan.controller.clients:*.macaddress': {'title': _('MAC Addresse'), }, + '.networking.wlan.controller.clients:*.wlanprofilename': {'title': _('WLAN profile name'), }, + '.networking.wlan.controller.clients:*.wgbstatus': {'title': _('WGB status'), }, + '.networking.wlan.controller.clients:*.wgbmacaddress': {'title': _('WGB MAC address'), }, + '.networking.wlan.controller.clients:*.associationmode': {'title': _('Association mode'), }, + '.networking.wlan.controller.clients:*.iftype': {'title': _('Interface type'), }, + '.networking.wlan.controller.clients:*.nacstate': {'title': _('NAC state'), }, + '.networking.wlan.controller.clients:*.quarantinevlan': {'title': _('Quarantine VLAN'), }, + '.networking.wlan.controller.clients:*.logintime': {'title': _('Login time'), }, + '.networking.wlan.controller.clients:*.powersavemode': {'title': _('Power save mode'), }, + '.networking.wlan.controller.clients:*.currenttxrateset': {'title': _('Current TX rate (MBit/s)'), }, + '.networking.wlan.controller.clients:*.datarateset': {'title': _('Data rate set'), }, + '.networking.wlan.controller.clients:*.hreapapauth': {'title': _('HREAP AP auth'), }, + '.networking.wlan.controller.clients:*.ieee80211ucapable': {'title': _('802.11u capable'), }, + '.networking.wlan.controller.clients:*.posturestate': {'title': _('Posture state'), }, + '.networking.wlan.controller.clients:*.aclname': {'title': _('ACL name'), }, + '.networking.wlan.controller.clients:*.aclapplied': {'title': _('ACL applied'), }, + '.networking.wlan.controller.clients:*.redirecturl': {'title': _('Redirect URL'), }, + '.networking.wlan.controller.clients:*.aaaoverrideaclname': {'title': _('AAA overide ACL name'), }, + '.networking.wlan.controller.clients:*.aaaoverrideaclapplied': {'title': _('AAA overide ACL applied'), }, + '.networking.wlan.controller.clients:*.securitytagid': {'title': _('Security tag ID'), }, + '.networking.wlan.controller.clients:*.typekts': {'title': _('NEC KTS SIP client'), }, + '.networking.wlan.controller.clients:*.ipv6aclname': {'title': _('IPv6 ACL name'), }, + '.networking.wlan.controller.clients:*.ipv6aclapplied': {'title': _('IPv6 ACL applied'), }, + '.networking.wlan.controller.clients:*.dataswitching': {'title': _('Data switching'), }, + '.networking.wlan.controller.clients:*.authentication': {'title': _('Authentication'), }, + '.networking.wlan.controller.clients:*.authmode': {'title': _('Auth mode'), }, + '.networking.wlan.controller.clients:*.reasoncode': {'title': _('Reason code'), }, + '.networking.wlan.controller.clients:*.sessionid': {'title': _('Session ID'), }, + '.networking.wlan.controller.clients:*.aproammacaddress': {'title': _('AP roam MAC address'), }, + '.networking.wlan.controller.clients:*.mdnsprofile': {'title': _('mDNS profile'), }, + '.networking.wlan.controller.clients:*.mdnsadvcount': {'title': _('mDNS adv count'), }, + '.networking.wlan.controller.clients:*.policyname': {'title': _('Policy name'), }, + '.networking.wlan.controller.clients:*.aaarole': {'title': _('AAA role'), }, + '.networking.wlan.controller.clients:*.userauthtype': {'title': _('User auth type'), }, +}) + +declare_invtable_view('invwlcclients', '.networking.wlan.controller.clients:', _('WLC clients'), _('WLC clients')) diff --git a/gui/wato/inv_cisco_wlc_clients.py b/gui/wato/inv_cisco_wlc_clients.py new file mode 100644 index 0000000000000000000000000000000000000000..79933969e27698009d1c614d26258a8a91e2be12 --- /dev/null +++ b/gui/wato/inv_cisco_wlc_clients.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# + +from cmk.gui.i18n import _ +from cmk.gui.plugins.wato.utils import ( + HostRulespec, + rulespec_registry, +) +from cmk.gui.valuespec import ( + Dictionary, + ListChoice, +) + +from cmk.gui.plugins.wato.inventory import ( + RulespecGroupInventory, +) + +_removecolumns_cisco_wlc_clients = [ + # 'index': {'title', 'Index'), + # 'username': {'title', 'Username'), + # 'uptime': {'title', 'Uptime'), + # 'ipaddress': {'title', 'IP address'), + # 'apmacaddress': {'title', 'AP MAC address'), + # 'ssid': {'title', 'SSID'), + # 'channel': {'title', 'Channel'), + # 'accessvlan': {'title', 'Access VLAN'), + # 'devicetype': {'title', 'Device type'), + # 'protocol': {'title', 'Protocol'), + # 'status': {'title', 'Status'), + + ('ieee80211ucapable', '802.11u capable'), + ('aaaoverrideaclapplied', 'AAA overide ACL applied'), + ('aaaoverrideaclname', 'AAA overide ACL name'), + ('aaarole', 'AAA role'), + ('aclapplied', 'ACL applied'), + ('aclname', 'ACL name'), + ('aproammacaddress', 'AP roam MAC address'), + ('associationmode', 'Association mode'), + ('authentication', 'Authentication'), + ('authmode', 'Auth mode'), + ('currenttxrateset', 'Current TX rate (MBit/s)'), + ('datarateset', 'Data rate set'), + ('dataswitching', 'Data switching'), + ('hreapapauth', 'HREAP AP auth'), + ('iftype', 'Interface type'), + ('ipv6aclapplied', 'IPv6 ACL applied'), + ('ipv6aclname', 'IPv6 ACL name'), + ('logintime', 'Login time'), + ('macaddress', 'MAC Addresse'), + ('mdnsadvcount', 'mDNS adv count'), + ('mdnsprofile', 'mDNS profile'), + ('nacstate', 'NAC state'), + ('policyname', 'Policy name'), + ('posturestate', 'Posture state'), + ('powersavemode', 'Power save mode'), + ('quarantinevlan', 'Quarantine VLAN'), + ('reasoncode', 'Reason code'), + ('redirecturl', 'Redirect URL'), + ('securitytagid', 'Security tag ID'), + ('sessionid', 'Session ID'), + ('typekts', 'NEC KTS SIP client'), + ('userauthtype', 'User auth type'), + ('wgbmacaddress', 'WGB MAC address'), + ('wgbstatus', 'WGB status'), + ('wlanprofilename', 'WLAN profile name'), +] + + +def _valuespec_inv_cisco_wlc_clients(): + return Dictionary( + title=_('Cisco WLC Clients'), + help=_('This inventory plugin collects all the client information from a Cisco Wireless LAN Controller. ' + 'To use this plugin you must also enable "Status data inventory" in a "Do hardware/software inventory" ' + 'rule.'), + elements=[ + ('removecolumns', + ListChoice( + title=_('list of columns to remove'), + help=_('information to remove from inventory'), + choices=_removecolumns_cisco_wlc_clients, + default_value=[], + )), + ], + ) + + +rulespec_registry.register( + HostRulespec( + group=RulespecGroupInventory, + match_type='dict', + name='inv_parameters:inv_cisco_wlc_clients', + valuespec=_valuespec_inv_cisco_wlc_clients, + )) diff --git a/inv_cisco_wlc_clients-0.3.1-20230607.mkp b/inv_cisco_wlc_clients-0.3.1-20230607.mkp new file mode 100644 index 0000000000000000000000000000000000000000..3cbfb4cd9d266ec96cf81afadb17e28c87f1fa4c Binary files /dev/null and b/inv_cisco_wlc_clients-0.3.1-20230607.mkp differ diff --git a/inv_cisco_wlc_clients.mkp b/inv_cisco_wlc_clients.mkp index a6caf989a98b1841145c5960673885ecfd1056f6..3cbfb4cd9d266ec96cf81afadb17e28c87f1fa4c 100644 Binary files a/inv_cisco_wlc_clients.mkp and b/inv_cisco_wlc_clients.mkp differ diff --git a/packages/inv_cisco_wlc_clients b/packages/inv_cisco_wlc_clients index a8519f062390a5270449571d413e0ae3491fb382..ef573c9c33b861d75efe0e0b5cb7af1f91cf1bf2 100644 --- a/packages/inv_cisco_wlc_clients +++ b/packages/inv_cisco_wlc_clients @@ -9,12 +9,11 @@ '2021-07-12: rewritten for CMK 2.0\n', 'download_url': 'http://thl-cmk.hopto.org', 'files': {'agent_based': ['inv_cisco_wlc_clients.py'], - 'web': ['plugins/views/inv_cisco_wlc_clients.py', - 'plugins/wato/inv_cisco_wlc_clients.py']}, + 'gui': ['views/inv_cisco_wlc_clients.py', + 'wato/inv_cisco_wlc_clients.py']}, 'name': 'inv_cisco_wlc_clients', - 'num_files': 3, 'title': 'inventory of cisco WLC clients', - 'version': '20210715.v0.3a', - 'version.min_required': '2.0.0', - 'version.packaged': '2021.07.14', + 'version': '0.3.1-20230607', + 'version.min_required': '2.1.0b1', + 'version.packaged': '2.1.0p21', 'version.usable_until': None} \ No newline at end of file