diff --git a/README.md b/README.md index 310af2a4709ae98758058ac98bf2191921ebd0db..d67420110740f4d18b299095f91b5a072f0433ec 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PACKAGE]: ../../raw/master/mkp/cisco_meraki-1.3.5-20240807.mkp "cisco_meraki-1.3.5-20240807.mkp" +[PACKAGE]: ../../raw/master/mkp/cisco_meraki-1.3.6-20240915.mkp "cisco_meraki-1.3.6-20240915.mkp" [SDK]: ../../raw/master/mkp/MerakiSDK-1.46.0-20240912.mkp "MerakiSDK-1.46.0-20240516.mkpp" # Cisco Meraki special agent diff --git a/mkp/cisco_meraki-1.3.6-20240915.mkp b/mkp/cisco_meraki-1.3.6-20240915.mkp new file mode 100644 index 0000000000000000000000000000000000000000..786de1b3290149638c72f8a20f78ae57769add45 Binary files /dev/null and b/mkp/cisco_meraki-1.3.6-20240915.mkp differ diff --git a/source/cmk_addons_plugins/meraki/agent_based/wireless_device_ssid_status.py b/source/cmk_addons_plugins/meraki/agent_based/wireless_device_ssid_status.py index 04deeffde4b6350716691cf733cccb6de4d56d88..5b65d48d91319810eb83b6be1a01f3f714ddb20a 100644 --- a/source/cmk_addons_plugins/meraki/agent_based/wireless_device_ssid_status.py +++ b/source/cmk_addons_plugins/meraki/agent_based/wireless_device_ssid_status.py @@ -14,6 +14,7 @@ # 2024-06-30: renamed from cisco_meraki_org_wireless_device_status.py int to wireless_device_ssid_status.py # 2024-07-13: fixed crash on missing metrics (device dormant) ThX to Leon Buhleier # 2024-08-07: fixed crash on missing power value (unit only) ThX to Leon Buhleier +# 2024-09-12: fixed missing SSID 0 ThX to Andreas Doehler from collections.abc import Mapping from dataclasses import dataclass @@ -71,7 +72,7 @@ def parse_wireless_device_status(string_table: StringTable) -> Mapping[str, SSID if row.get('ssidName') and row.get('ssidName', '').startswith('Unconfigured SSID'): continue # ignore unconfigured entry's - if not (ssid_number := row.get('ssidNumber')): + if (ssid_number := row.get('ssidNumber')) is None: continue item = str(ssid_number) + ' on band ' + row.get('band') diff --git a/source/cmk_addons_plugins/meraki/lib/agent.py b/source/cmk_addons_plugins/meraki/lib/agent.py index 860cc46d65c7acac1a41802e04d97410dd8efb0e..6f96d7430eb49e226c85ec7d28b9ed8c497fb2d0 100644 --- a/source/cmk_addons_plugins/meraki/lib/agent.py +++ b/source/cmk_addons_plugins/meraki/lib/agent.py @@ -37,6 +37,8 @@ # 2024-05-20: made appliance uplinks usage user selectable # made API requests per org user selectable # 2024-06-23: added cache time per section -> not nice but should work. +# 2024-09-12: added version check for min. Meraki SDK version +# 2024-09-15: fixed MerakiGetOrganizationSwitchPortsStatusesBySwitch -> return only list of switches # ToDo: create inventory from Networks, is per organisation, not sure where/how to put this in the inventory # ToDo: list Connected Datacenters like Umbrella https://developer.cisco.com/meraki/api-v1/list-data-centers/ @@ -124,6 +126,8 @@ from cmk_addons.plugins.meraki.lib.utils import ( _SEC_CACHE_WIRELESS_ETHERNET_STATUSES, ) +_MERAKI_SDK_MIN_VERSION: Final = '1.46.0' + _LOGGER = getLogger("agent_cisco_meraki") _API_NAME_API: Final = "api" @@ -644,11 +648,11 @@ class MerakiGetOrganizationSwitchPortsStatusesBySwitch(MerakiSectionOrg): params=params, timeout=3, ) - return response.json() + return response.json()['items'] # return self._config.dashboard.organizations.getOrganizationDevices(self._org_id, total_pages='all') except RequestException as e: _LOGGER.debug('Organisation ID: %r: Get Ports statuses by switch: %r', self._org_id, e) - return {} + return [] # @@ -1245,6 +1249,12 @@ def get_proxy(raw_proxy: str) -> str | None: def agent_cisco_meraki_main(args: Args) -> int: + if meraki.__version__ < _MERAKI_SDK_MIN_VERSION: + print( + f'This Agent needs at least Meraki SDK version {_MERAKI_SDK_MIN_VERSION}, installed is {meraki.__version__}' + ) + exit(1) + # don't remove used for runtime logging at the end start_time = time_ns() config = MerakiConfig( diff --git a/source/cmk_plugins/cisco/rulesets/meraki.py b/source/cmk_plugins/cisco/rulesets/meraki.py index 95fc8b3f2d3961322e5c7e9aec2112b3f0df01d4..244c40b32df6eadfbab475b43d566906866fa15f 100644 --- a/source/cmk_plugins/cisco/rulesets/meraki.py +++ b/source/cmk_plugins/cisco/rulesets/meraki.py @@ -162,47 +162,46 @@ def _form_special_agent_cisco_meraki() -> Dictionary: 'sort the host in organisation specific folders.' ) )), - - "excluded_sections": DictElement( - parameter_form=MultipleChoice( - title=Title("Exclude Sections"), - elements=[ - MultipleChoiceElement(name=_SEC_NAME_ORG_API_REQUESTS, - title=Title(_SEC_TITLE_ORG_API_REQUESTS)), - MultipleChoiceElement(name=_SEC_NAME_APPLIANCE_UPLINKS, - title=Title(_SEC_TITLE_APPLIANCE_UPLINKS)), - MultipleChoiceElement(name=_SEC_NAME_APPLIANCE_UPLINKS_USAGE, - title=Title(_SEC_TITLE_APPLIANCE_UPLINKS_USAGE)), - MultipleChoiceElement(name=_SEC_NAME_APPLIANCE_VPNS, title=Title(_SEC_TITLE_APPLIANCE_VPNS)), - MultipleChoiceElement(name=_SEC_NAME_APPLIANCE_PERFORMANCE, - title=Title(_SEC_TITLE_APPLIANCE_PERFORMANCE)), - MultipleChoiceElement(name=_SEC_NAME_CELLULAR_UPLINKS, - title=Title(_SEC_TITLE_CELLULAR_UPLINKS)), - MultipleChoiceElement(name=_SEC_NAME_DEVICE_STATUSES, title=Title(_SEC_TITLE_DEVICE_STATUSES)), - MultipleChoiceElement(name=_SEC_NAME_DEVICE_UPLINKS_INFO, - title=Title(_SEC_TITLE_DEVICE_UPLINKS_INFO)), - MultipleChoiceElement(name=_SEC_NAME_LICENSES_OVERVIEW, - title=Title(_SEC_TITLE_LICENSES_OVERVIEW)), - MultipleChoiceElement(name=_SEC_NAME_SENSOR_READINGS, title=Title(_SEC_TITLE_SENSOR_READINGS)), - MultipleChoiceElement(name=_SEC_NAME_SWITCH_PORTS_STATUSES, - title=Title(_SEC_TITLE_SWITCH_PORTS_STATUSES)), - MultipleChoiceElement(name=_SEC_NAME_WIRELESS_ETHERNET_STATUSES, - title=Title(_SEC_TITLE_WIRELESS_ETHERNET_STATUSES)), - MultipleChoiceElement(name=_SEC_NAME_WIRELESS_DEVICE_STATUS, - title=Title(_SEC_TITLE_WIRELESS_DEVICE_STATUS)), - MultipleChoiceElement(name=_SEC_NAME_ORG_SWITCH_PORTS_STATUSES, - title=Title(_SEC_TITLE_ORG_SWITCH_PORTS_STATUSES)), - ], - prefill=DefaultValue([ - _SEC_NAME_APPLIANCE_PERFORMANCE, - _SEC_NAME_SWITCH_PORTS_STATUSES, - _SEC_NAME_WIRELESS_DEVICE_STATUS, - _SEC_NAME_ORG_SWITCH_PORTS_STATUSES, - ]), - # migrate=_migrate_to_valid_ident, + "excluded_sections": DictElement( + parameter_form=MultipleChoice( + title=Title("Exclude Sections"), + elements=[ + MultipleChoiceElement(name=_SEC_NAME_ORG_API_REQUESTS, + title=Title(_SEC_TITLE_ORG_API_REQUESTS)), + MultipleChoiceElement(name=_SEC_NAME_APPLIANCE_UPLINKS, + title=Title(_SEC_TITLE_APPLIANCE_UPLINKS)), + MultipleChoiceElement(name=_SEC_NAME_APPLIANCE_UPLINKS_USAGE, + title=Title(_SEC_TITLE_APPLIANCE_UPLINKS_USAGE)), + MultipleChoiceElement(name=_SEC_NAME_APPLIANCE_VPNS, title=Title(_SEC_TITLE_APPLIANCE_VPNS)), + MultipleChoiceElement(name=_SEC_NAME_APPLIANCE_PERFORMANCE, + title=Title(_SEC_TITLE_APPLIANCE_PERFORMANCE)), + MultipleChoiceElement(name=_SEC_NAME_CELLULAR_UPLINKS, + title=Title(_SEC_TITLE_CELLULAR_UPLINKS)), + MultipleChoiceElement(name=_SEC_NAME_DEVICE_STATUSES, title=Title(_SEC_TITLE_DEVICE_STATUSES)), + MultipleChoiceElement(name=_SEC_NAME_DEVICE_UPLINKS_INFO, + title=Title(_SEC_TITLE_DEVICE_UPLINKS_INFO)), + MultipleChoiceElement(name=_SEC_NAME_LICENSES_OVERVIEW, + title=Title(_SEC_TITLE_LICENSES_OVERVIEW)), + MultipleChoiceElement(name=_SEC_NAME_SENSOR_READINGS, title=Title(_SEC_TITLE_SENSOR_READINGS)), + MultipleChoiceElement(name=_SEC_NAME_SWITCH_PORTS_STATUSES, + title=Title(_SEC_TITLE_SWITCH_PORTS_STATUSES)), + MultipleChoiceElement(name=_SEC_NAME_WIRELESS_ETHERNET_STATUSES, + title=Title(_SEC_TITLE_WIRELESS_ETHERNET_STATUSES)), + MultipleChoiceElement(name=_SEC_NAME_WIRELESS_DEVICE_STATUS, + title=Title(_SEC_TITLE_WIRELESS_DEVICE_STATUS)), + MultipleChoiceElement(name=_SEC_NAME_ORG_SWITCH_PORTS_STATUSES, + title=Title(_SEC_TITLE_ORG_SWITCH_PORTS_STATUSES)), + ], + prefill=DefaultValue([ + _SEC_NAME_APPLIANCE_PERFORMANCE, + _SEC_NAME_SWITCH_PORTS_STATUSES, + _SEC_NAME_WIRELESS_DEVICE_STATUS, + _SEC_NAME_ORG_SWITCH_PORTS_STATUSES, + ]), + # migrate=_migrate_to_valid_ident, + ), + required=True, ), - required=True, - ), "orgs": DictElement( parameter_form=List( element_template=String(macro_support=True), title=Title("Organizations"), @@ -261,6 +260,7 @@ def _form_special_agent_cisco_meraki() -> Dictionary: render_only=True, ), }, + # prefill=DefaultValue('excluded_sections'), ) diff --git a/source/cmk_plugins/collection/server_side_calls/cisco_meraki.py b/source/cmk_plugins/collection/server_side_calls/cisco_meraki.py index 4f772f38eb0cbe25f75362eb1e7ab1e80654766c..9e91fac5dad3ba592db35063990511c5d5b2a940 100644 --- a/source/cmk_plugins/collection/server_side_calls/cisco_meraki.py +++ b/source/cmk_plugins/collection/server_side_calls/cisco_meraki.py @@ -115,11 +115,11 @@ def agent_cisco_meraki_arguments( args.append("--sections") args += [s.replace("_", "-") for s in params.sections] - if params.excluded_sections is not None: + if params.excluded_sections: args.append("--excluded-sections") args += [s.replace("_", "-") for s in params.excluded_sections] - if params.orgs is not None: + if params.orgs: args.append("--orgs") args += [replace_macros(org, host_config.macros) for org in params.orgs] diff --git a/source/packages/cisco_meraki b/source/packages/cisco_meraki index 7e179357dd4a88c1147ed1af223f83697b1708f0..08abc811514722ef5a99424d2d9b47ef449eb38b 100644 --- a/source/packages/cisco_meraki +++ b/source/packages/cisco_meraki @@ -63,7 +63,7 @@ 'web': ['plugins/views/cisco_meraki.py']}, 'name': 'cisco_meraki', 'title': 'Cisco Meraki special agent', - 'version': '1.3.5-20240807', + 'version': '1.3.6-20240915', 'version.min_required': '2.3.0b1', 'version.packaged': 'cmk-mkp-tool 0.2.0', 'version.usable_until': '2.4.0b1'}