Hallo zusammen,
ich habe diese Woche bei uns mal versucht von V1.6 auf V2.0 des Docker Containers der Enterprise Version zu wechseln. Soweit hat auch das Grundlegende funktioniert, nur bei meinen Custom SNMP-Checks, fliegt er mir irgendwie auf die Nase und ich weiß nicht so ganz warum. Theoretisch sollten die ja auch weiterhin funktionieren, wenn ich nicht irre?
Beispielsweise dieser Check:
def inventory_hsm_cpu_temp(info):
return[(“Temp”,None)]
def check_hsm_cpu_temp(item, params, info):
return check_temperature(
float(info[0][0]),
params,
'temperature',
dev_levels=(95, 100),
dev_levels_lower=(5, 0)
)
check_info["hsm_cpu_temp"] = {
"check_function": check_hsm_cpu_temp,
"inventory_function": inventory_hsm_cpu_temp,
"service_description": "HSM CPU %s",
"has_perfdata" : True,
"snmp_info": (".1.3.6.1.4.1.3159.1.1", [ "11"]),
"group" : "temperature",
"includes" : ["temperature.include"],
}
Schlägt fehl mit:
OMD[spcm]:~/local/share/check_mk/checks$ cmk -vv --debug --checks hsm_cpu_temp hostname
Precompile /omd/sites/spcm/local/share/check_mk/checks/temperature.include to /omd/sites/spcm/var/check_mk/precompiled_checks/local/temperature.include
Error in check include file /omd/sites/spcm/local/share/check_mk/checks/temperature.include: [Errno 2] No such file or directory: ‘/omd/sites/spcm/local/share/check_mk/checks/temperature.include’
Error in plugin file /omd/sites/spcm/local/share/check_mk/checks/hsm_cpu_temp: [Errno 2] No such file or directory: ‘/omd/sites/spcm/local/share/check_mk/checks/temperature.include’
Try aquire lock on /omd/sites/spcm/var/check_mk/crashes/base/0a87a8a4-a8ea-11eb-a0f1-0242ac110002/crash.info
Got lock on /omd/sites/spcm/var/check_mk/crashes/base/0a87a8a4-a8ea-11eb-a0f1-0242ac110002/crash.info
Releasing lock on /omd/sites/spcm/var/check_mk/crashes/base/0a87a8a4-a8ea-11eb-a0f1-0242ac110002/crash.info
Released lock on /omd/sites/spcm/var/check_mk/crashes/base/0a87a8a4-a8ea-11eb-a0f1-0242ac110002/crash.info
Traceback (most recent call last):
File “/omd/sites/spcm/bin/cmk”, line 79, in
errors = config.load_all_agent_based_plugins(check_api.get_check_api_context)
File “/omd/sites/spcm/lib/python3/cmk/base/config.py”, line 1415, in load_all_agent_based_plugins
errors.extend(load_checks(get_check_api_context, filelist))
File “/omd/sites/spcm/lib/python3/cmk/base/config.py”, line 1493, in load_checks
did_compile |= load_check_includes(f, check_context)
File “/omd/sites/spcm/lib/python3/cmk/base/config.py”, line 1610, in load_check_includes
did_compile |= load_precompiled_plugin(include_file_path, check_context)
File “/omd/sites/spcm/lib/python3/cmk/base/config.py”, line 1774, in load_precompiled_plugin
py_compile.compile(path, precompiled_path, doraise=True)
File “/omd/sites/spcm/lib/python3.8/py_compile.py”, line 142, in compile
source_bytes = loader.get_data(file)
File “”, line 972, in get_data
FileNotFoundError: [Errno 2] No such file or directory: ‘/omd/sites/spcm/local/share/check_mk/checks/temperature.include’
Zusätzlich kommt auch noch der Hinweis auf Werk 10601, dass das automatische Umwandeln auf die neue API nicht funktioniert hat.
Mein Versuch das ganze in die neue API zu gießen sieht bisher so aus:
#!/usr/bin/env python3
# -- coding: utf-8 --
# Copyright (C) 2019 tribe29 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.base.plugins.agent_based.agent_based_api.v1 import *
register.snmp_section(
name = “cslCPUTemperature”,
detect = contains(".1.3.6.1.4.1.3159", “Utimaco”),
fetch = SNMPTree(
base = ‘.1.3.6.1.4.1.3159.1.1’,
oids = [
‘12.0’, #cslCPUTemp
],
),
)
Scheitert dann aber hier:
OMD[spcm]:~/local/lib/check_mk/base/plugins/agent_based$ ./cpu_temp.py
Traceback (most recent call last):
File “./cpu_temp.py”, line 9, in
register.snmp_section(
File “/omd/sites/spcm/lib/python3/cmk/base/api/agent_based/register/export.py”, line 233, in snmp_section
module=get_validated_plugin_module_name(),
File “/omd/sites/spcm/lib/python3/cmk/base/api/agent_based/register/utils.py”, line 51, in get_validated_plugin_module_name
raise ImportError(“do not register from %r” % path)
ImportError: do not register from PosixPath(‘cpu_temp.py’)
Bin ich irgendwo einmal komplett falsch abgebogen?
Kann mir jemand helfen, das ganze zum Laufen zu bringen?
Soweit ich es bisher habe, hab ich mir anhand der Doku und der Standard-SNMP-Checks zusammengebastelt.
Vielen Dank