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

update project

parent e5c119cf
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/inv_cdp_cache-0.7.5-20240408.mkp "inv_cdp_cache-0.7.5-20240408.mkp"
[PACKAGE]: ../../raw/master/mkp/inv_cdp_cache-0.7.6-202404014.mkp "inv_cdp_cache-0.7.6-202404014.mkp"
# CDP inventory plugin
Adds the CDP information from network devices to the inventory
......
File added
......@@ -33,6 +33,8 @@
# 2024-04-08: stop (early) if interface table can not be created
# refactoring parse function
# moved neighbour address to non-key columns
# 2024-04-14: refactoring _get_address (match/case)
# refactoring _render_mac_address ( remove hex() )
# ToDo: add fallback if there is no if_name to if_description -> if_alias
......@@ -141,9 +143,9 @@ def _render_ip_address(bytestring) -> str | None:
if len(bytestring) == 14: # "0A 0D FC 15 " -> some Nexus
ip_address = bytestring.strip('"').strip(' ').split(' ')
if len(ip_address) == 4:
ip_address = '.'.join(['%s' % int(m, 16) for m in ip_address])
ip_address = '.'.join([f'{int(m, 16)}' for m in ip_address])
else:
ip_address = '.'.join(['%s' % ord(m) for m in bytestring])
ip_address = '.'.join([f'{ord(m)}' for m in bytestring])
try:
return IPv4Address(ip_address).exploded
except AddressValueError:
......@@ -152,7 +154,7 @@ def _render_ip_address(bytestring) -> str | None:
def _render_mac_address(bytestring) -> str | None:
if mac_address := _sanitize_mac(''.join([f'{hex(ord(m))[2:]:0>2}' for m in bytestring])):
if mac_address := _sanitize_mac(''.join([f'{ord(m):02x}' for m in bytestring])):
return mac_address
# try encode().hex()
if mac_address := _sanitize_mac(bytestring.encode().hex()):
......@@ -210,6 +212,7 @@ def _get_capabilities(raw_capabilities) -> str | None:
value for capability, value in cdp_capabilities.items() if cdp_capabilities.get(raw_capabilities & capability)
]
if capabilities:
capabilities.sort()
return ', '.join(capabilities)
......@@ -222,23 +225,20 @@ def _is_ascii(str_to_test: str) -> bool:
def _get_address(address_type: str, raw_address: str) -> str | None:
if address_type == '1': # ip address
if (address := _render_ip_address(raw_address)) is not None:
return address
if debug.enabled():
print(f'drop bad address-type 1: |{raw_address}|')
return
elif address_type == '65535': # HPE stack MAC address
if (address := _render_mac_address(raw_address)) is not None:
return address
if debug.enabled():
print(f'drop bad address-type 65535: |{raw_address}|, len: {len(raw_address)}')
return
else:
if debug.enabled():
print(f'unknown address-type: |{address_type}|')
return raw_address
match address_type:
case '1': # ip address
if (address := _render_ip_address(raw_address)) is not None:
return address
if debug.enabled():
print(f'drop bad address-type 1: |{raw_address}|')
case '65535': # unknown (HPE stack MAC address)
if (address := _render_mac_address(raw_address)) is not None:
return address
if debug.enabled():
print(f'drop bad address-type 65535: |{raw_address}|, len: {len(raw_address)}')
case _:
if debug.enabled():
print(f'unknown address-type: |{address_type}|')
def _get_device_id(raw_device_id: str) -> str | None:
......
......@@ -9,7 +9,7 @@
'web': ['plugins/views/inv_cdp_cache.py']},
'name': 'inv_cdp_cache',
'title': 'Inventory for Cisco CDP Cache',
'version': '0.7.5-20240408',
'version': '0.7.6-202404014',
'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