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

Sensor to monitor maximum size of files in a folder

Votes:

0

Hello,

TLDR: I'm looking for a sensor which can monitor a maximum allowed file size of all files within a folder.

Long version: we started using FsLogix for our RDS farm deployments. As you might know the default size of user's container is 30 GB. We want to monitor all the user containers in the containers folder in a way that PRTG gives a warning when any file (container) reaches for example 25 GB in size.

I had a look at the default sensors for file and folder but I can't achieve what I want. Windows file screen is probably a solution but I prefer PRTG since file screen would result in monitoring outside of PRTG.

Any suggestions?

file-size fslogix prtg rds userprofile

Created on Mar 23, 2020 12:46:09 PM



5 Replies

Votes:

0

Hello there,

Thank you for your post.

Did you try our File Sensor?
If this does not fulfill your requirement, then the only solution would be to write a custom script and use it in a EXE/Script sensor.


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Mar 23, 2020 1:55:13 PM by  Sasa Ignjatovic [Paessler Support]



Votes:

0

Hi,

I created a script that does just that: It lists the largest file in a folder or its subfolders.

The problem is that the script works just fine when run in PowerShell in any context, but always returns "0:OK" when called from PRTG.

Call from PRTG with parameters: -path "F:\"

Script: param ( $path="C:\" ) $file = Get-ChildItem -Recurse -Path $path | Where-Object { !$_.PSIsContainer } | Select-Object -Property @{Name='Size';Expression={$_.Length}} | Sort-Object { $_.Size } -Descending | Select-Object -first 1 Write-Host "$(([Math]::Round($file.Size/1GB)).ToString()) :OK" exit 0

Created on Mar 24, 2020 10:11:29 AM



Votes:

0

Hello,

Thank you for sharing your script here. I tried running the script manually in Powershell as well but also just received "0:OK" as response. Please try again running the script manually on your PRTG server (and with the same path that is also configured in PRTG) and send us a screenshot of the result at [email protected], so that we can take a closer look here. Please refer to this KB article in your e-mail.

Thanks.

Created on Mar 24, 2020 11:05:39 AM by  Timo Dambach [Paessler Support]



Votes:

0

Hi,

The script does return a value that is the largest file in Gb, and the value is trucated, so if you have no large files, 0 :OK is the expected result. (0.999999 is still 0 acording to [Math]::Round($file.Size/1GB) )

Try this to get the size in bytes:

param ( $path="C:\" ) $file = Get-ChildItem -Recurse -Path $path | Where-Object { !$_.PSIsContainer } | Select-Object -Property @{Name='Size';Expression={$_.Length}} | Sort-Object { $_.Size } -Descending | Select-Object -first 1 Write-Host "$(([Math]::Round($file.Size)).ToString()) :OK" exit 0

Created on Mar 25, 2020 3:14:14 PM



Votes:

0

Hi,
Yes, you are right. Thanks for pointing this out to me. I tried again and in my case the script is working. Manually running the script on the PRTG server as well as the sensor in PRTG is working as expected. Does the windows user you are using in PRTG have sufficient access rights? Also did you configure the Execution Policy?

Created on Mar 26, 2020 6:55:15 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.