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

update project

parent 8c2ff04c
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/nvdct-0.8.10-20240614.mkp "nvdct-0.8.10-20240614.mkp"
[PACKAGE]: ../../raw/master/mkp/nvdct-0.8.12-20240618.mkp "nvdct-0.8.12-20240618.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 by Andreas Boesl and [schnetz](https://exchange.checkmk.com/u/schnetz).\
......
File added
......@@ -8,6 +8,8 @@
# Date : 2023-10-12
# File : nvdct/lib/backends.py
# 2024-06-18: fixed host_exist returns always True if host was in host_cache, even with host=None
from _collections_abc import Mapping, Sequence
from abc import abstractmethod
from ast import literal_eval
......@@ -279,7 +281,7 @@ class HostCacheLiveStatus(HostCache):
'OutputFormat: python3\n'
f'Filter: host_name = {host}\n'
)
if host in self.cache:
if self.cache.get(host) is not None:
return True
# if self.pre_fetch:
# LOGGER.warning(f'{self.backend} pre_fetch host not found in cache {host}')
......@@ -287,6 +289,7 @@ class HostCacheLiveStatus(HostCache):
data: Sequence[Sequence[str]] = self.get_raw_data(query=query)
LOGGER.debug(f'{self.backend} data for host {host}: {data}')
if [host] in data:
LOGGER.debug(f'{self.backend} Host {host} found in CMK')
return True
LOGGER.warning(f'{self.backend} Host {host} not found in CMK')
......@@ -347,6 +350,8 @@ class HostCacheMultiSite(HostCacheLiveStatus):
self.pre_fetch_hosts()
def get_sites(self):
# see: https://github.com/Checkmk/checkmk/blob/master/packages/cmk-livestatus-client/example_multisite.py
sites_mk = Path(f'{OMD_ROOT}/etc/check_mk/multisite.d/sites.mk')
socket_path = f'unix:{OMD_ROOT}/tmp/run/live'
if sites_mk.exists():
......@@ -505,7 +510,7 @@ class HostCacheRestApi(HostCache):
def host_exists(self, host: str) -> bool:
LOGGER.debug(f'{self.backend} host_exists {host}')
if host in self.cache:
if self.cache.get(host) is not None:
LOGGER.debug(f'{self.backend} host found in cache {host}')
return True
# if self.pre_fetch:
......@@ -657,7 +662,7 @@ class HostCacheFileSystem(HostCache):
def host_exists(self, host: str) -> bool:
# always True, don't works in distributed environments as autocheck files
# are only locally available
return True
return False
def get_hosts_by_label(self, label: str) -> List[str] | None:
# not implemented, no (good) way to get a list of hosts from file system
......
......@@ -8,6 +8,8 @@
# Date : 2023-10-12
# File : nvdct/lib/settings.py
# fixed path to default user data file
from _collections_abc import Mapping
from ipaddress import AddressValueError, IPv4Address, IPv4Network, NetmaskValueError
from logging import CRITICAL, FATAL, ERROR, WARNING, INFO, DEBUG
......@@ -96,7 +98,7 @@ class Settings:
'skip_l3_ip': False,
'time_format': TIME_FORMAT,
'uppercase': False,
'user_data_file': f'{self.omd_root}/local/bin/nvdct/{USER_DATA_FILE}',
'user_data_file': f'{self.omd_root}/local/bin/nvdct/conf/{USER_DATA_FILE}',
'version': False,
}
# args in the form {'s, __seed_devices': 'CORE01', 'p, __path_in_inventory': None, ... }}
......
......@@ -30,7 +30,9 @@ class NvObjects:
if host not in self.nv_objects:
link: Dict = {}
metadata: Dict = {}
if host_cache.host_exists(host=host):
# LOGGER.debug(f'host: {host}, {host_cache.host_exists(host=host)}')
if host_cache.host_exists(host=host) is True:
LOGGER.debug(f'host: {host} exists')
link = {'core': host}
else:
if emblem is not None:
......@@ -49,6 +51,7 @@ class NvObjects:
'link': link,
'metadata': metadata,
}
LOGGER.debug(f'host: {host}, link: {link}, metadata: {metadata}')
def add_service_object(
self,
......
......@@ -23,7 +23,7 @@ from time import time as now_time
from tomllib import loads as toml_loads, TOMLDecodeError
from typing import List, Dict, TextIO
NVDCT_VERSION = '0.8.11-20240617'
NVDCT_VERSION = '0.8.12-20240618'
@unique
......
......@@ -58,7 +58,7 @@
'htdocs/images/icons/location_80.png']},
'name': 'nvdct',
'title': 'Network Visualization Data Creation Tool (NVDCT)',
'version': '0.8.10-20240614',
'version': '0.8.12-20240618',
'version.min_required': '2.2.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