From 75e913fe6420b1ade5300a7c948817a82e1c9516 Mon Sep 17 00:00:00 2001 From: Marius Rieder Date: Wed, 5 Jun 2024 18:25:49 +0000 Subject: [PATCH] Rework for Checkmk 2.3.0 --- .devcontainer/build.sh | 4 +- agent_based/veeam_o365jobs.py | 19 +-- agent_based/veeam_o365licenses.py | 74 ++++------ bakery/veeam_o365.py | 3 +- graphing/veeam_o365.py | 136 ++++++++++++++++++ package | 30 ++-- .../agent_based/test_veeam_o356jobs.py | 6 +- .../agent_based/test_veeam_o356licenses.py | 16 +-- web/plugins/metrics/veeam_o365jobs.py | 93 ------------ web/plugins/metrics/veeam_o365licenses.py | 57 -------- web/plugins/wato/agent_bakery_veeam_o365.py | 55 ------- .../wato/check_parameters_veeam_o365jobs.py | 135 ----------------- .../check_parameters_veeam_o365licenses.py | 82 ----------- 13 files changed, 205 insertions(+), 505 deletions(-) create mode 100644 graphing/veeam_o365.py rename tests/unit/{cmk/base/plugins => }/agent_based/test_veeam_o356jobs.py (97%) rename tests/unit/{cmk/base/plugins => }/agent_based/test_veeam_o356licenses.py (83%) delete mode 100644 web/plugins/metrics/veeam_o365jobs.py delete mode 100644 web/plugins/metrics/veeam_o365licenses.py delete mode 100644 web/plugins/wato/agent_bakery_veeam_o365.py delete mode 100644 web/plugins/wato/check_parameters_veeam_o365jobs.py delete mode 100644 web/plugins/wato/check_parameters_veeam_o365licenses.py diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh index ad9915a..6625ef5 100755 --- a/.devcontainer/build.sh +++ b/.devcontainer/build.sh @@ -1,12 +1,14 @@ #!/bin/bash +set -e NAME=$(python3 -c 'print(eval(open("package").read())["name"])') VERSION=$(python3 -c 'print(eval(open("package").read())["version"])') rm /omd/sites/cmk/var/check_mk/packages/${NAME} \ /omd/sites/cmk/var/check_mk/packages_local/${NAME}-*.mkp ||: -mkp -v package package 2>&1 | sed '/Installing$/Q' ||: +mkp -v package package +rm $NAME-$VERSION.mkp cp /omd/sites/cmk/var/check_mk/packages_local/$NAME-$VERSION.mkp . mkp inspect $NAME-$VERSION.mkp diff --git a/agent_based/veeam_o365jobs.py b/agent_based/veeam_o365jobs.py index b584f9a..b00afca 100644 --- a/agent_based/veeam_o365jobs.py +++ b/agent_based/veeam_o365jobs.py @@ -21,13 +21,14 @@ # 01234567-89ab-cdef-0123-456789abcdef cmk.onmicrosoft.com Outlook Online Success 29.05.2020 16:45:46 29.05.2020 16:47:55 128.7511818 191 142 # 12345678-9abc-def0-1234-56789abcdef0 cmk.onmicrosoft.com Outlook Online2 Failed 29.05.2020 16:45:46 29.05.2020 16:47:55 128.7511818 -from .agent_based_api.v1 import ( +from cmk.agent_based.v2 import ( Service, Result, State, check_levels, render, - register, + CheckPlugin, + RuleSetType, ) VEEAM_O365JOBS_CHECK_DEFAULT_PARAMETERS = { @@ -88,20 +89,20 @@ def check_veeam_o365jobs(item, params, section): yield from check_levels( float(job_duration), metric_name='duration', - levels_upper=params.get('duration', None), + levels_upper=params.get('duration', ('no_levels', None)), label='Backup duration', render_func=render.timespan, ) -register.check_plugin( - name = 'veeam_o365jobs', +check_plugin_veeam_o365jobs = CheckPlugin( + name='veeam_o365jobs', service_name = 'VEEAM O365 Job %s', - discovery_ruleset_name='inventory_veeam_o365jobs_rules', - discovery_ruleset_type=register.RuleSetType.MERGED, + discovery_function=discovery_veeam_o365jobs, + discovery_ruleset_name='veeam_o365jobs', + discovery_ruleset_type=RuleSetType.MERGED, discovery_default_parameters={}, - discovery_function = discovery_veeam_o365jobs, - check_function = check_veeam_o365jobs, + check_function=discovery_veeam_o365jobs, check_ruleset_name='veeam_o365jobs', check_default_parameters=VEEAM_O365JOBS_CHECK_DEFAULT_PARAMETERS, ) diff --git a/agent_based/veeam_o365licenses.py b/agent_based/veeam_o365licenses.py index 372a304..2a49392 100644 --- a/agent_based/veeam_o365licenses.py +++ b/agent_based/veeam_o365licenses.py @@ -20,14 +20,13 @@ # <<>> # Valid 28.06.2020 02:00:00 2592000 42 50000 -from .agent_based_api.v1 import ( +from cmk.agent_based.v2 import ( Service, Result, State, check_levels, render, - Metric, - register, + CheckPlugin, ) @@ -50,54 +49,37 @@ def check_veeam_o365licenses(item, params, section): yield from check_levels( float(license_validity), - levels_lower=params.get('validity', (0, 0)), + levels_lower=params.get('validity', ('fixed', (0, 0))), label='Period of validity' if float(license_validity) > 0 else 'Expired since', render_func=lambda f: render.timespan(f if f > 0 else -f), ) - license_params = params.get('licenses', None) - - if license_params is False: - license_warn = None - license_crit = None - elif not license_params: - license_warn = int(license_total) - license_crit = int(license_total) - elif isinstance(license_params[0], int): - license_warn = max(0, int(license_total) - license_params[0]) - license_crit = max(0, int(license_total) - license_params[1]) - else: - license_warn = int(license_total) * (1 - license_params[0] / 100.0) - license_crit = int(license_total) * (1 - license_params[1] / 100.0) - - yield Metric('licenses', - int(license_used), - levels=(license_warn, license_crit), - boundaries=(0, int(license_total))) - - if int(license_used) <= int(license_total): - infotext = 'used %d out of %d licenses' % (int(license_used), int(license_total)) - else: - infotext = 'used %d licenses, but you have only %d' % (int(license_used), int(license_total)) - - if license_crit is not None and int(license_used) >= license_crit: - status = State.CRIT - elif license_warn is not None and int(license_used) >= license_warn: - status = State.WARN - else: - status = State.OK - - if license_crit is not None: - infotext += ' (warn/crit at %d/%d)' % (license_warn, license_crit) - - yield Result(state=status, summary=infotext) - - -register.check_plugin( - name = 'veeam_o365licenses', + license_used = int(license_used) + license_total = int(license_total) + + match params.get('licenses', None): + case ('always_ok', None): + levels = ('no_levels', None) + case ('absolute', {'warn': warn, 'crit': crit}): + levels = ('fixed', (license_total - warn, license_total - crit)) + case ('percentage', {'warn': warn, 'crit': crit}): + levels = ('fixed', (int(license_total * (100 - warn) / 100), int(license_total * (100 - crit) / 100))) + case _: + levels = ('fixed', (int(license_total), int(license_total))) + + yield from check_levels(license_used, + label="used", + render_func=lambda v: f"{v:d}", + levels_upper=levels, + metric_name='licenses', + boundaries=(0, int(license_total))) + + +check_plugin_veeam_o365jobs = CheckPlugin( + name='veeam_o365licenses', service_name = 'VEEAM O365 License %s', - discovery_function = discovery_veeam_o365licenses, - check_function = check_veeam_o365licenses, + discovery_function=discovery_veeam_o365licenses, + check_function=check_veeam_o365licenses, check_ruleset_name='veeam_o365licenses', check_default_parameters={}, ) diff --git a/bakery/veeam_o365.py b/bakery/veeam_o365.py index fd9ebee..948f57e 100644 --- a/bakery/veeam_o365.py +++ b/bakery/veeam_o365.py @@ -24,7 +24,8 @@ def get_veeam_o365_files(conf: Any) -> FileGenerator: - yield Plugin(base_os=OS.WINDOWS, source=Path('veeam_o365_status.ps1')) + if conf.get('agent', 'do_not_deploy') == 'deploy': + yield Plugin(base_os=OS.WINDOWS, source=Path('veeam_o365_status.ps1')) register.bakery_plugin( diff --git a/graphing/veeam_o365.py b/graphing/veeam_o365.py new file mode 100644 index 0000000..7dbf947 --- /dev/null +++ b/graphing/veeam_o365.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +# Copyright (C) 2020-2024 Marius Rieder +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +from cmk.graphing.v1 import ( + graphs as g, + metrics as m, + perfometers as p, + translations as t, +) + +translation_veeam_o365jobs = t.Translation( + name='veeam_o365jobs', + check_commands=[t.PassiveCheck('veeam_o365jobs')], + translations={ + 'transferred': t.RenameTo('veeam_o365jobs_transferred'), + 'duration': t.RenameTo('veeam_o365jobs_duration'), + 'items': t.RenameTo('veeam_o365jobs_items'), + } +) + +translation_veeam_o365licenses = t.Translation( + name='veeam_o365licenses', + check_commands=[t.PassiveCheck('veeam_o365licenses')], + translations={ + 'licenses': t.RenameTo('veeam_o365licenses_licenses'), + } +) + +metric_veeam_o365jobs_transferred = m.Metric( + name='veeam_o365jobs_transferred', + title=m.Title('Data Transferred'), + unit=m.Unit(m.IECNotation("bits")), + color=m.Color.GREEN, +) + +metric_veeam_o365jobs_duration = m.Metric( + name='veeam_o365jobs_duration', + title=m.Title('Job Duration'), + unit=m.Unit(m.TimeNotation()), + color=m.Color.GREEN, +) + +metric_veeam_o365jobs_transferred = m.Metric( + name='veeam_o365jobs_items', + title=m.Title('Items Transferred'), + unit=m.Unit(m.DecimalNotation(""), m.StrictPrecision(0)), + color=m.Color.GREEN, +) + +metric_veeam_o365licenses_licenses = m.Metric( + name='veeam_o365licenses_licenses', + title=m.Title('Used licenses'), + unit=m.Unit(m.DecimalNotation(""), m.StrictPrecision(0)), + color=m.Color.GREEN, +) + +graph_veeam_o365jobs_transferred = g.Graph( + name='veeam_o365jobs_transferred', + title=g.Title('Veeam for Office 365 Job'), + minimal_range=g.MinimalRange(0, m.MaximumOf('veeam_o365jobs_transferred')), + compound_lines=['veeam_o365jobs_transferred'], + simple_lines=[ + m.WarningOf('veeam_o365jobs_transferred'), + m.CriticalOf('veeam_o365jobs_transferred'), + ] +) + +graph_veeam_o365jobs_duration = g.Graph( + name='veeam_o365jobs_duration', + title=g.Title('Veeam for Office 365 Job'), + minimal_range=g.MinimalRange(0, m.MaximumOf('veeam_o365jobs_duration')), + compound_lines=['veeam_o365jobs_duration'], + simple_lines=[ + m.WarningOf('veeam_o365jobs_duration'), + m.CriticalOf('veeam_o365jobs_duration'), + ] +) + +graph_veeam_o365jobs_items = g.Graph( + name='veeam_o365jobs_items', + title=g.Title('Veeam for Office 365 Job'), + minimal_range=g.MinimalRange(0, m.MaximumOf('veeam_o365jobs_items')), + compound_lines=['veeam_o365jobs_items'], + simple_lines=[ + m.WarningOf('veeam_o365jobs_items'), + m.CriticalOf('veeam_o365jobs_items'), + ] +) + +graph_veeam_o365licenses_licenses = g.Graph( + name='veeam_o365licenses_licenses', + title=g.Title('Veeam for Office 365 licenses'), + minimal_range=g.MinimalRange(0, m.MaximumOf('veeam_o365licenses_licenses')), + compound_lines=['veeam_o365licenses_licenses'], + simple_lines=[ + m.WarningOf('veeam_o365licenses_licenses'), + m.CriticalOf('veeam_o365licenses_licenses'), + m.MaximumOf('veeam_o365licenses_licenses', m.Color.BLACK) + ] +) + +perfometer_veeam_o365jobs = p.Stacked( + name='veeam_o365jobs', + upper=p.Perfometer( + name='veeam_o365jobs_transferred', + focus_range=p.FocusRange(p.Closed(0), p.Open(m.WarningOf('veeam_o365jobs_transferred'))), + segments=['veeam_o365jobs_transferred'], + ), + lower=p.Perfometer( + name='veeam_o365jobs_duration', + focus_range=p.FocusRange(p.Closed(0), p.Open(m.WarningOf('veeam_o365jobs_duration'))), + segments=['veeam_o365jobs_duration'], + ), +) + +perfometer_veeam_o365licenses_licenses = p.Perfometer( + name='veeam_o365licenses_licenses', + focus_range=p.FocusRange(p.Closed(0), p.Open(m.MaximumOf('veeam_o365licenses_licenses'))), + segments=['veeam_o365licenses_licenses'], +) diff --git a/package b/package index b1bcb7c..c58612e 100644 --- a/package +++ b/package @@ -3,25 +3,25 @@ 'description': u'Agent Plugin and Checks for Veeam for Office 365', 'download_url': 'https://github.com/jiuka/checkmk_veeam_o365/releases', 'files': { - 'agent_based': ['veeam_o365jobs.py', 'veeam_o365licenses.py'], - 'agents': [ - 'windows/plugins/veeam_o365_status.ps1', + 'agents': ['windows/plugins/veeam_o365_status.ps1'], + 'cmk_addons_plugins': [ + 'veeam_o365/agent_based/veeam_o365jobs.py', + 'veeam_o365/agent_based/veeam_o365licenses.py', + 'veeam_o365/checkman/veeam_o365jobs', + 'veeam_o365/checkman/veeam_o365licenses', + 'veeam_o365/graphing/veeam_o365.py', + 'veeam_o365/rulesets/check_parameters.py', + 'veeam_o365/rulesets/discovery_parameters.py', + 'veeam_o365/rulesets/agent_config.py', ], - 'checkman': ['veeam_o365jobs', 'veeam_o365licenses'], 'lib': [ 'python3/cmk/base/cee/plugins/bakery/veeam_o365.py', ], - 'web': [ - 'plugins/metrics/veeam_o365jobs.py', - 'plugins/metrics/veeam_o365licenses.py', - 'plugins/wato/agent_bakery_veeam_o365.py', - 'plugins/wato/check_parameters_veeam_o365licenses.py', - 'plugins/wato/check_parameters_veeam_o365jobs.py', - ]}, + }, 'name': 'veeam_o365', 'title': u'Veeam for Office 365 Checks', - 'version': '2.6.0', - 'version.min_required': '2.2.0', - 'version.packaged': '2.2.0', - 'version.usable_until': '2.3.0' + 'version': '2.7.0-0', + 'version.min_required': '2.3.0p3', + 'version.packaged': '2.3.0', + 'version.usable_until': '2.4.0' } diff --git a/tests/unit/cmk/base/plugins/agent_based/test_veeam_o356jobs.py b/tests/unit/agent_based/test_veeam_o356jobs.py similarity index 97% rename from tests/unit/cmk/base/plugins/agent_based/test_veeam_o356jobs.py rename to tests/unit/agent_based/test_veeam_o356jobs.py index 83bff7d..9959eed 100644 --- a/tests/unit/cmk/base/plugins/agent_based/test_veeam_o356jobs.py +++ b/tests/unit/agent_based/test_veeam_o356jobs.py @@ -18,13 +18,13 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import pytest # type: ignore[import] -from cmk.base.plugins.agent_based.agent_based_api.v1 import ( +from cmk.agent_based.v2 import ( Metric, Result, Service, State, ) -from cmk.base.plugins.agent_based import veeam_o365jobs +from cmk_addons.plugins.veeam_o365.agent_based import veeam_o365jobs @pytest.mark.parametrize('params, section, result', [ @@ -98,7 +98,7 @@ def test_discovery_veeam_o365jobs(params, section, result): ] ), ( - 'cmk.onmicrosoft.com Outlook Online', {'jobId': '12345678-9abc-def0-1234-56789abcdef0', 'duration': (120, 300)}, + 'cmk.onmicrosoft.com Outlook Online', {'jobId': '12345678-9abc-def0-1234-56789abcdef0', 'duration': ('fixed', (120, 300))}, [ ['01234567-89ab-cdef-0123-456789abcdef', 'cmk.onmicrosoft.com', 'Outlook Online', 'Success', '29.05.2020 16:45:46', '29.05.2020 16:47:55', '128.7511818', '191', '142'], ['12345678-9abc-def0-1234-56789abcdef0', 'cmk.onmicrosoft.com', 'Outlook Online2', 'Failed', '29.05.2020 16:45:46', '29.05.2020 16:47:55', '128.7511818'] diff --git a/tests/unit/cmk/base/plugins/agent_based/test_veeam_o356licenses.py b/tests/unit/agent_based/test_veeam_o356licenses.py similarity index 83% rename from tests/unit/cmk/base/plugins/agent_based/test_veeam_o356licenses.py rename to tests/unit/agent_based/test_veeam_o356licenses.py index 6970843..085fd35 100644 --- a/tests/unit/cmk/base/plugins/agent_based/test_veeam_o356licenses.py +++ b/tests/unit/agent_based/test_veeam_o356licenses.py @@ -18,13 +18,13 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import pytest # type: ignore[import] -from cmk.base.plugins.agent_based.agent_based_api.v1 import ( +from cmk.agent_based.v2 import ( Metric, Result, Service, State, ) -from cmk.base.plugins.agent_based import veeam_o365licenses +from cmk_addons.plugins.veeam_o365.agent_based import veeam_o365licenses @pytest.mark.parametrize('section, result', [ @@ -46,28 +46,28 @@ def test_discovery_veeam_o365licenses(section, result): [ Result(state=State.OK, summary='License is vaild till 28.06.2020 02:00:00'), Result(state=State.OK, summary='Period of validity: 30 days 0 hours'), + Result(state=State.OK, summary='used: 42'), Metric('licenses', 42.0, levels=(50000.0, 50000.0), boundaries=(0.0, 50000.0)), - Result(state=State.OK, summary='used 42 out of 50000 licenses (warn/crit at 50000/50000)'), ] ), ( - '0', {'validity': (3456000, 1728000)}, + '0', {'validity': ('fixed', (3456000, 1728000))}, [['Valid', '28.06.2020 02:00:00', '2592000', '42', '50000']], [ Result(state=State.OK, summary='License is vaild till 28.06.2020 02:00:00'), Result(state=State.WARN, summary='Period of validity: 30 days 0 hours (warn/crit below 40 days 0 hours/20 days 0 hours)'), + Result(state=State.OK, summary='used: 42'), Metric('licenses', 42.0, levels=(50000.0, 50000.0), boundaries=(0.0, 50000.0)), - Result(state=State.OK, summary='used 42 out of 50000 licenses (warn/crit at 50000/50000)'), ] ), ( - '0', {'licenses': (10, 5)}, + '0', {'licenses': ('absolute', {'warn': 10, 'crit': 5})}, [['Valid', '28.06.2020 02:00:00', '2592000', '42', '50']], [ Result(state=State.OK, summary='License is vaild till 28.06.2020 02:00:00'), Result(state=State.OK, summary='Period of validity: 30 days 0 hours'), + Result(state=State.WARN, summary='used: 42 (warn/crit at 40/45)'), Metric('licenses', 42.0, levels=(40.0, 45.0), boundaries=(0.0, 50.0)), - Result(state=State.WARN, summary='used 42 out of 50 licenses (warn/crit at 40/45)'), ] ), ( @@ -76,8 +76,8 @@ def test_discovery_veeam_o365licenses(section, result): [ Result(state=State.OK, summary='License is vaild till 28.06.2020 02:00:00'), Result(state=State.CRIT, summary='Expired since: 30 days 0 hours (warn/crit below 0 seconds/0 seconds)'), + Result(state=State.OK, summary='used: 42'), Metric('licenses', 42.0, levels=(50.0, 50.0), boundaries=(0.0, 50.0)), - Result(state=State.OK, summary='used 42 out of 50 licenses (warn/crit at 50/50)'), ] ), ]) diff --git a/web/plugins/metrics/veeam_o365jobs.py b/web/plugins/metrics/veeam_o365jobs.py deleted file mode 100644 index a928eb9..0000000 --- a/web/plugins/metrics/veeam_o365jobs.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Copyright (C) 2020 Marius Rieder -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -from cmk.gui.i18n import _ - -from cmk.gui.plugins.metrics import ( - check_metrics, - metric_info, - graph_info, - perfometer_info, - MB -) - - -check_metrics['check_mk-veeam_o365jobs'] = { - 'transferred': {'name': 'veeam_o365jobs_transferred'}, - 'duration': {'name': 'veeam_o365jobs_duration'}, - 'items': {'name': 'veeam_o365jobs_items'}, -} - - -metric_info['veeam_o365jobs_transferred'] = { - 'title': _('Data Transferred'), - 'unit': 'bytes', - 'color': '#00b336', -} - -metric_info['veeam_o365jobs_duration'] = { - 'title': _('Job Duration'), - 'unit': 's', - 'color': '#00b336', -} - -metric_info['veeam_o365jobs_items'] = { - 'title': _('Items Transferred'), - 'unit': 'count', - 'color': '#00b336', -} - - -graph_info['veeam_o365jobs_transferred'] = { - 'title': _('Veeam for Office 365 Job'), - 'metrics': [('veeam_o365jobs_transferred', 'area')], - 'range': (0, 'veeam_o365jobs_transferred:max'), -} - -graph_info['veeam_o365jobs_duration'] = { - 'title': _('Veeam for Office 365 Job'), - 'metrics': [('veeam_o365jobs_duration', 'area')], - 'scalars': [ - 'veeam_o365jobs_duration:warn', - 'veeam_o365jobs_duration:crit', - ], - 'range': (0, 'veeam_o365jobs_duration:max'), -} - -graph_info['veeam_o365jobs_items'] = { - 'title': _('Veeam for Office 365 Job'), - 'metrics': [('veeam_o365jobs_items', 'area')], - 'range': (0, 'veeam_o365jobs_items:max'), -} - - -perfometer_info.append({ - 'type': 'stacked', - 'perfometers': [{ - 'type': 'logarithmic', - 'metric': 'veeam_o365jobs_transferred', - 'half_value': MB, - 'exponent': 2, - }, { - 'type': 'logarithmic', - 'metric': 'veeam_o365jobs_duration', - 'half_value': 60, - 'exponent': 2 - }], -}) diff --git a/web/plugins/metrics/veeam_o365licenses.py b/web/plugins/metrics/veeam_o365licenses.py deleted file mode 100644 index 48d0e5b..0000000 --- a/web/plugins/metrics/veeam_o365licenses.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Copyright (C) 2020 Marius Rieder -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -from cmk.gui.i18n import _ - -from cmk.gui.plugins.metrics import ( - check_metrics, - metric_info, - graph_info, - perfometer_info, -) - - -check_metrics['check_mk-veeam_o365licenses'] = { - 'licenses': { - 'name': 'veeam_o365licenses_licenses' - }, -} - -metric_info['veeam_o365licenses_licenses'] = { - 'title': _('Used licenses'), - 'unit': 'count', - 'color': '#00b336', -} - -graph_info['veeam_o365licenses_licenses'] = { - 'title': _('Veeam for Office 365 licenses'), - 'metrics': [('veeam_o365licenses_licenses', 'area')], - 'scalars': [ - 'veeam_o365licenses_licenses:warn', - 'veeam_o365licenses_licenses:crit', - ('veeam_o365licenses_licenses:max#000000', 'Total licenses'), - ], - 'range': (0, 'veeam_o365licenses_licenses:max'), -} - -perfometer_info.append({ - 'type': 'linear', - 'segments': ['veeam_o365licenses_licenses'], - 'total': 'veeam_o365licenses_licenses:max', -}) diff --git a/web/plugins/wato/agent_bakery_veeam_o365.py b/web/plugins/wato/agent_bakery_veeam_o365.py deleted file mode 100644 index b3a976d..0000000 --- a/web/plugins/wato/agent_bakery_veeam_o365.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Copyright (C) 2020 Marius Rieder -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -from cmk.gui.i18n import _ -from cmk.gui.valuespec import ( - DropdownChoice, -) -from cmk.gui.plugins.wato import ( - HostRulespec, - rulespec_registry, -) - -try: - from cmk.gui.cee.plugins.wato.agent_bakery.rulespecs.utils import ( - RulespecGroupMonitoringAgentsAgentPlugins - ) -except Exception: - RulespecGroupMonitoringAgentsAgentPlugins = None - - -def _valuespec_agent_config_veeam_o365(): - return DropdownChoice( - title=_('Veeam for Office 365'), - help=_('This will deploy the agent plugin veeam_o365_status ' - 'for checking Veeam for Office 365 status.'), - choices=[ - (True, _('Deploy Veeam for Office 365 plugin')), - (None, _('Do not deploy Veeam for Office 365 plugin')), - ], - ) - - -if RulespecGroupMonitoringAgentsAgentPlugins is not None: - rulespec_registry.register( - HostRulespec( - group=RulespecGroupMonitoringAgentsAgentPlugins, - name='agent_config:veeam_o365', - valuespec=_valuespec_agent_config_veeam_o365, - )) diff --git a/web/plugins/wato/check_parameters_veeam_o365jobs.py b/web/plugins/wato/check_parameters_veeam_o365jobs.py deleted file mode 100644 index 91f5ff7..0000000 --- a/web/plugins/wato/check_parameters_veeam_o365jobs.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Copyright (C) 2020 Marius Rieder -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -from cmk.gui.i18n import _ -from cmk.gui.valuespec import ( - Age, - Dictionary, - DropdownChoice, - MonitoringState, - TextAscii, - Tuple, -) -from cmk.gui.plugins.wato import ( - CheckParameterRulespecWithItem, - RulespecGroupCheckParametersApplications, - RulespecGroupCheckParametersDiscovery, - rulespec_registry, - HostRulespec, -) - - -def _valuespec_inventory_veeam_o365jobs_rules(): - return Dictionary( - title=_('Veeam for Office 365 Job Discovery'), - elements=[ - ('item_appearance', - DropdownChoice( - title=_('Appearance of job'), - help=_( - 'This option lets Check_MK use either only the job name, ' - 'prepend it with the shortend org oder the full org.'), - choices=[ - ('name', _('Use only the job name')), - ('short', _('Use the shortend org and the name')), - ('full', _('Use the full org and the name')), - ], - default_value='name', - )), - ], - help=_('This rule can be used to control the inventory for Veeam for ' - 'Office 365 Jobs. You can configure the service name to include' - 'the Organisation.'), - ) - - -rulespec_registry.register( - HostRulespec( - group=RulespecGroupCheckParametersDiscovery, - name='inventory_veeam_o365jobs_rules', - valuespec=_valuespec_inventory_veeam_o365jobs_rules, - )) - - -def _item_spec_veeam_o365jobs(): - return TextAscii( - title=_('Veeam for Office365 Job name'), - help=_('Name of the jobs service.') - ) - - -def _parameter_valuespec_veeam_o365jobs(): - return Dictionary( - title=_('Veem for Office 365 Jobs'), - elements=[ - ('duration', - Tuple( - title=_('Duration'), - elements=[ - Age(title=_('Warning at'),), - Age(title=_('Critical at'),), - ], - help=_('Thresholds for duration of the job.'), - )), - ('states', - Dictionary( - title=_('State mapping'), - elements=[ - ('Success', - MonitoringState( - title=_('Success'), - default_value=0, - )), - ('Warning', - MonitoringState( - title=_('Warning'), - default_value=1, - )), - ('Stopped', - MonitoringState( - title=_('Stopped'), - default_value=1, - )), - ('Failed', - MonitoringState( - title=_('Failed'), - default_value=2, - )), - ], - help=_('Remap the job stat to different monitoring states.'), - required_keys=[ - 'Success', - 'Warning', - 'Stopped', - 'Failed', - ], - )), - ], - help=_('This rule configures thresholds Veeam for Office 365 jobs.'), - ) - - -rulespec_registry.register( - CheckParameterRulespecWithItem( - check_group_name='veeam_o365jobs', - group=RulespecGroupCheckParametersApplications, - item_spec=_item_spec_veeam_o365jobs, - parameter_valuespec=_parameter_valuespec_veeam_o365jobs, - title=lambda: _('Veeam for Office 365 Job Levels'), - )) diff --git a/web/plugins/wato/check_parameters_veeam_o365licenses.py b/web/plugins/wato/check_parameters_veeam_o365licenses.py deleted file mode 100644 index 3328920..0000000 --- a/web/plugins/wato/check_parameters_veeam_o365licenses.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Copyright (C) 2020 Marius Rieder -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -from cmk.gui.exceptions import MKUserError -from cmk.gui.i18n import _ -from cmk.gui.plugins.wato.check_parameters.licenses import _vs_license -from cmk.gui.valuespec import ( - Age, - Dictionary, - TextAscii, - Tuple, -) -from cmk.gui.plugins.wato import ( - CheckParameterRulespecWithItem, - RulespecGroupCheckParametersApplications, - rulespec_registry, -) - - -def _validate_tuple_decrease(value, varprefix): - cur = value[0] - for entry in value[1:]: - if entry >= cur: - raise MKUserError(varprefix, - _('Warning needs to be bigger then critical')) - cur = entry - - -def _item_spec_veeam_o365licenses(): - return TextAscii( - title=_('Veeam for Office365 Licenses number'), - allow_empty=False, - help=_('Number of thelicense service.') - ) - - -def _valuespec_spec_veeam_o365licenses(): - return Dictionary( - elements=[ - ('validity', - Tuple( - title=_('License term'), - help=_('Days until expiry of the license'), - elements=[ - Age(title=_('Warning at'), - display=['days'], - default_value=90 * 24 * 60 * 60), - Age(title=_('Critical at'), - display=['days'], - default_value=60 * 24 * 60 * 60), - ], - validate=_validate_tuple_decrease, - )), - ('licenses', _vs_license()), - ], - ) - - -rulespec_registry.register( - CheckParameterRulespecWithItem( - check_group_name='veeam_o365licenses', - group=RulespecGroupCheckParametersApplications, - item_spec=_item_spec_veeam_o365licenses, - parameter_valuespec=_valuespec_spec_veeam_o365licenses, - title=lambda: _('Veeam for Office 365 licenses'), - ))