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

fixed wrong import for OMD_ROOT (copy&paste) (ThX to BH2005@forum.checkmk.com)

parent 06c033c9
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/nvdct-0.9.4-20241210.mkp "nvdct-0.9.4-20241210.mkp"
[PACKAGE]: ../../raw/master/mkp/nvdct-0.9.5-20241217.mkp "nvdct-0.9.5-20241217.mkp"
# Network Visualization Data Creation Tool (NVDCT)
This script creates the topology data file needed for the [Checkmk Exchange Network visualization](https://exchange.checkmk.com/p/network-visualization) plugin.\
......
File added
......@@ -8,11 +8,11 @@
# File : nvdct/lib/constants.py
from logging import getLogger
from logging import getLogger
from os import environ
from typing import Final
NVDCT_VERSION: Final[str] = '0.9.4-20241210'
NVDCT_VERSION: Final[str] = '0.9.5-20241217'
#
OMD_ROOT: Final[str] = environ["OMD_ROOT"]
#
......
......@@ -2,13 +2,13 @@
# -*- coding: utf-8 -*-
#
# License: GNU General Public License v2
from cmk_addons.plugins.bgp_topology.lib.utils import OMD_ROOT
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2023-10-12
# File : nvdct/lib/settings.py
# fixed path to default user data file
# fixed wrong import in line 5 (copy&paste) (ThX to BH2005@forum.checkmk.com)
from collections.abc import Mapping
from ipaddress import AddressValueError, IPv4Address, IPv4Network, NetmaskValueError
......
......@@ -50,9 +50,6 @@ class NvObjects:
host_cache: HostCache,
emblem: str | None = None
) -> None:
if not is_valid_hostname(host):
LOGGER.error(f'host not added! Invalid name {host}')
return
if host not in self.nv_objects:
self.host_count += 1
self.host_list.append(host)
......@@ -261,6 +258,7 @@ class NvConnections:
}
}
}
left_speed = nv_objects.nv_objects[left].get('metadata', {}).get('op_speed_int')
right_speed = nv_objects.nv_objects[right].get('metadata', {}).get('op_speed_int')
......@@ -273,6 +271,7 @@ class NvConnections:
left_native_vlan = nv_objects.nv_objects[left].get('metadata', {}).get('native_vlan')
right_native_vlan = nv_objects.nv_objects[right].get('metadata', {}).get('native_vlan')
if right_speed and left_speed:
right_thickness = map_speed_to_thickness(right_speed, speed_map)
# left_thickness = map_speed_to_thickness(left_speed, speed_map)
......@@ -347,8 +346,11 @@ def get_operational_interface_data(
unit_to_bits_per_second = {
'Bit/s': 1,
'kBit/s': 1000,
'Kbps': 1000,
'MBit/s': 1000000,
'Mbps': 1000000,
'GBit/s': 1000000000,
'Gbps': 1000000000,
}
# get dict of interfaces with the item as key
......@@ -496,7 +498,7 @@ def get_service_by_interface(host: str, interface: str, host_cache: HostCache) -
elif f'1:{interface}' == _entry.get('name'): # Extreme non stack:
return _match_entry_with_item(_entry, interface_items)
elif _entry.get('name') is not None and _get_short_if_name(
_entry.get('name')) == interface.lower(): # Cisco NXOS
_entry.get('name')) == str(interface).lower(): # Cisco NXOS
return _match_entry_with_item(_entry, interface_items)
LOGGER.warning(msg=f'Device: {host}: service for interface |{interface}| not found')
......@@ -778,26 +780,26 @@ def create_l2_device_from_inv(
nv_objects.add_host(host=host, host_cache=host_cache)
nv_objects.add_host(host=neighbour, host_cache=host_cache)
nv_objects.add_interface(
host=host,
service=local_port,
host=str(host),
service=str(local_port),
host_cache=host_cache,
metadata=metadata,
name=raw_local_port,
item=local_port
name=str(raw_local_port),
item=str(local_port)
)
nv_objects.add_interface(
host=neighbour,
service=neighbour_port,
host=str(neighbour),
service=str(neighbour_port),
host_cache=host_cache,
name=raw_neighbour_port,
item=neighbour_port
name=str(raw_neighbour_port),
item=str(neighbour_port)
)
nv_connections.add_connection(
left=host,
left=str(host),
right=f'{local_port}@{host}',
)
nv_connections.add_connection(
left=neighbour,
left=str(neighbour),
right=f'{neighbour_port}@{neighbour}',
)
nv_connections.add_connection(
......@@ -926,7 +928,7 @@ def create_l3v4_topology(
if ipv4_info.type.lower() != 'ipv4': # drop if not ipv4
LOGGER.warning(
f'host: {host} dropped non ipv4 address: {ipv4_info.address},'
' type: {ipv4_info.type}'
f' type: {ipv4_info.type}'
)
continue
......
......@@ -141,6 +141,11 @@
# incompatible: reworked static topology -> can now be used for each service, host/service name has to be
# exactly like in CMK. See ~/local/bin/nvdct/conf/nfdct.toml
# moved string constants to lib/constants.py
#
# minimum ip address inventory plugin versions
# - inv_lnx_if_ip-0.0.4-20241210.mkp
# - inv_ip_address-0.0.6-20241210.mkp
# - inv_win_if_ip-0.0.3-20241210.mkp
# creating topology data json from inventory data
#
......
......@@ -47,7 +47,7 @@
'htdocs/images/icons/location_80.png']},
'name': 'nvdct',
'title': 'Network Visualization Data Creation Tool (NVDCT)',
'version': '0.9.4-20241210',
'version': '0.9.5-20241217',
'version.min_required': '2.3.0b1',
'version.packaged': 'cmk-mkp-tool 0.2.0',
'version.usable_until': '2.4.0p1'}
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