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

XML Custom EXE\Script Sensor: string as value?

Votes:

0

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

customsensor powershell value

Created on Mar 24, 2021 1:41:18 PM

Last change on Mar 24, 2021 2:54:51 PM by  Florian Lesage [Paessler Support]



5 Replies

Votes:

0

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.

Created on Mar 25, 2021 6:45:48 AM by  Florian Lesage [Paessler Support]

Last change on Mar 25, 2021 6:45:59 AM by  Florian Lesage [Paessler Support]



Votes:

0

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.

Created on Mar 25, 2021 7:29:11 AM



Votes:

0

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.

Created on Mar 25, 2021 7:41:10 AM by  Florian Lesage [Paessler Support]



Votes:

0

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

Created on Mar 25, 2021 2:02:47 PM

Last change on Mar 25, 2021 2:09:10 PM by  Florian Lesage [Paessler Support]



Votes:

0

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.

Created on Mar 25, 2021 2:28:05 PM by  Florian Lesage [Paessler Support]

Last change on Mar 25, 2021 2:28:34 PM by  Florian Lesage [Paessler Support]




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.