I need to monitor a specific directory for the largest file of a few types (*.dbf, *.fpt, *.cdx) and return size and name to PRTG.

I have a PS script working to determine the file, but I'm not clear on how to return just the name and size to PRTG:

PS C:\Windows\system32> Get-ChildItem d:\apps\int\data\* -include ('*.dbf', '*.fpt','*.cdx') | Sort Length -desc | Select-Object -first 1

So - how do I grab name and size and return them to PRTG? Seems I need to write-host a JSON return string but I'm not sure how to get the size and name from what I have so far...


Article Comments

Attention: This article is a record of a conversation with the Paessler support team. The information in this conversation is not updated to preserve the historical record. As a result, some of the information or recommendations in this conversation might be out of date.

Hello,

The output of the script has to be as expected by PRTG. You can find the proper output syntax in your Webinterface under "Setup > PRTG API > Custom Sensors" or within our online manual: https://www.paessler.com/manuals/prtg/custom_sensor

An example for the normal "EXE/Script Sensor" would be: "value:message"

An example for the "EXE/Script Advanced" would be: "<prtg><result><channel>First channel</channel><value>10</value></result></prtg>"

This article may also be of interest for you: https://helpdesk.paessler.com/en/support/solutions/articles/76000041700-guide-for-powershell-based-custom-sensors

Kind Regards,
Timo Dambach
Paessler Tech Support


Mar, 2020 - Permalink