checkmk
checkmk copied to clipboard
Escape newline when truncating notification variables
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
- 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
- Use the example script from https://docs.checkmk.com/latest/en/notifications.html?lquery=notifications#scripts
- change the notification script to change state
- look into the output of the notification script
Proposed changes
Escape the slash to generate "\\n" as output