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

update project

parent eb2aa990
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/vsphere_topo-0.0.3-20240711.mkp "vsphere_topo-0.0.3-20240711.mkp"
[PACKAGE]: ../../raw/master/mkp/vsphere_topo-0.0.4-20240712.mkp "vsphere_topo-0.0.4-20240712.mkp"
# vSphere Topology Visualization
This plugin uses the data from the _VMware ESX via vSphere_ spezial agent to create a topolofy of the vSphere environment.
......
File added
......@@ -14,6 +14,7 @@
# -> obsoletes 'Add dummy topologies'
# added vCenter twice (once as vCenter once as vM) with different object IDs
# -> obsoletes 'Don\'t add vCenter as VM'
# 2024-07-12: added support for Queried host is a host system
from collections.abc import Mapping, Sequence
from pathlib import Path
......@@ -124,86 +125,86 @@ def check_vsphere_topo(
objects = {}
connections = []
raw_vsphere_host: str = host_name().strip()
add_host(
host=raw_vsphere_host,
obj_id_prefix='vc',
# icon='icon_topic_hosts',
icon=get_emblem(ICON_VCENTER, params.get(PARAM_VCENTER)),
)
vsphere_host = f'vc{raw_vsphere_host}'
__clusters = {
'HA': {
'datacenter': 'datacenter-21',
'hostsystems': 'esxi01, esxi02',
'vms': 'vmname01, vmname02, vmname03'
if section_esx_vsphere_clusters is not None:
__clusters = {
'HA': {
'datacenter': 'datacenter-21',
'hostsystems': 'esxi01, esxi02',
'vms': 'vmname01, vmname02, vmname03'
}
}
}
if section_esx_vsphere_clusters is None:
yield Result(
state=State.UNKNOWN,
summary='Found no vSphere data centers/clusters. This service needs the "VMware ESX via vSphere" '
'option "Type of query" set to "Queried host is vCenter"'
raw_vsphere_host: str = host_name().strip()
add_host(
host=raw_vsphere_host,
obj_id_prefix='vc',
icon=get_emblem(ICON_VCENTER, params.get(PARAM_VCENTER)),
)
return
for cluster in section_esx_vsphere_clusters:
data_center: str = section_esx_vsphere_clusters[cluster]['datacenter'].strip()
if objects.get(data_center) is None:
vsphere_host = f'vc{raw_vsphere_host}'
for cluster in section_esx_vsphere_clusters:
data_center: str = section_esx_vsphere_clusters[cluster]['datacenter'].strip()
if objects.get(data_center) is None:
add_host(
host=data_center,
emblem=get_emblem(EMBLEM_DATA_CENTER, params.get(PARAM_DATA_CENTER)),
link2core=False,
)
add_connection(data_center, vsphere_host)
add_host(
host=data_center,
emblem=get_emblem(EMBLEM_DATA_CENTER, params.get(PARAM_DATA_CENTER)),
link2core=False,
host=cluster,
emblem=get_emblem(EMBLEM_CLUSTER, params.get(PARAM_CLUSTER)),
link2core=False
)
add_connection(data_center, vsphere_host)
add_host(
host=cluster,
emblem=get_emblem(EMBLEM_CLUSTER, params.get(PARAM_CLUSTER)),
link2core=False
add_connection(cluster, data_center)
host_systems: Sequence[str] = section_esx_vsphere_clusters[cluster].get('hostsystems', '').split(',')
for host_system in host_systems:
esx_name: str = adjust_name(host_system, params.get(PARAM_HOST_SYSTEMS, {}))
add_host(host=esx_name)
add_connection(cluster, esx_name)
yield Result(
state=State.OK,
notice='VMware ESX via vSphere agent type of query: Queried host is the vCenter'
)
else: # assuming the query type is ESXi host
raw_vsphere_host: str = host_name().strip()
add_host(host=raw_vsphere_host)
vsphere_host = raw_vsphere_host
yield Result(
state=State.OK,
notice='VMware ESX via vSphere agent type of query: Queried host is a host system'
)
add_connection(cluster, data_center)
host_systems: Sequence[str] = section_esx_vsphere_clusters[cluster].get('hostsystems', '').split(',')
for host_system in host_systems:
esx_name: str = adjust_name(host_system, params.get(PARAM_HOST_SYSTEMS, {}))
add_host(host=esx_name)
add_connection(cluster, esx_name)
__VMs = [
{
'vm_name': 'vmname01',
'hostsystem': 'esxi01',
'powerstate': 'poweredOff',
'guest_os': 'Microsoft Windows Server 2008 R2 (64-bit)',
'compatibility': 'vmx-10',
'uuid': '420354bd-bee0-88d5-053c-d4f424106b0f'
},
{
'vm_name': 'vmname02',
'hostsystem': 'esxi02',
'powerstate': 'poweredOn',
'guest_os': 'Microsoft Windows Server 2019 (64-bit)',
'compatibility': 'vmx-19',
'uuid': '422eba9f-0327-2da0-b546-f5a5e5dfdb68'
},
{
'vm_name': 'vmname03',
'hostsystem': 'esxi01',
'powerstate': 'poweredOn',
'guest_os': 'Other 3.x or later Linux (64-bit)',
'compatibility': 'vmx-11',
'uuid': '422e3863-b7de-dc55-74f8-6dc9c159b36d'
}
]
if section_esx_vsphere_virtual_machines is not None:
__VMs = [
{
'vm_name': 'vmname01',
'hostsystem': 'esxi01',
'powerstate': 'poweredOff',
'guest_os': 'Microsoft Windows Server 2008 R2 (64-bit)',
'compatibility': 'vmx-10',
'uuid': '420354bd-bee0-88d5-053c-d4f424106b0f'
},
{
'vm_name': 'vmname02',
'hostsystem': 'esxi02',
'powerstate': 'poweredOn',
'guest_os': 'Microsoft Windows Server 2019 (64-bit)',
'compatibility': 'vmx-19',
'uuid': '422eba9f-0327-2da0-b546-f5a5e5dfdb68'
},
{
'vm_name': 'vmname03',
'hostsystem': 'esxi01',
'powerstate': 'poweredOn',
'guest_os': 'Other 3.x or later Linux (64-bit)',
'compatibility': 'vmx-11',
'uuid': '422e3863-b7de-dc55-74f8-6dc9c159b36d'
}
]
for vm in section_esx_vsphere_virtual_machines:
vm_name: str = adjust_name(vm['vm_name'], params.get(PARAM_VM_NAMES, {}))
# if params.get(PARAM_DONT_ADD_VC_AS_VM) is True and vm_name.lower() == vsphere_host.lower():
# continue
host_system: str = adjust_name(vm['hostsystem'], params.get(PARAM_HOST_SYSTEMS, {}))
add_host(host=vm_name)
add_connection(vm_name, host_system)
......@@ -256,8 +257,6 @@ def check_vsphere_topo(
if (vm_to_data_stores := ls_connection.query(query=query)) is not None:
for vm, data_stores in vm_to_data_stores:
vm_name: str = adjust_name(vm, params.get(PARAM_VM_NAMES, {}))
# if params.get(PARAM_DONT_ADD_VC_AS_VM) is True and vm_name.lower() == vsphere_host.lower():
# continue
if vm_name in objects:
data_stores = data_stores.split(',')
for data_store in data_stores:
......@@ -274,7 +273,6 @@ def check_vsphere_topo(
'version': 1,
'name': 'vSphere',
'objects': dict(sorted(objects.items())),
# 'objects': objects,
'connections': connections,
}
......@@ -282,7 +280,7 @@ def check_vsphere_topo(
# workaround for backend is only picking up topologies from default folder
path: str = f'{OMD_ROOT}/var/check_mk/topology/data/default'
if Path(path).exists():
if Path(path).exists() and not Path(f'{path}/data_vsphere.json').exists(): # don't overwrite existing topology
dummy_topology = {'version': 1, 'name': 'vSphere', 'objects': {}, 'connections': []}
save_data_to_file(
data=dummy_topology,
......@@ -294,6 +292,7 @@ def check_vsphere_topo(
for topology in get_topologies():
data_sets.append({'version': 1, 'name': topology, 'objects': {}, 'connections': []})
# end workaround
data_sets.append(data_set_vsphere)
path: str = f'{OMD_ROOT}/var/check_mk/topology/data/{raw_vsphere_host}'
......
......@@ -39,8 +39,8 @@ PARAM_NO_CHANGE: Final[str] = 'no_change'
PARAM_NO_EMBLEM: Final[str] = 'no_emblem'
PARAM_PREFIX: Final[str] = 'prefix'
PARAM_UPPER: Final[str] = 'upper'
PARAM_VM_NAMES: Final[str] = 'vm_names'
PARAM_VCENTER: Final[str] = 'vcenter_icon'
PARAM_VM_NAMES: Final[str] = 'vm_names'
PICTURE_TYPE_EMBLEM: Final[str] = 'emblem'
PICTURE_TYPE_ICON: Final[str] = 'icon'
......@@ -127,10 +127,10 @@ def get_topologies() -> Sequence[str | None]:
json_loads(Path(file).read_text()).get('name') is not None
]
#
# live status
#
class LiveStatusConnection(object):
def __init__(self):
self.sites: SiteConfigurations = SiteConfigurations({})
......
......@@ -22,13 +22,13 @@ from cmk.rulesets.v1.form_specs import (
SingleChoiceElement,
String,
)
from cmk.rulesets.v1.form_specs.validators import LengthInRange
from cmk.rulesets.v1.rule_specs import CheckParameters, HostCondition, Topic
from cmk_addons.plugins.vsphere_topo.lib.utils import (
EMBLEM_CLUSTER,
EMBLEM_DATA_CENTER,
EMBLEM_DATA_STORE,
ICON_VCENTER,
PARAM_ADD_DUMMY_TOPOLOGIES,
PARAM_CHANGE_CASE,
PARAM_CLUSTER,
......@@ -46,12 +46,11 @@ from cmk_addons.plugins.vsphere_topo.lib.utils import (
PARAM_NO_EMBLEM,
PARAM_PREFIX,
PARAM_UPPER,
PARAM_VM_NAMES,
RULE_SET_NAME_VSPHERE_TOPO,
PARAM_VCENTER,
ICON_VCENTER,
PARAM_VM_NAMES,
PICTURE_TYPE_EMBLEM,
PICTURE_TYPE_ICON,
RULE_SET_NAME_VSPHERE_TOPO,
)
adjust_names_elements: Mapping[str, DictElement] = {
......
......@@ -12,7 +12,7 @@
'vsphere_topo/graphing/packages.py']},
'name': 'vsphere_topo',
'title': 'vSphere Topologie',
'version': '0.0.3-20240711',
'version': '0.0.4-20240712',
'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