Escaping characters in the message

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
devnull
Posts: 5
Joined: Tue Aug 18, 2015 4:00 pm

Escaping characters in the message

Post by devnull »

is there a way to escape characters like "|" in the message.

sample message:

[1439925251] PROCESS_SERVICE_CHECK_RESULT;localhost;TSERVICE;2;TEST123|456
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Escaping characters in the message

Post by hsmith »

devnull wrote:is there a way to escape characters like "|" in the message.

sample message:

[1439925251] PROCESS_SERVICE_CHECK_RESULT;localhost;TSERVICE;2;TEST123|456
What exactly are you trying to do, just make it so the | does not show up?
Former Nagios Employee.
me.
devnull
Posts: 5
Joined: Tue Aug 18, 2015 4:00 pm

Re: Escaping characters in the message

Post by devnull »

it only shows TEST123

but if the value of $SERVICEOUTPUT$ is TEST123|456 ACB DEF:HIJ FOO|BAR|TEST|THIS|IS|LONG|Blah: GHJD

notification doesn't even execute
devnull
Posts: 5
Joined: Tue Aug 18, 2015 4:00 pm

Re: Escaping characters in the message

Post by devnull »

ooopss.. i wanted to show all characters in $SERVICEOUTPUT$ including the pipes.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Escaping characters in the message

Post by Box293 »

Your plugin should only be returning one pipe in the output.

The pipe is what separates the status information from the performance data.

This is why you only see TEST123

https://nagios-plugins.org/doc/guidelines.html#AEN200
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
devnull
Posts: 5
Joined: Tue Aug 18, 2015 4:00 pm

Re: Escaping characters in the message

Post by devnull »

Are there a list of characters that nagios doesnt allow in the $SERVICEOUTPUT$
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Escaping characters in the message

Post by tmcdonald »

Former Nagios employee
devnull
Posts: 5
Joined: Tue Aug 18, 2015 4:00 pm

Re: Escaping characters in the message

Post by devnull »

thanks..
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Escaping characters in the message

Post by tmcdonald »

You can of course edit that list, but remember that the pipe character has special meaning in Nagios. I tried escaping it with a backslash but it had no effect.
Former Nagios employee
Locked