ConSol-Monitoring / snclient

SNClient+ - Cross platform monitoring agent
MIT License
48 stars 9 forks source link

Add folder size support #38

Closed lgmu closed 9 months ago

lgmu commented 1 year ago

Would be great if either check_files had a mode to check the size of folders or if there was a check_folder. Right now it's only possible to check the size of individual files in the folder, but not the whole folder itself.

In Powershell this can be achieved like this: $foldersize = (Get-ChildItem -Path "$folder" -Recurse | Measure-Object -Property Length -Sum).Sum

airathere commented 1 year ago

@lgmu: sorry to say that: no. imho get-childitem is really not helpful nor working in middle to large sized folders in any way, see also: https://devblogs.microsoft.com/powershell/why-is-get-childitem-so-slow/ If you need to read folder sizes you have to use other possibilities

lgmu commented 1 year ago

One day, you’ll install a build and the issues will just magically be gone.

This article is from 2009 and I have no issues whatsoever with 20+ GB Folders. And it was just an example. In Go this would be implemented entirely different anyway.

sni commented 9 months ago

check_files now shows the total size along with some performance data. It does not add additional overhead to the current code, since the agent has to stat() each file anyway already.