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?


Article Comments

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


Mar, 2020 - Permalink

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


Mar, 2020 - Permalink

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 support@paessler.com, so that we can take a closer look here. Please refer to this KB article in your e-mail.

Thanks.


Mar, 2020 - Permalink

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


Mar, 2020 - Permalink

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?


Mar, 2020 - Permalink