CMK version:
2.2.0p28
OS version:
Debian 6.1.0-20-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.85-1 (2024-04-11) x86_64 GNU/Linux
Error message:
"‘name’ not in globals
Output of “cmk --debug -vvn hostname”: (If it is a problem with checks or plugins)
Error in plugin file /omd/sites/demo5g/local/share/check_mk/checks/airspan_api.py: "'__name__' not in globals"
Trying to acquire lock on /omd/sites/demo5g/var/check_mk/crashes/base/c6f96b50-4a7f-11ef-860b-000c2977a675/crash.info
Got lock on /omd/sites/demo5g/var/check_mk/crashes/base/c6f96b50-4a7f-11ef-860b-000c2977a675/crash.info
Releasing lock on /omd/sites/demo5g/var/check_mk/crashes/base/c6f96b50-4a7f-11ef-860b-000c2977a675/crash.info
Released lock on /omd/sites/demo5g/var/check_mk/crashes/base/c6f96b50-4a7f-11ef-860b-000c2977a675/crash.info
Traceback (most recent call last):
File "/omd/sites/demo5g/bin/cmk", line 97, in <module>
errors = config.load_all_agent_based_plugins(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/omd/sites/demo5g/lib/python3/cmk/base/config.py", line 1669, in load_all_agent_based_plugins
errors.extend(load_checks(get_check_api_context, filelist))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/omd/sites/demo5g/lib/python3/cmk/base/config.py", line 1739, in load_checks
did_compile |= load_precompiled_plugin(f, check_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/omd/sites/demo5g/lib/python3/cmk/base/config.py", line 2033, in load_precompiled_plugin
exec(marshal.loads(Path(precompiled_path).read_bytes()[_PYCHeader.SIZE :]), check_context)
File "/omd/sites/demo5g/local/share/check_mk/checks/airspan_api.py", line 6, in <module>
from .agent_based_api.v1 import check_levels, Metric, register, Result, Service, State
KeyError: "'__name__' not in globals"
ich habe ein Check Plugin erstellt entspr. https://docs.checkmk.com/latest/en/devel_check_plugins.html:
#!/usr/bin/env python3
from .agent_based_api.v1 import check_levels, Metric, register, Result, Service, State
def parse_airspan_api(string_table):
parsed = {}
for line in string_table:
parsed[line[0]] = {"alarm_counters": line[1]}
print(parsed)
return parsed
def discover_airspan_api(section):
for gnb in section:
yield Service(item=gnb)
def check_airspan_api(item,section):
attr = section.get(item)
yield Result(state=State.OK, summary=f"alarm counters: {attr['alarm_counters']}")
register.agent_section(
name = "airspan_api",
parse_function = parse_airspan_api,
)
register.check_plugin(
name = "airspan_api",
sections = ["airspan_api"],
service_name = "gnb %s",
discovery_function = discover_airspan_api,
check_function = check_airspan_api,
)
'''
als check für "other Integrations"->"Individual program call instead of agent access" abgelegt unter "~/local/lib/check_mk/base/plugins/agent_based/" funktioniert es.
Wenn ich den gleichen check für einen special agent benutzen möchte, lege ich ihn entspr. https://digaround.cloud/check-mk-create-own-special-agent/ unter "~/local/share/check_mk/checks" ab und bekomme den Fehler.
scheinbar muss ich für den import
`from .agent_based_api.v1 import check_levels, Metric, register, Result, Service, State`
was anderes angeben ... aber was?
vielen Dank
Torsten