diff --git a/cmk/gui/plugins/wato/check_parameters/graylog_alerts.py b/cmk/gui/plugins/wato/check_parameters/graylog_alerts.py deleted file mode 100644 index 31d49b60c34..00000000000 --- a/cmk/gui/plugins/wato/check_parameters/graylog_alerts.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2 -# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and -# conditions defined in the file COPYING, which is part of this source code package. - -from cmk.gui.i18n import _ -from cmk.gui.plugins.wato.utils import ( - CheckParameterRulespecWithoutItem, - rulespec_registry, - RulespecGroupCheckParametersApplications, -) -from cmk.gui.valuespec import Dictionary, Integer, Tuple - - -def _parameter_valuespec_graylog_alerts(): - return Dictionary( - elements=[ - ( - "alerts_upper", - Tuple( - title=_("Total alerts count upper levels"), - elements=[ - Integer(title=_("Warning at")), - Integer(title=_("Critical at")), - ], - ), - ), - ( - "alerts_lower", - Tuple( - title=_("Total alerts count lower levels"), - elements=[ - Integer(title=_("Warning below")), - Integer(title=_("Critical below")), - ], - ), - ), - ( - "alerts_in_range_upper", - Tuple( - title=_("Number of alerts in defined timespan upper level"), - elements=[ - Integer(title=_("Warning below"), unit="alerts"), - Integer(title=_("Critical below"), unit="alerts"), - ], - ), - ), - ( - "alerts_in_range_lower", - Tuple( - title=_("Number of alerts in defined timespan lower level"), - elements=[ - Integer(title=_("Warning at"), unit="alerts"), - Integer(title=_("Critical at"), unit="alerts"), - ], - ), - ), - ], - ) - - -rulespec_registry.register( - CheckParameterRulespecWithoutItem( - check_group_name="graylog_alerts", - group=RulespecGroupCheckParametersApplications, - match_type="dict", - parameter_valuespec=_parameter_valuespec_graylog_alerts, - title=lambda: _("Graylog alerts"), - ) -) diff --git a/cmk/plugins/collection/agent_based/graylog_alerts.py b/cmk/plugins/collection/agent_based/graylog_alerts.py deleted file mode 100644 index 29be8aedbd4..00000000000 --- a/cmk/plugins/collection/agent_based/graylog_alerts.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2 -# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and -# conditions defined in the file COPYING, which is part of this source code package. - -import json -from collections.abc import Mapping -from dataclasses import dataclass -from typing import Any - -from cmk.agent_based.v1 import check_levels as check_levels_v1 -from cmk.agent_based.v2 import ( - AgentSection, - CheckPlugin, - CheckResult, - DiscoveryResult, - render, - Service, - StringTable, -) - -# <<>> -# {"alerts": {"num_of_alerts": 0, "has_since_argument": false, "alerts_since": null, "num_of_alerts_in_range": 0}} - -# <<>> -# {"alerts": {"num_of_alerts": 5, "has_since_argument": true, "alerts_since": 1800, "num_of_alerts_in_range": 2}} - - -@dataclass -class AlertsInfo: - num_of_alerts: int - has_since_argument: bool - alerts_since: int | None - num_of_alerts_in_range: int - - -def parse_graylog_alerts(string_table: StringTable) -> AlertsInfo | None: - alerts_section = json.loads(string_table[0][0]) - if len(alerts_section) != 1: - return None - - alerts_data = alerts_section.get("alerts") - - return AlertsInfo( - num_of_alerts=alerts_data.get("num_of_alerts"), - has_since_argument=alerts_data.get("has_since_argument"), - alerts_since=alerts_data.get("alerts_since"), - num_of_alerts_in_range=alerts_data.get("num_of_alerts_in_range"), - ) - - -agent_section_graylog_alerts = AgentSection( - name="graylog_alerts", - parse_function=parse_graylog_alerts, -) - - -def discover_graylog_alerts(section: AlertsInfo) -> DiscoveryResult: - yield Service(item=None) - - -def check_graylog_alerts(params: Mapping[str, Any], section: AlertsInfo) -> CheckResult: - yield from check_levels_v1( - value=section.num_of_alerts, - levels_upper=params.get("alerts_upper", (None, None)), - levels_lower=params.get("alerts_lower", (None, None)), - render_func=lambda x: str(int(x)), - label="Total number of alerts", - ) - - if section.has_since_argument and section.alerts_since: - yield from check_levels_v1( - value=section.num_of_alerts_in_range, - levels_upper=params.get("alerts_in_range_upper", (None, None)), - levels_lower=params.get("alerts_in_range_lower", (None, None)), - render_func=lambda x: str(int(x)), - label=f"Total number of alerts in the last {render.timespan(section.alerts_since)}", - ) - - -check_plugin_graylog_alerts = CheckPlugin( - name="graylog_alerts", - check_function=check_graylog_alerts, - discovery_function=discover_graylog_alerts, - service_name="Graylog Cluster Alerts", - check_default_parameters={}, - check_ruleset_name="graylog_alerts", -) diff --git a/cmk/plugins/graylog/__init__.py b/cmk/plugins/graylog/__init__.py new file mode 100644 index 00000000000..c42b91132bf --- /dev/null +++ b/cmk/plugins/graylog/__init__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. diff --git a/cmk/plugins/graylog/agent_based/__init__.py b/cmk/plugins/graylog/agent_based/__init__.py new file mode 100644 index 00000000000..c42b91132bf --- /dev/null +++ b/cmk/plugins/graylog/agent_based/__init__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. diff --git a/cmk/plugins/graylog/agent_based/alerts.py b/cmk/plugins/graylog/agent_based/alerts.py new file mode 100644 index 00000000000..7a04df6571e --- /dev/null +++ b/cmk/plugins/graylog/agent_based/alerts.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. + +""" +Kuhn & Rueß GmbH +Consulting and Development +https://kuhn-ruess.de + +""" + +from collections.abc import Mapping +from json import loads +from typing import Any, NamedTuple + +from cmk.agent_based.v2 import ( + AgentSection, + check_levels, + CheckPlugin, + CheckResult, + DiscoveryResult, + Service, + StringTable, +) + +# <<>> +# {"alerts": {"num_of_events": 547, "num_of_alerts": 4}} + +# <<>> +# {"alerts": {"num_of_events": 5, "num_of_alerts": 0}} + + +class AlertsInfo(NamedTuple): + num_of_events: int + num_of_alerts: int + + +def parse_graylog_alerts(string_table: StringTable) -> AlertsInfo | None: + """ + Parse JSON data to AlertsInfo + """ + alerts_section = loads(string_table[0][0]) + + if len(alerts_section) != 1: + return None + + alerts_data = alerts_section.get("alerts") + + return AlertsInfo( + num_of_events=alerts_data.get("num_of_events"), + num_of_alerts=alerts_data.get("num_of_alerts"), + ) + + +agent_section_graylog_alerts = AgentSection( + name="graylog_alerts", + parse_function=parse_graylog_alerts, +) + + +def discover_graylog_alerts(section: AlertsInfo) -> DiscoveryResult: + """ + Discover one service + """ + if section: + yield Service(item=None) + + +def check_graylog_alerts(params: Mapping[str, Any], section: AlertsInfo) -> CheckResult: + for which in ["alerts", "events"]: + yield from check_levels( + value=(section._asdict())[f"num_of_{which}"], + levels_upper=params.get(f"{which}_upper", None), + levels_lower=params.get(f"{which}_lower", None), + metric_name=f"graylog_{which}", + render_func=lambda x: str(int(x)), + label=f"Total number of {which}", + ) + + +check_plugin_graylog_alerts = CheckPlugin( + name="graylog_alerts", + sections=["graylog_alerts"], + service_name="Graylog Cluster Alerts", + discovery_function=discover_graylog_alerts, + check_function=check_graylog_alerts, + check_default_parameters={}, + check_ruleset_name="graylog_alerts", +) diff --git a/cmk/plugins/collection/checkman/graylog_alerts b/cmk/plugins/graylog/checkman/graylog_alerts similarity index 58% rename from cmk/plugins/collection/checkman/graylog_alerts rename to cmk/plugins/graylog/checkman/graylog_alerts index b5b28aa67b7..a893d50c48b 100644 --- a/cmk/plugins/collection/checkman/graylog_alerts +++ b/cmk/plugins/graylog/checkman/graylog_alerts @@ -1,12 +1,13 @@ -title: Graylog: Sources +title: Graylog: Alerts agents: graylog catalog: app/graylog license: GPLv2 distribution: check_mk description: - This check plug-in monitors the count of alerts a Graylog - instance. It outputs the total number of alerts. - You can also configure the check plug-in to monitor the number of alerts in a given timeframe. + This check plug-in monitors the count of alerts and events of a Graylog + instance. It outputs the total number of alerts and events. + You can also configure the check plug-in to monitor the number of alerts + and events in a given timeframe. You would do that by configuring the "Time for coverage of alerts" option when configuring the Graylog special agent. @@ -14,4 +15,4 @@ item: Does not have an item. discovery: - One service is created. \ No newline at end of file + One service is created. diff --git a/cmk/plugins/graylog/graphing/__init__.py b/cmk/plugins/graylog/graphing/__init__.py new file mode 100644 index 00000000000..c42b91132bf --- /dev/null +++ b/cmk/plugins/graylog/graphing/__init__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. diff --git a/cmk/plugins/graylog/graphing/alerts.py b/cmk/plugins/graylog/graphing/alerts.py new file mode 100644 index 00000000000..ea72a644aab --- /dev/null +++ b/cmk/plugins/graylog/graphing/alerts.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +""" +Kuhn & Rueß GmbH +Consulting and Development +https://kuhn-ruess.de +""" + +from cmk.graphing.v1 import Title +from cmk.graphing.v1.graphs import Graph +from cmk.graphing.v1.metrics import Color, DecimalNotation, Metric, Unit + +UNIT_NUMBER = Unit(DecimalNotation("")) + +metric_graylog_alerts = Metric( + name="graylog_alerts", + title=Title("Total amount of alerts"), + unit=UNIT_NUMBER, + color=Color.BLUE, +) +metric_graylog_events = Metric( + name="graylog_events", + title=Title("Total amount of events"), + unit=UNIT_NUMBER, + color=Color.GREEN, +) + +graph_graylog_alerts = Graph( + name="gralog_alerts", + title=Title("Graylog alerts and events"), + simple_lines=["graylog_alerts", "graylog_events"], +) diff --git a/cmk/plugins/graylog/rulesets/__init__.py b/cmk/plugins/graylog/rulesets/__init__.py new file mode 100644 index 00000000000..c42b91132bf --- /dev/null +++ b/cmk/plugins/graylog/rulesets/__init__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. diff --git a/cmk/plugins/graylog/rulesets/alerts.py b/cmk/plugins/graylog/rulesets/alerts.py new file mode 100644 index 00000000000..9ec98f4e2cc --- /dev/null +++ b/cmk/plugins/graylog/rulesets/alerts.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +""" +Kuhn & Rueß GmbH +Consulting and Development +https://kuhn-ruess.de +""" + +from cmk.rulesets.v1 import Title +from cmk.rulesets.v1.form_specs import ( + DictElement, + Dictionary, + InputHint, + Integer, + LevelDirection, + SimpleLevels, +) +from cmk.rulesets.v1.rule_specs import CheckParameters, HostCondition, Topic + + +def _parameter_form_graylog_alerts(): + return Dictionary( + title=Title("Graylog alerts"), + elements={ + "alerts_upper": DictElement( + parameter_form=SimpleLevels( + title=Title("Total alerts count upper levels"), + level_direction=LevelDirection.UPPER, + form_spec_template=Integer(), + prefill_fixed_levels=InputHint((0, 0)), + ) + ), + "alerts_lower": DictElement( + parameter_form=SimpleLevels( + title=Title("Total alerts count lower levels"), + level_direction=LevelDirection.LOWER, + form_spec_template=Integer(), + prefill_fixed_levels=InputHint((0, 0)), + ) + ), + "events_upper": DictElement( + parameter_form=SimpleLevels( + title=Title("Total events count upper levels"), + level_direction=LevelDirection.UPPER, + form_spec_template=Integer(), + prefill_fixed_levels=InputHint((0, 0)), + ) + ), + "events_lower": DictElement( + parameter_form=SimpleLevels( + title=Title("Total events count lower levels"), + level_direction=LevelDirection.LOWER, + form_spec_template=Integer(), + prefill_fixed_levels=InputHint((0, 0)), + ) + ), + }, + ) + + +rule_spec_graylog_alerts = CheckParameters( + name="graylog_alerts", + topic=Topic.APPLICATIONS, + condition=HostCondition(), + parameter_form=_parameter_form_graylog_alerts, + title=Title("Graylog alerts"), +) diff --git a/cmk/plugins/graylog/server_side_calls/__init__.py b/cmk/plugins/graylog/server_side_calls/__init__.py new file mode 100644 index 00000000000..c42b91132bf --- /dev/null +++ b/cmk/plugins/graylog/server_side_calls/__init__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. diff --git a/cmk/plugins/graylog/server_side_calls/special_agent.py b/cmk/plugins/graylog/server_side_calls/special_agent.py index 05fe03495ac..9e4e272df66 100644 --- a/cmk/plugins/graylog/server_side_calls/special_agent.py +++ b/cmk/plugins/graylog/server_side_calls/special_agent.py @@ -41,15 +41,15 @@ class Params(BaseModel): def commands_function(params: Params, host_config: HostConfig) -> Iterable[SpecialAgentCommand]: command_arguments: list[str | Secret] = [ - "-P", + "--proto", params.protocol, - "-m", + "--sections", ",".join(params.sections), - "-t", + "--since", f"{params.since:.0f}", - "-u", + "--user", params.user, - "-s", + "--password", params.password.unsafe(), "--display_node_details", params.display_node_details, @@ -60,7 +60,7 @@ def commands_function(params: Params, host_config: HostConfig) -> Iterable[Speci ] if params.port: - command_arguments += ["-p", f"{params.port}"] + command_arguments += ["--port", f"{params.port}"] if params.source_since: command_arguments += ["--source_since", f"{params.source_since:.0f}"] diff --git a/cmk/special_agents/agent_graylog.py b/cmk/special_agents/agent_graylog.py index 3d90c256474..2c9c436e9f9 100644 --- a/cmk/special_agents/agent_graylog.py +++ b/cmk/special_agents/agent_graylog.py @@ -34,7 +34,7 @@ def main(argv=None): # Add new queries here sections = [ - GraylogSection(name="alerts", uri="/streams/alerts?limit=300"), + GraylogSection(name="alerts", uri="/events/search"), GraylogSection(name="cluster_health", uri="/system/indexer/cluster/health"), GraylogSection(name="cluster_inputstates", uri="/cluster/inputstates"), GraylogSection(name="cluster_stats", uri="/system/cluster/stats"), @@ -70,6 +70,14 @@ def handle_request(args, sections): # pylint: disable=too-many-branches if section.name == "events": value = handle_response(url, args, "POST").json() + + elif section.name == "alerts": + content = { + "filter": {"alerts": "include"}, + "timerange": {"type": "relative", "range": args.alerts_since}, + } + value = handle_response(url, args, "POST", args.alerts_since, content).json() + else: value = handle_response(url, args).json() @@ -156,24 +164,19 @@ def handle_request(args, sections): # pylint: disable=too-many-branches handle_output([events], section.name, args) if section.name == "alerts": - num_of_alerts = value.get("total", 0) - num_of_alerts_in_range = 0 - alerts_since_argument = args.alerts_since - - if alerts_since_argument: - url_alerts_in_range = f"{url}%since={str(alerts_since_argument)}" - num_of_alerts_in_range = ( - handle_response(url_alerts_in_range, args).json().get("total", 0) - ) + num_of_events = value.get("total_events", 0) - alerts = { - "alerts": { - "num_of_alerts": num_of_alerts, - "has_since_argument": bool(alerts_since_argument), - "alerts_since": alerts_since_argument if alerts_since_argument else None, - "num_of_alerts_in_range": num_of_alerts_in_range, - } + content = { + "filter": {"alerts": "only"}, + "timerange": {"type": "relative", "range": args.alerts_since}, } + value = handle_response(url, args, "POST", args.alerts_since, content).json() + + num_of_alerts = value.get("total_events", 0) + num_of_events -= num_of_alerts + + alerts = {"alerts": {"num_of_events": num_of_events, "num_of_alerts": num_of_alerts}} + handle_output([alerts], section.name, args) if section.name == "sources": @@ -218,18 +221,31 @@ def handle_request(args, sections): # pylint: disable=too-many-branches handle_output(value, section.name, args) -def handle_response(url, args, method="GET", events_since=86400): +def handle_response(url, args, method="GET", events_since=86400, content=None): if method == "POST": try: - response = requests.post( # nosec B113 # BNS:0b0eac - url, - auth=(args.user, args.password), - headers={ - "Content-Type": "application/json", - "X-Requested-By": args.user, - }, - json={"timerange": {"type": "relative", "range": events_since}}, - ) + if content: + response = requests.post( # nosec B113 # BNS:0b0eac + url, + auth=(args.user, args.password), + headers={ + "Content-Type": "application/json", + "X-Requested-By": args.user, + }, + json=content, + ) + + else: + response = requests.post( # nosec B113 + url, + auth=(args.user, args.password), + headers={ + "Content-Type": "application/json", + "X-Requested-By": args.user, + }, + json={"timerange": {"type": "relative", "range": events_since}}, + ) + except requests.exceptions.RequestException as e: sys.stderr.write("Error: %s\n" % e) if args.debug: diff --git a/tests/unit/cmk/plugins/collection/agent_based/test_graylog_alerts.py b/tests/unit/cmk/plugins/collection/agent_based/test_graylog_alerts.py deleted file mode 100644 index 7fc191b5000..00000000000 --- a/tests/unit/cmk/plugins/collection/agent_based/test_graylog_alerts.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2022 Checkmk GmbH - License: GNU General Public License v2 -# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and -# conditions defined in the file COPYING, which is part of this source code package. - -from collections.abc import Sequence - -import pytest - -from cmk.agent_based.v1.type_defs import StringTable -from cmk.agent_based.v2 import Result, State -from cmk.plugins.collection.agent_based.graylog_alerts import ( - check_graylog_alerts, - parse_graylog_alerts, -) - - -@pytest.mark.parametrize( - "section, expected_check_result", - [ - pytest.param( - [ - [ - '{"alerts": {"num_of_alerts": 0, "has_since_argument": false, "alerts_since": null, "num_of_alerts_in_range": 0}}' - ] - ], - [Result(state=State.OK, summary="Total number of alerts: 0")], - id="Timeframe for 'alerts_since' not configured.", - ), - pytest.param( - [ - [ - '{"alerts": {"num_of_alerts": 5, "has_since_argument": true, "alerts_since": 1800, "num_of_alerts_in_range": 2}}' - ] - ], - [ - Result(state=State.OK, summary="Total number of alerts: 5"), - Result( - state=State.OK, - summary="Total number of alerts in the last 30 minutes 0 seconds: 2", - ), - ], - id="Timeframe for 'alerts_since' configured. Now the check gives information about the total number of alerts received in the timeframe.", - ), - ], -) -def test_check_graylog_alerts( - section: StringTable, - expected_check_result: Sequence[Result], -) -> None: - parsed_section = parse_graylog_alerts(section) - assert parsed_section - assert ( - list( - check_graylog_alerts( - params={}, - section=parsed_section, - ) - ) - == expected_check_result - ) - - -def test_parse_graylog_alerts_empty_alerts_section() -> None: - section = [['{"total": 0, "alerts": []}']] - parsed_section = parse_graylog_alerts(section) - assert parsed_section is None diff --git a/tests/unit/cmk/plugins/graylog/agent_based/test_graylog_alerts.py b/tests/unit/cmk/plugins/graylog/agent_based/test_graylog_alerts.py new file mode 100644 index 00000000000..afdd15b590c --- /dev/null +++ b/tests/unit/cmk/plugins/graylog/agent_based/test_graylog_alerts.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +# Copyright (C) 2022 Checkmk GmbH - License: GNU General Public License v2 +# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and +# conditions defined in the file COPYING, which is part of this source code package. + +from collections.abc import Sequence + +import pytest + +from cmk.agent_based.v1.type_defs import StringTable +from cmk.agent_based.v2 import Metric, Result, State +from cmk.plugins.graylog.agent_based.alerts import ( + check_graylog_alerts, + parse_graylog_alerts, +) + + +@pytest.mark.parametrize( + "section, expected_check_result", + [ + pytest.param( + [['{"alerts": {"num_of_events": 0, "num_of_alerts": 0}}']], + [ + Result(state=State.OK, summary="Total number of alerts: 0"), + Metric("graylog_alerts", 0.0), + Result(state=State.OK, summary="Total number of events: 0"), + Metric("graylog_events", 0.0), + ], + id="No alerts and events.", + ), + pytest.param( + [['{"alerts": {"num_of_events": 53, "num_of_alerts": 0}}']], + [ + Result(state=State.OK, summary="Total number of alerts: 0"), + Metric("graylog_alerts", 0.0), + Result(state=State.OK, summary="Total number of events: 53"), + Metric("graylog_events", 53.0), + ], + id="Events exists and no alerts.", + ), + pytest.param( + [['{"alerts": {"num_of_events": 0, "num_of_alerts": 5}}']], + [ + Result(state=State.OK, summary="Total number of alerts: 5"), + Metric("graylog_alerts", 5.0), + Result(state=State.OK, summary="Total number of events: 0"), + Metric("graylog_events", 0.0), + ], + id="Alerts exists and no events.", + ), + pytest.param( + [['{"alerts": {"num_of_events": 63, "num_of_alerts": 7}}']], + [ + Result(state=State.OK, summary="Total number of alerts: 7"), + Metric("graylog_alerts", 7.0), + Result(state=State.OK, summary="Total number of events: 63"), + Metric("graylog_events", 63.0), + ], + id="Events and alerts exists.", + ), + ], +) +def test_check_graylog_alerts( + section: StringTable, + expected_check_result: Sequence[Result], +) -> None: + parsed_section = parse_graylog_alerts(section) + assert parsed_section + assert ( + list( + check_graylog_alerts( + params={}, + section=parsed_section, + ) + ) + == expected_check_result + ) + + +def test_parse_graylog_alerts_empty_alerts_section() -> None: + section = [['{"num_of_events": 0, "num_of_alerts": 0}']] + parsed_section = parse_graylog_alerts(section) + assert parsed_section is None diff --git a/tests/unit/cmk/plugins/graylog/server_side_calls/test_agent_graylog.py b/tests/unit/cmk/plugins/graylog/server_side_calls/test_agent_graylog.py index 4585a7aa728..144daf356e2 100644 --- a/tests/unit/cmk/plugins/graylog/server_side_calls/test_agent_graylog.py +++ b/tests/unit/cmk/plugins/graylog/server_side_calls/test_agent_graylog.py @@ -34,15 +34,15 @@ ), SpecialAgentCommand( command_arguments=[ - "-P", + "--proto", "https", - "-m", + "--sections", "alerts", - "-t", + "--since", "1800", - "-u", + "--user", "user", - "-s", + "--password", Secret(id=1, format="%s", pass_safely=False), "--display_node_details", "host",