1

I have written a script and it is printing multiline output. But in nagios it is showing only one line. Does anyone know how to print multilines in Nagios

Rajesh
  • 13
  • 1
  • 7

2 Answers2

2

Multiline ouput is possible only with Nagios 3 and newer.
First of all, you can use html tag <br/> for each new line of desired output.
Next important thing is disable HTML tag escaping in your cgi.cfg on Nagios server.
Find escape_html_tags=1 and change to escape_html_tags=0.
Then you restart Nagios server.

Some advice about Nagios plugins output can be found here: https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/pluginapi.html

PS: By default Nagios will only read the first 4 KB of data that a plugin returns.

Rohlik
  • 1,286
  • 19
  • 28
  • 1
    This solution may also be used to workaround the currently broken (as of thruk 2.44.3) interpretation of "\n" in submit check result command for passive service checks (such as snmp traps). See https://github.com/naemon/naemon-core/issues/144 – Ashark Sep 15 '21 at 14:34
1

Yes! I agree, multiline output is possible only with Nagios 3 and above. However your do not need to send <br/> tags to achieve this. You can simply end each line with '\r\n'. Use the following format.

DISK OK - free space: / 3326 MB (56%); | /=2643MB;5948;5958;0;5968
/ 15272 MB (77%);
/boot 68 MB (69%);
/home 69357 MB (27%);
/var/log 819 MB (84%); | /boot=68MB;88;93;0;98
/home=69357MB;253404;253409;0;253414
/var/log=818MB;970;975;0;980

The performance data is optional. Even the following format is acceptable. (Note that each line end with a \r\n)

Weather OK - Temperature OK: 22 C
Humidity (77%) | Temp=22;35;39;40; Humidity=77;80;90;99;

For more details, check the official documentation on multiline output. https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/pluginapi.html

Shawn
  • 2,679
  • 2
  • 15
  • 26