Which characters in a Nagios plugin output need escaping other than pipe (|)?

How do I escape the pipe character and others?


The development guidelines do not specify a way to escape the |

The syntax of the first line is fix and not very flexible

SERVICE STATUS: First line of output | First part of performance data

and then in section 2.6 (Performance Data)

Nagios 3 and newer will concatenate the parts following a "|" in a) the first line output by the plugin, and b) in the second to last line, into a string it passes to whatever performance data processing it has configured.

I would then assume that if you have a | in the First line of output part it will just interpreted as the beginning of the performance data.

Since the first line of output is not interpreted (up to the |) I would also assume that no characters have to be specially handled.


As already mentioned, the | character is a reserved one to seperate plugin output from performance datas.

There is actually no way to escape it.

Regarding escaping other characters : Nagios uses STDOUT to display the plugin output. This means that it will display it as is.

However there is an exception for the \ character. You will have to escape it with an extra \.

For example, to display c:\Windows\system32 your plugin output should be c:\\Windows\\system32.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.