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

modified for check APIv2, ruleset APIv1, graphing APIv1

parent b36646a4
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/inv_lldp_cache-0.10.3-20241217.mkp "inv_lldp_cache-0.10.3-20241217.mkp"
[PACKAGE]: ../../raw/master/mkp/inv_lldp_cache-0.10.4-20250323.mkp "inv_lldp_cache-0.10.4-20250323.mkp"
# LLDP inventory plugin
Adds the LLDP information from network devices to the inventory
......
File added
......@@ -54,25 +54,20 @@ from re import compile as re_compile
from typing import List, Self
from cmk.utils import debug
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
from cmk.agent_based.v2 import (
Attributes,
HostLabel,
HostLabelGenerator,
InventoryPlugin,
InventoryResult,
StringByteTable,
)
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
OIDBytes,
OIDEnd,
)
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
Attributes,
HostLabel,
SNMPSection,
SNMPTree,
StringByteTable,
TableRow,
all_of,
exists,
register,
all_of,
)
_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%m'
......@@ -297,7 +292,7 @@ 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
return None
try:
interfaces = {
......@@ -305,12 +300,12 @@ def parse_inv_lldp_cache(string_table: List[StringByteTable]) -> Lldp | None:
for if_index, if_sub_type, if_name in if_info
}
except ValueError:
return
return None
try:
mgmt_addresses = [oid_end for oid_end, lldp_rem_man_addr_if_subtype in lldp_mgmt_addresses]
except ValueError:
return
return None
neighbours = []
for entry in lldp_info:
......@@ -501,7 +496,7 @@ lldp_rem_man_addr_entry = SNMPTree(
]
)
register.snmp_section(
snmp_section_inv_lldp_cache = SNMPSection(
name='inv_lldp_cache',
# parsed_section_name='inv_lldp_cache',
host_label_function=host_label_inv_lldp_cache,
......@@ -515,7 +510,7 @@ register.snmp_section(
detect=exists('.1.0.8802.1.1.2.1.4.1.1.4.*'), #
)
register.inventory_plugin(
inventory_plugin_inv_lldp_cache = InventoryPlugin(
name='inv_lldp_cache',
inventory_function=inventory_lldp_cache,
inventory_default_parameters={},
......@@ -534,7 +529,7 @@ def parse_inv_lldp_cache_fortinet(string_table: List[StringByteTable]) -> Lldp |
try:
lldp_info, if_info, lldp_global, lldp_mgmt_addresses, if_name, trunk_member = string_table
except ValueError:
return
return None
map_if_name2idx = {name: idx for idx, name in if_name}
map_if_idx2name = {idx: name for idx, name in if_name}
......@@ -560,7 +555,7 @@ def parse_inv_lldp_cache_fortinet(string_table: List[StringByteTable]) -> Lldp |
for if_index, if_sub_type, if_name in if_info
}
except ValueError:
return
return None
for entry in lldp_info:
try:
......@@ -599,7 +594,7 @@ fortinet_trunk_member = SNMPTree(
]
)
register.snmp_section(
snmp_section_inv_lldp_cache_fortinet = SNMPSection(
name='inv_lldp_cache_fortinet',
parsed_section_name='inv_lldp_cache',
supersedes=['inv_lldp_cache'],
......
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#
# License: GNU General Public License v2
#
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2016-04-16
# 2023-06-14: moved wato file to check_parameters subdirectory
# 2025-03-23: moved to rulesets API v1
from cmk.rulesets.v1 import Label, Title
from cmk.rulesets.v1.form_specs import (
DictElement,
Dictionary,
FixedValue,
MultipleChoice,
MultipleChoiceElement,
String,
)
from cmk.rulesets.v1.form_specs.validators import LengthInRange, Message
from cmk.rulesets.v1.rule_specs import InventoryParameters, Topic
def _parameter_form_inv_lldp_cache():
remove_columns = [
MultipleChoiceElement(name='port_description', title=Title('Neighbour port description')),
MultipleChoiceElement(name='system_description', title=Title('Neighbour description')),
MultipleChoiceElement(name='capabilities_map_supported', title=Title('Capabilities map supported')),
MultipleChoiceElement(name='capabilities', title=Title('Capabilities')),
]
return Dictionary(
elements={
'remove_domain': DictElement(
parameter_form=FixedValue(
value=True,
title=Title('Remove domain name from neighbour device name'),
label=Label('enabled'),
)),
'domain_name': DictElement(
parameter_form=String(
title=Title('Specific domain name to remove from neighbour device name'),
custom_validate=(LengthInRange(min_value=1, error_msg=Message('This filed ca not be empty')),),
)),
'removecolumns': DictElement(
parameter_form=MultipleChoice(
title=Title('Columns to remove'),
elements=remove_columns,
)),
'use_short_if_name': DictElement(
parameter_form=FixedValue(
value=True,
title=Title('use short interface names (i.e. Gi0/0 for GigabitEthernet0/0)'),
label=Label('enabled'),
)),
'one_neighbour_per_port': DictElement(
parameter_form=FixedValue(
value=True,
title=Title('Accept only one neighbour per local port'),
label=Label('enabled'),
)),
}
)
rule_spec_inv_lldp_cache = InventoryParameters(
name="inv_lldp_cache",
parameter_form=_parameter_form_inv_lldp_cache,
title=Title("LLDP cache"),
topic=Topic.NETWORKING,
)
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#
# License: GNU General Public License v2
#
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2016-04-16
# 2023-06-14: moved wato file to check_parameters subdirectory
from cmk.gui.i18n import _
from cmk.gui.plugins.wato.utils import (
HostRulespec,
rulespec_registry,
)
from cmk.gui.valuespec import (
Dictionary,
FixedValue,
TextAscii,
ListChoice,
)
from cmk.gui.plugins.wato.inventory import (
RulespecGroupInventory,
)
def _valuespec_inv_lldp_cache():
removecolumns = [
('port_description', 'Neighbour port description'),
('system_description', 'Neighbour description'),
('capabilities_map_supported', 'Capabilities map supported'),
('capabilities', 'Capabilities'),
]
return Dictionary(
title=_('LLDP cache'),
elements=[
('remove_domain',
FixedValue(
True,
title=_('Remove domain name from neighbour device name'),
totext=_(''),
default_value=False,
)),
('domain_name',
TextAscii(
title=_('Specific domain name to remove from neighbour device name'),
allow_empty=False,
default_value='',
)),
('removecolumns',
ListChoice(
title=_('List of columns to remove'),
help=_('information to remove from inventory'),
choices=removecolumns,
default_value=[],
)),
('use_short_if_name',
FixedValue(
True,
title=_('use short interface names (i.e. Gi0/0 for GigabitEthernet0/0)'),
totext=_(''),
default_value=False,
)),
('one_neighbour_per_port',
FixedValue(
True,
title=_('Accept only one neighbour per local port'),
totext=_(''),
default_value=False,
)),
],
)
rulespec_registry.register(
HostRulespec(
group=RulespecGroupInventory,
match_type="dict",
name="inv_parameters:inv_lldp_cache",
valuespec=_valuespec_inv_lldp_cache,
))
......@@ -13,12 +13,12 @@
' - 2023-06-14: changed for CMK 2.2\n'
' - 2024-07-25: added support for Fortinet\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['inv_lldp_cache.py'],
'gui': ['wato/check_parameters/inv_lldp_cache.py'],
'files': {'cmk_addons_plugins': ['inventory/agent_based/inv_lldp_cache.py',
'inventory/rulesets/inv_lldp_cache.py'],
'web': ['plugins/views/inv_lldp_cache.py']},
'name': 'inv_lldp_cache',
'title': 'inventory for LLDP cache',
'version': '0.10.3-20241217',
'version.min_required': '2.2.0b1',
'version': '0.10.4-20250323',
'version.min_required': '2.3.0b1',
'version.packaged': 'cmk-mkp-tool 0.2.0',
'version.usable_until': '2.4.0b1'}
'version.usable_until': '2.5.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