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

update project

parent 0dca2fd9
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/packagee-0.1.2-20230706.mkp "package-0.1.2-20230706.mkp"
[PACKAGE]: ../../raw/master/mkp/inv_lnx_if_ip-0.0.1-20240930.mkp "inv_lnx_if_ip-0.0.1-20240930.mkp"
# Title
A short description about the plugin
......
File added
# License: GNU General Public License v2
#
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2024-07-12
# File : plugins/agent_based/inv_lnx_if_ip.py
# based on ~/lib/check_mk/base/plugins/agent_based/lnx_if.py
from collections.abc import MutableMapping, MutableSequence, Sequence
from dataclasses import dataclass, field
from ipaddress import ip_address, ip_network
from cmk.base.plugins.agent_based.agent_based_api.v1 import register, TableRow
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import InventoryResult
from cmk.plugins.lib.interfaces import InterfaceWithCounters
@dataclass
class IPLinkInterface:
state_infos: Sequence[str] | None = None
link_ether: str = ""
inet: MutableSequence[str] = field(default_factory=list)
inet6: MutableSequence[str] = field(default_factory=list)
SectionInventory = MutableMapping[str, IPLinkInterface]
Section = tuple[Sequence[InterfaceWithCounters], SectionInventory]
def inventory_lnx_if_ip(section: SectionInventory) -> InventoryResult:
__ip_state = {
'lo': IPLinkInterface(
state_infos=['LOOPBACK', 'UP', 'LOWER_UP'],
link_ether='', inet=['127.0.0.1/8'],
inet6=['::1/128']
),
'ens32': IPLinkInterface(
state_infos=['BROADCAST', 'MULTICAST', 'UP', 'LOWER_UP'],
link_ether='\x00\x0c)\x82ýr',
inet=['192.168.10.144/24'],
inet6=['fe80::20c:29ff:fe82:fd72/64']
)
}
_interfaces_with_counters, ip_stats = section
for if_name, interface in ip_stats.items():
for networks, type_ in [
(interface.inet, "ipv4"),
(interface.inet6, "ipv6"),
]:
for network in networks:
address = str(ip_address(network.split('/')[0]).compressed)
network = ip_network(network, strict=False)
yield TableRow(
path=["networking", "addresses"],
key_columns={
"address": address,
"device": if_name,
},
inventory_columns={
"broadcast": str(network.broadcast_address),
"cidr": str(network.prefixlen),
"netmask": str(network.netmask),
"network": str(network.network_address),
"type": type_,
},
)
register.inventory_plugin(
name="inv_lnx_if_ip",
sections=["lnx_if"],
inventory_function=inventory_lnx_if_ip,
)
title: Dummy check man page - used as template for new check manuals
agents: linux, windows, aix, solaris, hpux, vms, freebsd, snmp
catalog: see modules/catalog.py for possible values
license: GPL
distribution: check_mk
description:
Describe here: (1) what the check actually does, (2) under which
circumstances it goes warning/critical, (3) which devices are supported
by the check, (4) if the check requires a separated plugin or
tool or separate configuration on the target host.
item:
Describe the syntax and meaning of the check's item here. Provide all
information one needs if coding a manual check with {checks +=} in {main.mk}.
Give an example. If the check uses {None} as sole item,
then leave out this section.
examples:
# Give examples for configuration in {main.mk} here. If the check has
# configuration variable, then give example for them here.
# set default levels to 40 and 60 percent:
foo_default_values = (40, 60)
# another configuration variable here:
inventory_foo_filter = [ "superfoo", "superfoo2" ]
perfdata:
Describe precisely the number and meaning of performance variables
the check sends. If it outputs no performance data, then leave out this
section.
inventory:
Describe how the inventory for the check works. Which items
will it find? Describe the influence of check specific
configuration parameters to the inventory.
[parameters]
foofirst(int): describe the first parameter here (if parameters are grouped
as tuple)
fooother(string): describe another parameter here.
[configuration]
foo_default_levels(int, int): Describe global configuration variable of
foo here. Important: also tell the user how they are preset.
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'This plugin will extend the IP-Address inventory for Linux '
'hosts by\n'
'- Broadcast address\n'
'- CIDR\n'
'- Netmask\n'
'- Network\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['inv_lnx_if_ip.py']},
'name': 'inv_lnx_if_ip',
'title': 'Extended inventory for IP-addresses on Linux hosts',
'version': '0.0.1-20240930',
'version.min_required': '2.3.0b1',
'version.packaged': 'cmk-mkp-tool 0.2.0',
'version.usable_until': '2.4.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