Mk_logwatch_2.py causes "Check_MK Discovery" to crash

Hey,

CMK version: 2.0.0p33 (CEE)
OS version: Ubuntu 20.04.6 LTS

at the moment we are moving old hosts from our 1.6 server to the new one.
I’ve installed the new 2.0 agent on our host (SLES 11 SP4) and now I see 2 logwatch plugins (mk_logwatch.py and mk_logwatch_2.py).

The problem is, the “mk_logwatch_2.py” causes the “Check_MK Discovery” Service of that host to crash:

Error message:

Check_MK Discovery
check failed - please submit a crash report! (Crash-ID: 463f9d5e-f63e-11ed-9089-2f86efd076b0)

Exception
error (bad escape \l at position 4)

I’ve tried both:

Agent rules:

  • [Python agent plugin execution (UNIX)]
  • [Install Python runtime environment]

can’t fine any option that would solve the problem :frowning:

The agent-output is showing:

<<<logwatch>>>
[[[/XXX/log/ntp/ntp.log]]]
[[[/var/log/messages]]]
C Maximum number (50000) of new log messages exceeded.
<<<sshd_config>>>

If I delete the the output has no logwatch section anymore, and the error is gone too.
The “mk_logwatch.py” does notwork because there’s no python3 on the host.

I can start the plugin without any error:

HOST:/usr/lib/check_mk_agent/plugins # ./mk_logwatch_2.py
<<<logwatch>>>
HOST:/usr/lib/check_mk_agent/plugins #

Josef

Output of “cmk --debug -vvn hostname”: (If it is a problem with checks or plugins)

is this the actual output (i.e. the XXX) or did you shorten something here? If you can’t share it publicly, but since you have the CEE (and maybe a support contract?) I would suggest opening a support ticket with the crash report. (Or first updating to 2.1 if you want to make sure the bug hasn’t already been fixed :))

that’s the whole logwatch part output, I just anonymized the folder name (XXX). Are there bugs that just have been fixes in 2.1? I thought fixes come to all supported versions.

updating to 2.1.0p29 did not fix the problem =(

  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/decorator.py", line 43, in wrapped_check_func
    status, output_text = _combine_texts(check_func(hostname, *args, **kwargs))
  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/discovery/__init__.py", line 581, in active_check_discovery
    services = _get_host_services(
  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/discovery/__init__.py", line 1030, in _get_host_services
    **_get_node_services(
  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/discovery/__init__.py", line 1055, in _get_node_services
    service_result = analyse_discovered_services(
  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 46, in analyse_discovered_services
    discovered_services=_discover_services(
  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 145, in _discover_services
    {
  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 145, in <dictcomp>
    {
  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 280, in _discover_plugins_services
    yield from (
  File "/omd/sites/vls/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 280, in <genexpr>
    yield from (
  File "/omd/sites/vls/lib/python3/cmk/base/api/agent_based/register/check_plugins.py", line 74, in filtered_generator
    for element in generator(*args, **kwargs):
  File "/omd/sites/vls/lib/python3/cmk/base/plugins/agent_based/logwatch.py", line 120, in discover_logwatch_groups
    not_forwarded_logs = logwatch.select_forwarded(
  File "/omd/sites/vls/lib/python3/cmk/base/plugins/agent_based/utils/logwatch.py", line 106, in select_forwarded
    return {
  File "/omd/sites/vls/lib/python3/cmk/base/plugins/agent_based/utils/logwatch.py", line 107, in <setcomp>
    item for item in items if ec_forwarding_enabled(forward_settings[0], item) is not invert
  File "/omd/sites/vls/lib/python3/cmk/base/plugins/agent_based/utils/logwatch.py", line 93, in ec_forwarding_enabled
    return any(re.match(pattern, item) for pattern in params["restrict_logfiles"])
  File "/omd/sites/vls/lib/python3/cmk/base/plugins/agent_based/utils/logwatch.py", line 93, in <genexpr>
    return any(re.match(pattern, item) for pattern in params["restrict_logfiles"])
  File "/omd/sites/vls/lib/python3.9/re.py", line 191, in match
    return _compile(pattern, flags).match(string)
  File "/omd/sites/vls/lib/python3.9/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/omd/sites/vls/lib/python3.9/sre_compile.py", line 788, in compile
    p = sre_parse.parse(p, flags)
  File "/omd/sites/vls/lib/python3.9/sre_parse.py", line 955, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/omd/sites/vls/lib/python3.9/sre_parse.py", line 444, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/omd/sites/vls/lib/python3.9/sre_parse.py", line 526, in _parse
    code = _escape(source, this, state)
  File "/omd/sites/vls/lib/python3.9/sre_parse.py", line 427, in _escape
    raise source.error("bad escape %s" % escape, len(escape))

Josef

We found the problem today together with CMK.

We used the “Logwatch Event Console Forwarding” rule.

There the path for
“Restrict Logfiles”
and
“List of expected logfiles”

was: “\var\log\messages”.
we changed it to “\\var\\log\\messages

:slight_smile: thanks for the great help

Josef

1 Like

/var/log/messages is a linux file path - why was the backslash instead of the forward slash used as the path seperator at all?

3 Likes

That’s a good question :smiley:
I did’t see the wrong slashes until your comment …
Guess it was a mistake
Thanks :slight_smile:

Josef