Hello, how can I output a string as a value in the sensor (Powershell) ? For example, I want to display a computer name as a value. Is that possible ?

Example:

"<prtg>"
"<result>"
"<channel>Logincounter</channel>" 
"<value>$LoginCounter</value>"
"<unit>Number</unit>" 
"</result>"
"<result>"
"<channel>TopHost</channel>" 
"<value>$TopHostname</value>"
"<unit>Text</unit>" 
"</result>"
"<Text>$Text</Text>" 
"</prtg>"

The second part does not work like that. But is there a possibility?

Regards, Coyo


Article Comments

Hello,

Thank you for your message.

Regarding your question, I'm afraid that it is not possible to send string values in PRTG, but only integer or float. However, in this case you have the possibility to display the string in the sensor message field with <Text>$Text</Text>.

Here is the manual regarding custom sensors: https://www.paessler.com/manuals/prtg/custom_sensors

If you have questions, let us know.

Regards.


Mar, 2021 - Permalink

since only numerical values are possible, I tend to use the result text as channel name and then a numerical value to either represent the count (as in your example) or for normal/warning/error thresholds.

so in your example: "<channel>$TopHostname</channel>" "<value>$LoginCounter</value>"

if the TopHostname changes, the sensor will add new channels on it's own or update the data if the TopHostname will recur.

another posibility is, as Paessler Support stated, to use the <text> to return strings. I do so for Exchange Versions. My script will determine if the server is up2date and return a 0, 1 or 2 for the state and in the <text> the absolute build number.


Mar, 2021 - Permalink

Hello Volker,

Regarding your question with the channels, PRTG will create a new one if the hostname changes, the old one won't receive any data anymore. Of course, it is possible to hide it in both Graph and Table with the corresponding options in the channel settings.

Then, you are indeed right regarding the other possibility, this is a good approach that we also recommend in such case.

Have a nice day.


Mar, 2021 - Permalink

Hi, thanks Volker, that's a great idea. I can use that in another sensor. :)

In my case, the string changes too often. Florian has explained the problem well. I am evaluating the LDAP queries against our DCs and wanted to show the top originator. In the text box above, it's already in there, including source IP. But there I have no history of the values.

Is it possible to write values from sensor to a log inside prtg?

Regards


Mar, 2021 - Permalink

Hello,

Thank you for your feedback.

Regarding the sensor message, I'm afraid that there are effectively not stored in the database and there is no option to do so.

Therefore, I would recommend to extract the value by using the API of PRTG, by executing this request:

https://PRTGSERVER/api/table.json?content=sensors&columns=objid,name,message&count=*&filter_objid=SENSORID&username=PRTGUSER&passhash=PASSHASH

With a script executed with a scheduled task every scan interval + 5 seconds, you could then get this data and then store it in a file/database, etc. However, there is no possibility to analyze it and configure alerts in PRTG as long as it's a string.

Regards.


Mar, 2021 - Permalink