Hello,

I know about https://helpdesk.paessler.com/en/support/solutions/articles/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.


Article Comments

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?


Mar, 2022 - Permalink

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.


Mar, 2022 - Permalink

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


Mar, 2022 - Permalink

Hi there,

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


Mar, 2022 - Permalink

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

This whole post is about that.


Mar, 2022 - Permalink

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


Mar, 2022 - Permalink

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

It seems that there is none.


Mar, 2022 - Permalink

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.


Mar, 2022 - Permalink

Argh, this is not available for notifications :-(


Mar, 2022 - Permalink

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.


Mar, 2022 - Permalink

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.


Mar, 2022 - Permalink

Hi there,

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


Mar, 2022 - Permalink

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.


Apr, 2022 - Permalink

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


Nov, 2022 - Permalink