Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit 6035e6b4 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent e17f680c
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/cisco_meraki-1.1.0-2023-11-05.mkp "cisco_meraki-1.1.0-2023-11-05.mkp"
[PACKAGE]: ../../raw/master/mkp/cisco_meraki-1.2.0-2023-11-09.mkp "cisco_meraki-1.2.0-2023-11-09.mkp"
# Cisco Meraki special agent
This is an enhanched version of the build in Cisco Meraki special agent.
......
......@@ -10,8 +10,8 @@
from dataclasses import dataclass
from cmk.base.plugins.agent_based.agent_based_api.v1 import Attributes, register, TableRow
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import InventoryResult, StringTable
from cmk.base.plugins.agent_based.agent_based_api.v1 import Attributes, register, TableRow, HostLabel
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import InventoryResult, StringTable, HostLabelGenerator
from cmk.base.plugins.agent_based.utils.cisco_meraki import load_json, MerakiAPIData
......@@ -47,6 +47,14 @@ class DeviceInfo:
)
def host_label_meraki_device_info(section: DeviceInfo) -> HostLabelGenerator:
yield HostLabel('meraki/org_id', section.organisation_id)
yield HostLabel('meraki/org_name', section.organisation_name)
yield HostLabel('meraki/net_id', section.network_id)
yield HostLabel('meraki/net_name', section.network_name)
yield HostLabel('cmk/vendor', 'meraki')
def parse_device_info(string_table: StringTable) -> DeviceInfo | None:
return DeviceInfo.parse(loaded_json[0]) if (loaded_json := load_json(string_table)) else None
......@@ -54,6 +62,7 @@ def parse_device_info(string_table: StringTable) -> DeviceInfo | None:
register.agent_section(
name="cisco_meraki_org_device_info",
parse_function=parse_device_info,
host_label_function=host_label_meraki_device_info,
)
......
......@@ -12,6 +12,9 @@
# - removed device offline check from device status discovery function
# - added power supplys to inventory (hardware -> physical components -> power supplys
# - changed item from "Cisco Meraki Device" Status to "Device Status" -> we know this is a Meraki device ;-)
#
# 2023-11-09: fixed crash if no powersupply in components
#
from dataclasses import dataclass
from datetime import datetime
......@@ -57,7 +60,7 @@ class PowerSupply:
class DeviceStatus:
status: str
last_reported: datetime | None
power_supplys: Sequence[PowerSupply]
power_supplys: Sequence[PowerSupply] | None
unknown_components: Mapping | None
@classmethod
......@@ -65,7 +68,7 @@ class DeviceStatus:
return cls(
status=str(row["status"]),
last_reported=cls._parse_last_reported(str(row["lastReportedAt"])),
power_supplys=cls._parse_powesuplys(_components=row.get('components')),
power_supplys=cls._parse_powesuplys(_components=row['components']) if row.get('components') else None,
unknown_components=row.get('components') if row.get('components', {}) != {} else None,
)
......@@ -154,8 +157,9 @@ register.check_plugin(
def discover_device_status_ps(section: DeviceStatus | None) -> DiscoveryResult | None:
for power_supply in section.power_supplys:
yield Service(item=power_supply.slot)
if section.power_supplys:
for power_supply in section.power_supplys:
yield Service(item=power_supply.slot)
def check_device_status_ps(item: str, params: Mapping[str, any], section: DeviceStatus | None) -> CheckResult:
......
This diff is collapsed.
File added
......@@ -21,7 +21,7 @@
'lib': ['python3/cmk/special_agents/agent_cisco_meraki.py']},
'name': 'cisco_meraki',
'title': 'Cisco Meraki special agent',
'version': '1.1.0-2023-11-05',
'version': '1.2.0-2023-11-09',
'version.min_required': '2.2.0p11',
'version.packaged': '2.2.0p11',
'version.usable_until': '2.3.0b1'}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment