From b81b007eeb2bcb867a8c101af8f6709cf51928cf Mon Sep 17 00:00:00 2001 From: Marius Rieder Date: Mon, 10 Jun 2024 15:32:05 +0000 Subject: [PATCH] Fix new linter warnings --- agent_based/veeam_o365jobs.py | 7 +++++-- tests/unit/agent_based/test_veeam_o356jobs.py | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/agent_based/veeam_o365jobs.py b/agent_based/veeam_o365jobs.py index 89cdba2..f229f1f 100644 --- a/agent_based/veeam_o365jobs.py +++ b/agent_based/veeam_o365jobs.py @@ -21,6 +21,8 @@ # 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 dataclasses import dataclass +from typing import Optional from cmk.agent_based.v2 import ( Service, Result, @@ -29,8 +31,9 @@ render, CheckPlugin, RuleSetType, + StringTable, + AgentSection, ) -from .agent_based_api.v1.type_defs import StringTable VEEAM_O365JOBS_CHECK_DEFAULT_PARAMETERS = { 'states': { @@ -83,7 +86,7 @@ def parse_veeam_o365jobs(string_table: StringTable) -> dict[str, VeeamO365Job]: return parsed -register.agent_section( +agent_section_veeam_o365jobs = AgentSection( name='veeam_o365jobs', parse_function=parse_veeam_o365jobs, ) diff --git a/tests/unit/agent_based/test_veeam_o356jobs.py b/tests/unit/agent_based/test_veeam_o356jobs.py index a4b8c2f..d077a51 100644 --- a/tests/unit/agent_based/test_veeam_o356jobs.py +++ b/tests/unit/agent_based/test_veeam_o356jobs.py @@ -166,7 +166,7 @@ def test_discovery_veeam_o365jobs(params, section, result): ] ), ( - 'cmk.onmicrosoft.com Outlook Online3', {'jobId': '23456789-abcd-ef01-2345-6789abcdef01', 'duration': (500, 600)}, + 'cmk.onmicrosoft.com Outlook Online3', {'jobId': '23456789-abcd-ef01-2345-6789abcdef01', 'duration': ('fixed', (500, 600))}, [ Result(state=State.OK, summary='Running since: 5 minutes 14 seconds'), Result(state=State.OK, notice='Last Success: 1 day 1 hour'), @@ -174,7 +174,7 @@ def test_discovery_veeam_o365jobs(params, section, result): ] ), ( - 'cmk.onmicrosoft.com Outlook Online3', {'jobId': '23456789-abcd-ef01-2345-6789abcdef01', 'duration': (120, 600)}, + 'cmk.onmicrosoft.com Outlook Online3', {'jobId': '23456789-abcd-ef01-2345-6789abcdef01', 'duration': ('fixed', (120, 600))}, [ Result(state=State.WARN, summary='Running since: 5 minutes 14 seconds (warn/crit at 2 minutes 0 seconds/10 minutes 0 seconds)'), Result(state=State.OK, notice='Last Success: 1 day 1 hour'), @@ -182,7 +182,7 @@ def test_discovery_veeam_o365jobs(params, section, result): ] ), ( - 'cmk.onmicrosoft.com Outlook Online3', {'jobId': '23456789-abcd-ef01-2345-6789abcdef01', 'duration': (120, 300)}, + 'cmk.onmicrosoft.com Outlook Online3', {'jobId': '23456789-abcd-ef01-2345-6789abcdef01', 'duration': ('fixed', (120, 300))}, [ Result(state=State.CRIT, summary='Running since: 5 minutes 14 seconds (warn/crit at 2 minutes 0 seconds/5 minutes 0 seconds)'), Result(state=State.OK, notice='Last Success: 1 day 1 hour'), @@ -190,7 +190,7 @@ def test_discovery_veeam_o365jobs(params, section, result): ] ), ( - 'cmk.onmicrosoft.com Outlook Online', {'jobId': '01234567-89ab-cdef-0123-456789abcdef', 'success_maxage': (1800, 504000)}, + 'cmk.onmicrosoft.com Outlook Online', {'jobId': '01234567-89ab-cdef-0123-456789abcdef', 'success_maxage': ('fixed', (1800, 504000))}, [ Result(state=State.OK, summary='Status: Success'), Result(state=State.OK, summary='Transferred Items: 191.00'), @@ -204,7 +204,7 @@ def test_discovery_veeam_o365jobs(params, section, result): ] ), ( - 'cmk.onmicrosoft.com Outlook Online', {'jobId': '01234567-89ab-cdef-0123-456789abcdef', 'success_maxage': (1800, 3600)}, + 'cmk.onmicrosoft.com Outlook Online', {'jobId': '01234567-89ab-cdef-0123-456789abcdef', 'success_maxage': ('fixed', (1800, 3600))}, [ Result(state=State.OK, summary='Status: Success'), Result(state=State.OK, summary='Transferred Items: 191.00'), @@ -218,7 +218,7 @@ def test_discovery_veeam_o365jobs(params, section, result): ] ), ( - 'cmk.onmicrosoft.com Outlook Online3', {'jobId': '23456789-abcd-ef01-2345-6789abcdef01', 'success_maxage': (86400, 504000)}, + 'cmk.onmicrosoft.com Outlook Online3', {'jobId': '23456789-abcd-ef01-2345-6789abcdef01', 'success_maxage': ('fixed', (86400, 504000))}, [ Result(state=State.OK, summary='Running since: 5 minutes 14 seconds'), Result(state=State.WARN, summary='Last Success: 1 day 1 hour (warn/crit at 1 day 0 hours/5 days 20 hours)'),