diff --git a/README.md b/README.md index f8cd3a68525917369d1aa6b4c783c051a819ea29..d130b9e5c9348532d9c153c8108a83b6d1c08721 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PACKAGE]: ../../raw/master/mkp/vsphere_topo-0.0.1-20240709.mkp "vsphere_topo-0.0.1-20240709.mkp" +[PACKAGE]: ../../raw/master/mkp/vsphere_topo-0.0.2-20240709.mkp "vsphere_topo-0.0.2-20240709.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. diff --git a/mkp/vsphere_topo-0.0.2-20240709.mkp b/mkp/vsphere_topo-0.0.2-20240709.mkp new file mode 100644 index 0000000000000000000000000000000000000000..3838a14893cefc61b7f47762264fbea7a866e184 Binary files /dev/null and b/mkp/vsphere_topo-0.0.2-20240709.mkp differ diff --git a/source/cmk_addons_plugins/vsphere_topo/agent_based/packages.py b/source/cmk_addons_plugins/vsphere_topo/agent_based/packages.py index 912b4c40253d7360badd221f2ceca267208b3c15..401aa8f5a7f38f02389ab5d64214979b331092ea 100644 --- a/source/cmk_addons_plugins/vsphere_topo/agent_based/packages.py +++ b/source/cmk_addons_plugins/vsphere_topo/agent_based/packages.py @@ -8,6 +8,8 @@ # Date : 2024-07-05 # File : vsphere_topo/agent_based/packages.py +# 2024-07-10: added time taken as metric + from collections.abc import Mapping, Sequence from time import time_ns from typing import Any @@ -19,6 +21,8 @@ from cmk.agent_based.v2 import ( Result, Service, State, + check_levels, + render, ) from cmk.base.check_api import host_name from cmk_addons.plugins.vsphere_topo.lib.utils import ( @@ -273,7 +277,13 @@ def check_vsphere_topo( yield Result(state=State.OK, summary=f'Objects: {len(objects)}') yield Result(state=State.OK, summary=f'Connections: {len(connections)}') yield Result(state=State.OK, notice=f'Written to: {path}/{file}') - yield Result(state=State.OK, summary=f'Time taken: {((time_ns() - start_time) / 1e9):.2}/s') + yield from check_levels( + value=(time_ns() - start_time) / 1e9, + label='Time taken', + metric_name='vsphere_topo_time_taken', + boundaries=(0, None), + render_func=render.timespan, + ) check_plugin_vsphere_topo = CheckPlugin( diff --git a/source/cmk_addons_plugins/vsphere_topo/graphing/packages.py b/source/cmk_addons_plugins/vsphere_topo/graphing/packages.py new file mode 100644 index 0000000000000000000000000000000000000000..036cc608284f339802724d0138b552a26dff705b --- /dev/null +++ b/source/cmk_addons_plugins/vsphere_topo/graphing/packages.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2024-07-10 +# File : vsphere_topo/graphing/packages.py + +from cmk.graphing.v1 import Title +from cmk.graphing.v1.graphs import Graph +from cmk.graphing.v1.metrics import Color, Metric, Unit, TimeNotation, AutoPrecision +from cmk.graphing.v1.perfometers import Closed, FocusRange, Open, Perfometer + +metric_vsphere_topo_time_taken = Metric( + name='vsphere_topo_time_taken', + title=Title('Time taken'), + unit=Unit(TimeNotation(), AutoPrecision(4)), + color=Color.BLUE, +) + +graph_vsphere_topo_time_taken = Graph( + name='vsphere_topo_time_taken', + title=Title('Time taken'), + compound_lines=['vsphere_topo_time_taken'], +) + +perfometer_vsphere_topo_time_taken = Perfometer( + name='vsphere_topo_time_taken', + focus_range=FocusRange(Closed(0), Open(1)), + segments=['vsphere_topo_time_taken'] +) diff --git a/source/cmk_addons_plugins/vsphere_topo/rulesets/packages.py b/source/cmk_addons_plugins/vsphere_topo/rulesets/packages.py index 2133a73642f5e12f1a66cc882b4a39e800e6c61d..800fdae5f755bceee606d3f42c2db259e833becc 100644 --- a/source/cmk_addons_plugins/vsphere_topo/rulesets/packages.py +++ b/source/cmk_addons_plugins/vsphere_topo/rulesets/packages.py @@ -10,7 +10,7 @@ from collections.abc import Mapping, Sequence -from cmk.rulesets.v1 import Label, Title +from cmk.rulesets.v1 import Help, Label, Title from cmk.rulesets.v1.form_specs import ( CascadingSingleChoice, CascadingSingleChoiceElement, @@ -118,42 +118,70 @@ def _parameter_form() -> Dictionary: parameter_form=CascadingSingleChoice( title=Title('Cluster emblem'), elements=get_emblem_element(EMBLEM_CLUSTER), - prefill=DefaultValue(PARAM_DEFAULT_EMBLEM) + prefill=DefaultValue(PARAM_DEFAULT_EMBLEM), + help_text=Help( + 'Here you can change the picture for the cluster. If you use the built-in icons prefix ' + 'the name with "icon_"' + ), )), PARAM_DATA_CENTER: DictElement( parameter_form=CascadingSingleChoice( title=Title('Datacenter emblem'), elements=get_emblem_element(EMBLEM_DATA_CENTER), - prefill=DefaultValue(PARAM_DEFAULT_EMBLEM) + prefill=DefaultValue(PARAM_DEFAULT_EMBLEM), + help_text=Help( + 'Here you can change the picture for the datacenter. If you use the built-in icons prefix ' + 'the name with "icon_"' + ), )), PARAM_DATA_STORE: DictElement( parameter_form=CascadingSingleChoice( title=Title('Datastore emblem'), elements=get_emblem_element(EMBLEM_DATA_STORE), - prefill=DefaultValue(PARAM_DEFAULT_EMBLEM) + prefill=DefaultValue(PARAM_DEFAULT_EMBLEM), + help_text=Help( + 'Here you can change the picture for the datastore. If you use the built-in icons prefix ' + 'the name with "icon_"' + ), )), PARAM_DATA_STORE_AS_SERVICE: DictElement( parameter_form=FixedValue( title=Title('Add data store service'), label=Label('enabled'), + help_text=Help( + 'This option adds the datastore services from the vCenter object to the topology. ' + 'Pro: more insight. Con: cluttered topology.' + ), value=True )), PARAM_MAKE_DEFAULT: DictElement( parameter_form=FixedValue( title=Title('Make default'), label=Label('This will be the default topology'), + help_text=Help( + 'Makes the vSphere topology the default topology. If there no default topology, the vSphere ' + 'topology becomes always the default.' + ), value=True )), PARAM_DONT_ADD_VC_AS_VM: DictElement( parameter_form=FixedValue( title=Title('Don\'t add vCenter as VM'), label=Label('The vCenter will not be added as VM'), + help_text=Help( + 'Use this option if the vCenter is also a VM within the managed datacenter.' + 'This will create a clearer topology, but you lose the info where the vCenter is running.' + ), value=True )), PARAM_ADD_DUMMY_TOPOLOGIES: DictElement( parameter_form=FixedValue( title=Title('Add dummy topologies'), label=Label('Adds empty CDP, LLDP, L3v4 and STATIC topology'), + help_text=Help( + 'Use this option if you are also using the NVDCT. This is a workaround, as the backend ' + 'only picks up layers that are present in the default topology folder.' + ), value=True )), } diff --git a/source/packages/vsphere_topo b/source/packages/vsphere_topo index 62492c4615b4a79fbc72f9ba98419fb1606d02f9..142ae810548317ff10beaef62ee407091554bdb1 100644 --- a/source/packages/vsphere_topo +++ b/source/packages/vsphere_topo @@ -8,10 +8,11 @@ 'download_url': 'https://thl-cmk.hopto.org', 'files': {'cmk_addons_plugins': ['vsphere_topo/agent_based/packages.py', 'vsphere_topo/rulesets/packages.py', - 'vsphere_topo/lib/utils.py']}, + 'vsphere_topo/lib/utils.py', + 'vsphere_topo/graphing/packages.py']}, 'name': 'vsphere_topo', 'title': 'vSphere Topologie', - 'version': '0.0.1-20240709', + 'version': '0.0.2-20240709', 'version.min_required': '2.3.0b1', 'version.packaged': 'cmk-mkp-tool 0.2.0', 'version.usable_until': '2.4.0b1'}