Skip to content

Commit

Permalink
never discover string params XX: checks/{u,v}*
Browse files Browse the repository at this point in the history
Change-Id: I754ed8e8edd9653f1ad7392b1ea2f0de13b534b7
  • Loading branch information
mo-ki committed Apr 6, 2023
1 parent 812bf5f commit 6ae78dc
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 75 deletions.
1 change: 0 additions & 1 deletion checks/hr_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.cpu_util import * # pylint: disable=wildcard-import,unused-wildcard-import
from cmk.base.check_legacy_includes.ucd_hr import * # pylint: disable=wildcard-import,unused-wildcard-import
from cmk.base.plugins.agent_based.utils import ucd_hr_detection

# .1.3.6.1.2.1.25.3.3.1.2.768 1 --> HOST-RESOURCES-MIB::hrProcessorLoad.768
Expand Down
4 changes: 0 additions & 4 deletions checks/ucd_cpu_util
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.cpu_util import * # pylint: disable=wildcard-import,unused-wildcard-import

# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.ucd_hr import * # pylint: disable=wildcard-import,unused-wildcard-import
from cmk.base.plugins.agent_based.utils import ucd_hr_detection

# UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 219998591
Expand Down
4 changes: 0 additions & 4 deletions checks/ucd_disk
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.df import * # pylint: disable=wildcard-import,unused-wildcard-import

# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.ucd_hr import * # pylint: disable=wildcard-import,unused-wildcard-import
from cmk.base.plugins.agent_based.utils import ucd_hr_detection

# .1.3.6.1.4.1.2021.9.1.2.1 / --> UCD-SNMP-MIB::dskPath.1
Expand Down
4 changes: 0 additions & 4 deletions checks/ucd_mem
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.mem import * # pylint: disable=wildcard-import,unused-wildcard-import

# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.ucd_hr import * # pylint: disable=wildcard-import,unused-wildcard-import
from cmk.base.plugins.agent_based.utils import ucd_hr_detection

# FIXME
Expand Down
3 changes: 0 additions & 3 deletions checks/ucd_processes
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# 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.

# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.ucd_hr import * # pylint: disable=wildcard-import,unused-wildcard-import
from cmk.base.plugins.agent_based.utils import ucd_hr_detection

# .1.3.6.1.4.1.2021.2.1.2.1 Web-Processes --> UCD-SNMP-MIB::prNames.1
Expand Down
2 changes: 1 addition & 1 deletion checks/ups_bat_temp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def inventory_ups_bat_temp(info):
# 2nd condition is needed to catch some UPS devices which do not have
# any temperature sensor but report a 0 as upsBatteryTemperature. Skip those lines
if len(info) > 0 and saveint(info[0][1]) != 0:
return [(format_item_ups_bat_temp(line[0], True), "ups_bat_temp_default") for line in info]
return [(format_item_ups_bat_temp(line[0], True), {}) for line in info]
return []


Expand Down
11 changes: 10 additions & 1 deletion checks/ups_out_voltage
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# 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 typing import Iterable

# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.ups_generic import * # pylint: disable=wildcard-import,unused-wildcard-import
Expand All @@ -11,9 +13,16 @@ from cmk.base.plugins.agent_based.utils.ups import DETECT_UPS_GENERIC

ups_out_voltage_default_levels = (210, 180) # warning / critical


def discover_ups_out_voltage(info: list[list[str]]) -> Iterable[tuple[str, tuple[int, int]]]:
yield from (
(item, ups_out_voltage_default_levels) for item, value, *_rest in info if int(value) > 0
)


check_info["ups_out_voltage"] = {
"detect": DETECT_UPS_GENERIC,
"inventory_function": discover(lambda line: int(line[1]) > 0, "ups_out_voltage_default_levels"),
"inventory_function": discover_ups_out_voltage,
"check_function": check_ups_out_voltage,
"service_description": "OUT voltage phase %s",
"group": "evolt",
Expand Down
2 changes: 1 addition & 1 deletion checks/ups_socomec_out_voltage
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ups_out_voltage_default_levels = (210, 180) # warning / critical

def inventory_socomec_ups_out_voltage(info):
if len(info) > 0:
return [(x[0], "ups_out_voltage_default_levels") for x in info if int(x[1]) > 0]
return [(x[0], ups_out_voltage_default_levels) for x in info if int(x[1]) > 0]
return []


Expand Down
29 changes: 0 additions & 29 deletions cmk/base/check_legacy_includes/ucd_hr.py

This file was deleted.

30 changes: 3 additions & 27 deletions cmk/base/check_legacy_includes/ups_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,9 @@
# conditions defined in the file COPYING, which is part of this source code package.


def ups_generic_scan_function(oid):
# migration in progress: if you want to port this function in the new
# checkapi use the existing one in
# cmk/base/plugins/agent_based/utils/ups.py
return (
oid(".1.3.6.1.2.1.1.2.0")
in [
".1.3.6.1.4.1.232.165.3",
".1.3.6.1.4.1.476.1.42",
".1.3.6.1.4.1.534.1",
".1.3.6.1.4.1.935",
".1.3.6.1.4.1.8072.3.2.10",
".1.3.6.1.4.1.2254.2.5",
".1.3.6.1.4.1.12551.4.0",
]
or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.2.1.33")
or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.534.2")
or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5491")
or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.705.1")
or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.818.1.100.1")
or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.935")
)


def discovery_ups_generic(info, default_levels_name):
def discovery_ups_generic(info, default_levels):
return [
(idx, default_levels_name) #
for idx, raw_voltage, _raw_value in info #
(idx, default_levels)
for idx, raw_voltage, _raw_value in info
if raw_voltage and int(raw_voltage)
]

0 comments on commit 6ae78dc

Please sign in to comment.