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"
7-
86import time
7+ from collections .abc import Mapping
8+ from typing import Any
99
10- from cmk .agent_based .legacy .v0_unstable import LegacyCheckDefinition
11- from cmk .agent_based .v2 import equals , get_value_store , OIDEnd , SNMPTree , StringTable
10+ from cmk .agent_based .v2 import (
11+ CheckPlugin ,
12+ CheckResult ,
13+ DiscoveryResult ,
14+ equals ,
15+ get_value_store ,
16+ OIDEnd ,
17+ Service ,
18+ SimpleSNMPSection ,
19+ SNMPTree ,
20+ StringTable ,
21+ )
1222from cmk .plugins .lib .cpu_util import check_cpu_util
1323
14- check_info = {}
15-
1624
17- def discover_arris_cmts_cpu (info ) :
18- for oid_id , cpu_id , _cpu_idle_util in info :
25+ def discover_arris_cmts_cpu (section : StringTable ) -> DiscoveryResult :
26+ for oid_id , cpu_id , _cpu_idle_util in section :
1927 # Sadly the cpu_id seams empty. Referring to
2028 # the MIB, its slot id
2129 # Fallback to the oid end
22- yield cpu_id or str (int (oid_id ) - 1 ), {}
30+ yield Service ( item = cpu_id or str (int (oid_id ) - 1 ))
2331
2432
25- def check_arris_cmts_cpu (item , params , info ) :
26- for oid_id , cpu_id , cpu_idle_util in info :
33+ def check_arris_cmts_cpu (item : str , params : Mapping [ str , Any ], section : StringTable ) -> CheckResult :
34+ for oid_id , cpu_id , cpu_idle_util in section :
2735 # see inventory function
2836 if cpu_id :
2937 citem = cpu_id
@@ -46,14 +54,19 @@ def parse_arris_cmts_cpu(string_table: StringTable) -> StringTable:
4654 return string_table
4755
4856
49- check_info [ "arris_cmts_cpu" ] = LegacyCheckDefinition (
57+ snmp_section_arris_cmts_cpu = SimpleSNMPSection (
5058 name = "arris_cmts_cpu" ,
51- parse_function = parse_arris_cmts_cpu ,
5259 detect = equals (".1.3.6.1.2.1.1.2.0" , ".1.3.6.1.4.1.4998.2.1" ),
5360 fetch = SNMPTree (
5461 base = ".1.3.6.1.4.1.4998.1.1.5.3.1.1.1" ,
5562 oids = [OIDEnd (), "1" , "8" ],
5663 ),
64+ parse_function = parse_arris_cmts_cpu ,
65+ )
66+
67+
68+ check_plugin_arris_cmts_cpu = CheckPlugin (
69+ name = "arris_cmts_cpu" ,
5770 service_name = "CPU utilization Module %s" ,
5871 discovery_function = discover_arris_cmts_cpu ,
5972 check_function = check_arris_cmts_cpu ,
0 commit comments