checkmk icon indicating copy to clipboard operation
checkmk copied to clipboard

Escape newline when truncating notification variables

Open mayrstefan opened this issue 1 month ago • 0 comments

General information

When notification variables get truncated we only see "...". The additional text "Attention: Removed remaining content because it was too long." is missing because it is in a new line. Host/Service output uses "\\n" instead of "\n". So the added text needs to escape the slash too.

Bug reports

Please include:

  • Detailed steps to reproduce the bug
  1. use a local check to simulate a service with very long output
#!/bin/bash
cat <<EOF
<<<local>>>
0 "longoutput" - short output\nlong output\n$(for i in {1..128000}; do echo -n "x"; done)
EOF
  1. Use the example script from https://docs.checkmk.com/latest/en/notifications.html?lquery=notifications#scripts
  2. change the notification script to change state
  3. look into the output of the notification script

Proposed changes

Escape the slash to generate "\\n" as output

mayrstefan avatar Nov 16 '25 21:11 mayrstefan