Skip to content

mk_sap: apply host_prefix to logwatch piggyback #937

Open
Simon0Harms wants to merge 1 commit into
Checkmk:masterfrom
Simon0Harms:prefix
Open

mk_sap: apply host_prefix to logwatch piggyback #937
Simon0Harms wants to merge 1 commit into
Checkmk:masterfrom
Simon0Harms:prefix

Conversation

@Simon0Harms

Copy link
Copy Markdown

General information

Affected plugin: agents/plugins/mk_sap.py — the SAP R/3 agent plugin that
collects CCMS data via RFC (pyrfc) and emits it as piggyback blocks keyed by the
SAP System ID (SID). The host_prefix option prepends a string to the piggyback
host name.

This is a platform-independent issue (a Python string-formatting inconsistency);
it was observed on SLES 15 SP7 with pyrfc and NW RFC SDK 7.50, but does not depend
on the OS.

Bug report

  • Operating system: SLES 15 SP7 (issue is OS-independent)

  • Local setup: two SAP systems sharing the same SID (an ECC and an S/4HANA system).
    host_prefix is used to give each source's piggyback data a distinct host name.

  • Steps to reproduce:

    1. Set host_prefix in /etc/check_mk/sap.cfg, e.g. "host_prefix": "S4H_".
    2. Run the plugin so that it produces both a <<<sap>>> section and a
      <<<logwatch>>> section (i.e. at least one MTE_MSG_CONTAINER with alerts).
    3. Inspect the emitted piggyback headers.
  • Agent output (illustrative, with host_prefix = "S4H_"):

    Observed (current behavior):

<<<<S4H_SB1>>>>
<<sap:sep(9)>>

<<<<>>>>
<<<<SB1>>>>            <-- logwatch header WITHOUT the prefix
<<<logwatch>>>

The SAP section and the logwatch section end up on two different piggyback
hosts (S4H_SB1 vs. SB1).

Proposed changes

  • Expected behavior: with host_prefix set, both the sap section and the
    logwatch section are written under the same (prefixed) piggyback host.
  • Observed behavior: only the SAP data header includes the prefix; the logwatch
    header omits it. In check(), the SAP block writes
    "<<<<%s%s>>>>\n" % (cfg_entry.get("host_prefix", ""), host) while the logwatch
    block writes "<<<<%s>>>>\n" % host, dropping the prefix.
  • Change: apply the same host_prefix formatting to the logwatch header so both
    sections share one piggyback host.
  • Is this a new problem? No — a longstanding inconsistency. It surfaces when
    host_prefix is used, which is the natural way to disambiguate systems that
    share a SID.
  • Unit test: a test that runs the output stage with a non-empty host_prefix and
    asserts that both the sap and the logwatch piggyback headers carry the
    prefix would have failed before this fix.

The host_prefix config option in mk_sap is currently only applied to the SAP
value section header, but not to the logwatch section header. As a result, the two
sections end up on different piggyback hosts when host_prefix is set.
Where
In check(), the SAP data block writes the header as:
"<<<<%s%s>>>>\n" % (cfg_entry.get("host_prefix", ""), host)
while the logwatch block writes:
"<<<<%s>>>>\n" % host
— dropping the prefix.
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Simon0Harms Simon0Harms mentioned this pull request Jul 14, 2026
@Simon0Harms

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants