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

Return largest file name and size to sensor

Votes:

0

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...

filename filesize powershell

Created on Mar 29, 2020 4:39:40 PM



1 Reply

Votes:

0

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://kb.paessler.com/en/topic/71356-guide-for-powershell-based-custom-sensors

Kind Regards,
Timo Dambach
Paessler Tech Support

Created on Mar 30, 2020 8:44:32 AM by  Timo Dambach [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.