What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Single quotes in message break notification script

Votes:

1

Hello,

I know about https://kb.paessler.com/en/topic/75261-single-quote-in-sensor-message-breaks-notification-script

Is there a solution for this problem?

We have sensors that reports messages like:

- Error recorder "Foo" is down.
- Failed to connect. Please check the SSH log of the target device or try the Compatibility Mode of the sensor's SSH engine and consider updating the target system's operating system.

As you see, one message contains a double quote and the other a single quote, which makes effective quoting impossible.

Is there a way to modify the SSH sensor messages ourselves? That way we can remove the single quotes from PRTG's messages.

That or you introduce a %powershell_message placeholder that is properly escaped.

IMHO the best way to solve this is to stop using placeholders but provide the parameters as environment variables instead. That way any script can use the environment any way it likes.

notification prtg quotes scripts

Created on Mar 15, 2022 9:31:11 AM

Last change on Mar 16, 2022 9:52:24 AM by  Felix Wiesneth [Paessler Support]



14 Replies

Votes:

0

The recommendation is to use '%message' for powershell and "%message" for other script, which suggest that it's escaped for the double quote character, is that correct?

If yes I'm thinking of a .bat file workaround that would call the powershell script, can you describe *exactly* how the Notification Script is called and what escaping is done to the placeholders?

Created on Mar 16, 2022 1:21:25 PM



Votes:

0

Hi there,

The notification script is called from the PRTG Core server when the corresponding notification template is executed. During this the PRTG Core Server process starts the script as sub-process.

Created on Mar 18, 2022 7:57:41 AM by  Moritz Heller [Paessler Support]



Votes:

0

@Moritz Heller: thanks, and what escaping is done to %message? no escaping at all?

Created on Mar 21, 2022 6:33:24 AM



Votes:

0

Hi there,

we recommend to submit placeholders in single quotes like '%host'

Created on Mar 21, 2022 1:23:57 PM by  Moritz Heller [Paessler Support]



Votes:

0

Yes, that fails when the placeholder contains a single quote.

This whole post is about that.

Created on Mar 21, 2022 3:16:29 PM



Votes:

0

In this case, there is no workaround which I can recommend at the moment. Maybe you can create a workaround which first re-format the placeholder and then they are used in your notification script

Created on Mar 24, 2022 9:24:10 AM by  Moritz Heller [Paessler Support]



Votes:

0

In order to make a workaround I need to know what escaping is done to "%message".

It seems that there is none.

Created on Mar 24, 2022 9:44:40 AM



Votes:

0

I just discovered https://www.paessler.com/manuals/prtg/custom_sensors#environment

This should fix the issue, simply set the environment variables instead of trying to pass the values.

Created on Mar 24, 2022 3:46:02 PM



Votes:

0

Argh, this is not available for notifications :-(

Created on Mar 24, 2022 3:56:48 PM



Votes:

0

The placeholders values are simply replaced with the placeholders.For example, Your device uses the IP/DNS "localhost". If you use the placeholder %host, the placeholder would be replaced with localhost.

Created on Mar 25, 2022 9:17:14 AM by  Moritz Heller [Paessler Support]



Votes:

1

Please consider "Set placeholders as environment values" for notification scripts.

In the meantime as there is no escaping done to the placeholders it means we should be able to escape them, how is the script called? with `cmd.exe /c`? With `WinExec()`? With `CreateProcess()`?

Depending how it is called maybe we can do the escaping at the DOS level, otherwise we'll need to do it in the script.

Created on Mar 28, 2022 5:25:00 AM



Votes:

0

Hi there,

I informed myself and it should be cmd.exe /c

Created on Mar 30, 2022 2:03:09 PM by  Moritz Heller [Paessler Support]



Votes:

1

I found a simpler workaround: only pass the sensor id to the notification script and get the sensor data through https://github.com/lordmilko/PrtgAPI.

But please please consider implementing "Set placeholders as environment values" for notification scripts, and not just EXE/XML sensors.

Created on Apr 4, 2022 2:16:19 PM



Votes:

1

I have the same problem and agree that the "Set placeholders as environment values" option should be available for notifications aswell.

Created on Nov 1, 2022 1:16:48 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.