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

update project

parent 8ad33e12
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@
# 2020-07-31 : added short interface name, code cleanup
# 2021-03-17 : rewrite for CMK 2.0
import time, re
import re
from typing import List
from .agent_based_api.v1.type_defs import (
......@@ -85,21 +85,18 @@ def parse_inv_lldp_cache(string_table: List[StringTable]) -> list:
def render_ip_address(bytestring):
return '.'.join(['%s' % ord(m) for m in bytestring])
def render_time(uptime_sec):
uptime_sec = int(uptime_sec)
since = time.strftime('%c', time.localtime(time.time() - (uptime_sec / 100)))
return since
def render_capabilities(bytestring):
if len(bytestring) == 0:
return []
cpapabilites = []
bytestring = int(ord(bytestring[0]))
for x in lldp_capabilities:
tempcap = lldp_capabilities.get(int(ord(bytestring[0])) & x)
tempcap = lldp_capabilities.get(bytestring & x)
if tempcap != '':
cpapabilites.append(tempcap)
cpapabilites = str(', '.join(cpapabilites))
# print (bytestring , '/' , cpapabilites)
return cpapabilites
def get_short_if_name(st):
......@@ -120,6 +117,8 @@ def parse_inv_lldp_cache(string_table: List[StringTable]) -> list:
lldp_info, if_info = string_table
# print(len(lldp_info))
neighbors = []
for oid_end, lldpchassisidsubtype, lldpchassisid, lldpportidsubtype, lldpportid, lldpportdescription, \
......@@ -131,7 +130,7 @@ def parse_inv_lldp_cache(string_table: List[StringTable]) -> list:
if local_ifindex == ifIndex:
local_port = get_short_if_name(ifName)
if lldp_chassisidsubtype == '3': # mac address
if lldpchassisidsubtype == '4': # mac address
lldpchassisid = render_mac_address(lldpchassisid)
if lldpportidsubtype == '3': # macaddress
......@@ -147,9 +146,9 @@ def parse_inv_lldp_cache(string_table: List[StringTable]) -> list:
lldpportid = render_mac_address(lldpportid)
neighbor = {
'local_port_num': get_short_if_name(local_port),
'local_port_num': local_port,
'chassis_id': lldpchassisid,
'port_id': lldpportid,
'port_id': get_short_if_name(lldpportid),
'port_description': lldpportdescription,
'system_name': lldpsystemname,
'system_description': lldpsystemdescription,
......@@ -178,18 +177,21 @@ def inventory_lldp_cache(params, section: list) -> InventoryResult:
domain_name = params.get('domain_name', domain_name)
path= ['networking', 'lldp_cache']
for neighbor in section:
# print(neighbor)
if remove_domain:
if not domain_name == '':
neighbor['lldpsystemname'] = neighbor['lldpsystemname'].replace(domain_name, '')
neighbor['lldpchassisid'] = neighbor['lldpchassisid'].replace(domain_name, '')
neighbor['system_name'] = neighbor['system_name'].replace(domain_name, '')
neighbor['chassis_id'] = neighbor['chassis_id'].replace(domain_name, '')
else:
neighbor['lldpsystemname'] = neighbor['lldpsystemname'].split('.')[0]
neighbor['lldpchassisid'] = neighbor['lldpchassisid'].split('.')[0]
key_columns = {'local_port_num': neighbor['local_port_num']}
neighbor['system_name'] = neighbor['system_name'].split('.')[0]
neighbor['chassis_id'] = neighbor['chassis_id'].split('.')[0]
key_columns = {
# 'system_name': neighbor['system_name'],
'chassis_id': neighbor['chassis_id'],
'port_id': neighbor['port_id'],
'local_port_num': neighbor['local_port_num'],
}
for key in key_columns.keys():
neighbor.pop(key)
......
No preview for this file type
......@@ -29,6 +29,7 @@ def _valuespec_inv_lldp_cache():
('capabilities_map_supported', 'Capabilities map supported'),
('cache_capabilities', 'Cache Capabilities'),
]
return Dictionary(
title=_('LLDP cache'),
elements=[
......
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