33# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
44# conditions defined in the file COPYING, which is part of this source code package.
55
6- # mypy: disable-error-code="no-untyped-def"
76# mypy: disable-error-code="type-arg"
8-
9-
107# mypy: disable-error-code="arg-type"
118
12- from collections .abc import Iterable
9+ from collections .abc import Mapping , Sequence
10+ from typing import Any
1311
14- from cmk .agent_based .legacy .v0_unstable import check_levels , LegacyCheckDefinition
12+ from cmk .agent_based .legacy .v0_unstable import (
13+ check_levels ,
14+ LegacyCheckDefinition ,
15+ LegacyCheckResult ,
16+ LegacyDiscoveryResult ,
17+ LegacyService ,
18+ )
1519from cmk .agent_based .v2 import render
1620from cmk .plugins .graylog .lib import deserialize_and_merge_json , GraylogSection
1721
5761# "alarmcallback_count_by_type": {}}}']]
5862
5963
60- def discover_graylog_cluster_stats (section : GraylogSection ) -> Iterable [ tuple [ None , dict ]] :
64+ def discover_graylog_cluster_stats (section : GraylogSection ) -> LegacyDiscoveryResult :
6165 if section :
6266 yield None , {}
6367
6468
65- def check_graylog_cluster_stats (_no_item , params , parsed ):
69+ def check_graylog_cluster_stats (
70+ _no_item : None , params : Mapping [str , Any ], parsed : GraylogSection
71+ ) -> LegacyCheckResult :
6672 if not parsed :
6773 return
6874
@@ -93,18 +99,18 @@ def check_graylog_cluster_stats(_no_item, params, parsed):
9399)
94100
95101
96- def discover_graylog_cluster_stats_elastic (parsed ) :
102+ def discover_graylog_cluster_stats_elastic (parsed : GraylogSection ) -> Sequence [ LegacyService ] :
97103 elastic_data = parsed .get ("elasticsearch" )
98104 if elastic_data is not None :
99105 return [(None , {})]
100106 return []
101107
102108
103109def check_graylog_cluster_stats_elastic (
104- _no_item ,
105- params ,
106- parsed ,
107- ):
110+ _no_item : None ,
111+ params : Mapping [ str , Any ] ,
112+ parsed : GraylogSection ,
113+ ) -> LegacyCheckResult :
108114 elastic_data = parsed .get ("elasticsearch" )
109115 if elastic_data is None :
110116 return
@@ -121,7 +127,7 @@ def check_graylog_cluster_stats_elastic(
121127
122128 status_data = elastic_data .get ("status" )
123129 if status_data :
124- yield params .get (status_data .lower ()), "Status: %s" % status_data .title ()
130+ yield params .get (status_data .lower (), 3 ), "Status: %s" % status_data .title ()
125131
126132 health_data = elastic_data .get ("cluster_health" )
127133 if health_data :
@@ -202,14 +208,16 @@ def check_graylog_cluster_stats_elastic(
202208)
203209
204210
205- def discover_graylog_cluster_stats_mongodb (parsed ) :
211+ def discover_graylog_cluster_stats_mongodb (parsed : GraylogSection ) -> Sequence [ LegacyService ] :
206212 mongo_data = parsed .get ("mongo" )
207213 if mongo_data is not None :
208214 return [(None , {})]
209215 return []
210216
211217
212- def check_graylog_cluster_stats_mongodb (_no_item , params , parsed ):
218+ def check_graylog_cluster_stats_mongodb (
219+ _no_item : None , params : Mapping [str , Any ], parsed : GraylogSection
220+ ) -> LegacyCheckResult :
213221 mongo_data = parsed .get ("mongo" )
214222 if mongo_data is None :
215223 return
0 commit comments