2

I have a nagios plugin which puts out JSON in it's mutliline output. For example:

Thresholds: {
  "crit": [
    "and",
      [ "<", "blah", [ "*", "blah_avg", 0.5 ] ],
      [ ">", "hour_of_day", 7 ]
  ]
}

Renders in the check_mk UI as

Thresholds: {
"crit": [
"and",
[ "<", "blah", [ "*", "blah_avg", 0.5 ] ],
[ ">", "hour_of_day", 7 ]
]
}

I've got similar problems with sending out emails, but for now I'd like to at least fix it here. Any suggestions? At this point I'm considering replacing the initial spaces with underscores.

Ramfjord
  • 872
  • 8
  • 14

1 Answers1

0

If it is possible to modify the output, you may want to try enclosing the entire output in HTML 'pre' tags. Such as:

<pre>
Thresholds: {
  "crit": [
    "and",
      [ "<", "blah", [ "*", "blah_avg", 0.5 ] ],
      [ ">", "hour_of_day", 7 ]
  ]
}
</pre>

That should preserve the outputs spacing in the web UI and in your email client.

Jim Black
  • 1,422
  • 1
  • 13
  • 26
  • Is it important that the _whole_ plugin output text to be wrapped by pre tags? It does not work for me when I wrap only the part with whitespaces. – Ashark Dec 14 '20 at 12:33
  • Probably, also need to turn off escaping of html tags, as described here: https://stackoverflow.com/questions/45640167/print-more-than-one-line-output-in-nagios – Ashark Dec 14 '20 at 12:37