diff --git a/README.md b/README.md index c4e6e4594acd15b3358c9345d258a145610eac3e..b77a321ec365fea5a35e8f910db8253801f668dc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[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.\ diff --git a/mkp/nvdct-0.9.5-20241217.mkp b/mkp/nvdct-0.9.5-20241217.mkp new file mode 100644 index 0000000000000000000000000000000000000000..1807b82550b435b7632bd43fa92420cbae300bc5 Binary files /dev/null and b/mkp/nvdct-0.9.5-20241217.mkp differ diff --git a/source/bin/nvdct/lib/constants.py b/source/bin/nvdct/lib/constants.py index 076f6490754ace384898101ddf1a4f9272f10363..4bf5240ab6154dcef3d0839ad7e9cdc9637dac76 100755 --- a/source/bin/nvdct/lib/constants.py +++ b/source/bin/nvdct/lib/constants.py @@ -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"] # diff --git a/source/bin/nvdct/lib/settings.py b/source/bin/nvdct/lib/settings.py index d40af5356ec8670702c24417f0aed896f32dcf6c..0e5097be13270fdfb42b85355790aa0af3e7abd8 100755 --- a/source/bin/nvdct/lib/settings.py +++ b/source/bin/nvdct/lib/settings.py @@ -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 diff --git a/source/bin/nvdct/lib/topologies.py b/source/bin/nvdct/lib/topologies.py index 026b6fc46b0348f35404e812aac9b83a018887a2..32710db0219f2adfb5b5400fce911a47b0966c2e 100755 --- a/source/bin/nvdct/lib/topologies.py +++ b/source/bin/nvdct/lib/topologies.py @@ -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 diff --git a/source/bin/nvdct/nvdct.py b/source/bin/nvdct/nvdct.py index 80755bf9c7a35ba4a238f440198b4eb3d829572f..8966b104060df4a5b6e7cbc0ba359fd788eb8fd3 100755 --- a/source/bin/nvdct/nvdct.py +++ b/source/bin/nvdct/nvdct.py @@ -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 # diff --git a/source/packages/nvdct b/source/packages/nvdct index d2a4e8fa6c18365c06bec03ee77a0007c1e043aa..a41f73e6981757ab73a9344482db1285e9afbae0 100644 --- a/source/packages/nvdct +++ b/source/packages/nvdct @@ -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'}