Monitor the size of a folder
I had a discussion with one of the support Engineers and like to raise this as a feature request. I would like to monitor a folder size on a windows and set up an alert if the utilization reaches "x" amount.
The only possible way right now in LM is to monitor the folder using a "UNC path"monitor but it's not actually presenting the size of the folder. Is there any chance this feature request can be enabled in a future LM release?
Dim
Posted 9 years ago·Last reply 9 years ago
4 comments
SchuylerC
·9 years agoYeah the data source we built used the same Get-ChildItem method with the recurse modifier. Worked great when we were looking at small number of folders. Attached the xml if anyone may be looking to do something similar. AD script gets all sub folders one tier down and passes them as wild values. Collection script uses the Get-ChildItem -recurse method to report the size in MB. Again this works great for monitoring a directory with a limited number of sub-directories, but has issues when monitoring a directory with a ton of sub-directories.
Dim
OP9 years ago@mnagel Thanks , I got a working datasource to check the folder size now. @SchuylerCthere's a beta datasource for this in the repository now (search for folder size). this is the powershell script :
Make sure you include "recurse" if you trying to get properties of Administrator folders. The result should be raw output (folder size in bytes) and then I created a complex datapoint to convert bytes into GB (Size/1024/1024/1024)
SchuylerC
·9 years agoI'd like to see this too. We have a datasource which uses a recursive PowerShell script to do this currently, which works great when the are only a handful of child directories, but we've seen issues running the same script on say a fileserver with hundreds of chid directories where it was pegging mem and cpu usage. The grovvy script above is also recursive so I wonder if it may have the same issues. Worth a look though.
mnagel
·9 years agoThis would be a fairly simple embedded Groovy datasource. This is a good starting point for calculating directory size:
http://mrhaki.blogspot.com/2013/01/groovy-goodness-calculating-directory.html
My recommendation is to define a custom property with the target path and use Groovy to extract that at the script initialization, for example:
You can then use "dirsizecheck.filepath" as your "Applies To" to automatically run this DS for any hosts that have that defined. Not appropriate if you want multiple instances, though -- that would require more thought. Perhaps a comma or semicolon separated list in that property -- still learning the ropes on best practices.