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 (no data)

Votes:

0

When performing a custom sensor and attempting to display the value of a variable, it shows 0.

# Obtener el tamaño del archivo 
$SizeArchivo = (Get-Item $ServerArchivo).Length

#mandar datos a PRTG
"<prtg>"
    "<result>"
    "<channel>Free size disc</channel>"
    "<unit>BytesDisk</unit>"
    "<value>$SizeArchivo</value>"
    "</result>"
"</prtg>"

custom exe powershell prtg script xml

Created on Apr 1, 2023 11:06:03 AM



3 Replies

Votes:

0

What is the value you are especting to receive?

For example, if the value you are expecting is a "string", then the issue in this code is that the value of the $SizeArchivo variable is not being properly formatted as a string, which can cause it to display as 0 in the output. To fix this, you can explicitly convert the value to a string using the ToString() method, like so:

# get file size
$SizeArchivo = (Get-Item $ServerArchivo).Length


#send data to PRTG
"<prtg>"
    "<result>"
    "<channel>Free size disc</channel>"
    "<unit>BytesDisk</unit>"
    "<value>" + $SizeArchivo.ToString() + "</value>"
    "</result>"
"</prtg>"

By using the ToString() method, the value of $SizeArchivo will be properly converted to a string that can be displayed correctly in the PRTG output.

Created on Apr 6, 2023 6:43:41 PM by  Ivan Escalante [Paessler Support]



Votes:

0

El problema que veo es que si muestra el dato de tamaño del archivo al monitorear un archivo local (en el servidor del PRTG) pero cuando quiero monitorear un archivo de otro servidor me muestra el dato en 0, el usuario utilizado es administrador de dominio, ejecuto este script en powershell y me muestra bien los datos, pero en PRTG me da el valor en 0

----------------------------ENGLISH---------------------------------------------------

The problem I see is that when monitoring a local file (on the PRTG server) it displays the file size data correctly. However, when trying to monitor a file on another server, it shows the data as 0. The user being used is a domain administrator, and when I run this script in PowerShell, it shows the data correctly. But in PRTG, it gives me a value of 0.

Created on Jun 13, 2023 12:21:10 PM



Votes:

0

LISTO, el problema era la opcion: Choose a security context to run the EXE/script file.

Created on Jun 13, 2023 12:46:51 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.