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 13a4c9e2 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent aa743bd5
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/inv_lldp_cache-0.9.4-20240405.mkp "inv_lldp_cache-0.9.4-20240405.mkp"
[PACKAGE]: ../../raw/master/mkp/inv_lldp_cache-0.9.5-20240407.mkp "inv_lldp_cache-0.9.5-20240407.mkp"
# LLDP inventory plugin
Adds the LLDP information from network devices to the inventory
......
File added
......@@ -31,7 +31,8 @@
# 2024-03-20: added host label nvdct/has_lldp_neighbours:yes if the device has at least one lldp neighbour
# 2024-04-05: drop neighbours without chassis id
# drop invalid MAC addresses (length != 6)
#
# 2024-04-07: fixed missing/empty lldp_global in snmp data (ThX bitwiz@froum.checkmk.com)
# improved validation if SNMP input data
from dataclasses import dataclass
from ipaddress import ip_address
......@@ -137,7 +138,7 @@ class LldpNeighbour:
@dataclass(frozen=True)
class Lldp:
lldp_global: LldpGlobal
lldp_global: LldpGlobal | None
lldp_neighbours: List[LldpNeighbour]
......@@ -206,28 +207,44 @@ def _render_chassis_id(chassis_id_sub_type: str, chassis_id: str) -> str:
return ''.join(chr(m) for m in chassis_id)
def parse_inv_lldp_cache(string_table: List[StringByteTable]) -> Lldp:
lldp_info, if_info, lldp_global, lldp_mgmt_addresses = string_table
mgmt_addresses = [oid_end for oid_end, lldp_rem_man_addr_if_subtype in lldp_mgmt_addresses]
def parse_inv_lldp_cache(string_table: List[StringByteTable]) -> Lldp | None:
try:
lldp_info, if_info, lldp_global, lldp_mgmt_addresses = string_table
except ValueError:
return
global_chassis_id_type, global_chassis_id, global_system_name = lldp_global[0]
try:
mgmt_addresses = [oid_end for oid_end, lldp_rem_man_addr_if_subtype in lldp_mgmt_addresses]
except ValueError:
return
global_info = LldpGlobal(
local_id=_render_chassis_id(global_chassis_id_type, global_chassis_id),
local_name=global_system_name,
)
try:
global_chassis_id_type, global_chassis_id, global_system_name = lldp_global[0]
except (ValueError, IndexError):
global_info = None
else:
global_info = LldpGlobal(
local_id=_render_chassis_id(global_chassis_id_type, global_chassis_id),
local_name=global_system_name,
)
interfaces = {
if_index: {'if_sub_type': if_sub_type, 'if_name': if_name}
for if_index, if_sub_type, if_name in if_info
}
try:
interfaces = {
if_index: {'if_sub_type': if_sub_type, 'if_name': if_name}
for if_index, if_sub_type, if_name in if_info
}
except ValueError:
return
neighbours = []
for oid_end, chassis_id_sub_type, chassis_id, port_id_sub_type, port_id, port_description, \
neighbour_name, system_description, capabilities_map_supported, cache_capabilities in lldp_info:
for entry in lldp_info:
try:
oid_end, chassis_id_sub_type, chassis_id, port_id_sub_type, port_id, port_description, \
neighbour_name, system_description, capabilities_map_supported, cache_capabilities = entry
except ValueError:
continue
# skip neighbours chassis id
# skip neighbours without chassis id
if not chassis_id:
continue
......@@ -296,13 +313,14 @@ def host_label_inv_lldp_cache(section: Lldp) -> HostLabelGenerator:
def inventory_lldp_cache(params, section: Lldp) -> InventoryResult:
path = ['networking', 'lldp_cache']
yield Attributes(
path=path,
inventory_attributes={
**({"local_id": section.lldp_global.local_id} if section.lldp_global.local_id else {}),
**({"local_name": section.lldp_global.local_name} if section.lldp_global.local_name else {}),
}
)
if section.lldp_global:
yield Attributes(
path=path,
inventory_attributes={
**({"local_id": section.lldp_global.local_id} if section.lldp_global.local_id else {}),
**({"local_name": section.lldp_global.local_name} if section.lldp_global.local_name else {}),
}
)
path = path + ['neighbours']
......
......@@ -17,7 +17,7 @@
'web': ['plugins/views/inv_lldp_cache.py']},
'name': 'inv_lldp_cache',
'title': 'inventory for LLDP cache',
'version': '0.9.4-20240405',
'version': '0.9.5-20240407',
'version.min_required': '2.2.0b1',
'version.packaged': '2.2.0p24',
'version.usable_until': None}
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