Forum Discussion

Jordan-Eil's avatar
2 years ago
Solved

Looking for DataSource/Property for indvidual Folder

Good Evening,

I’m curious if anyone has had any success in finding/building a DataSource/Property which can monitor the size of an individual windows Directory/Folder. 

The software team has a folder that needs to warn us when it reached 8GB and give a critical alert when it hits 9GB, and I’m trying to find a specific source, or method, to collect this data and alert on it.

Any help would be appreciated! 

9 Replies

  • So, the situation was pretty simple but slightly complex.

    For those looking for this:  We enabled the UNC monitoring on the datapoint, and on the server added the property: unc.recursive = true

    then added the Wildcard Value of \\[IP Address]\C$\[FilePath] 

    From there it has now been monitoring the size of the folder using the DataPoint:  BytesInDir

    I hope this helps anyone who’s looking for a similar solution.  

  • I don’t know if one exists, but it wouldn’t take much to build it. You’d need a Powershell based DS that implements this method: https://www.partitionwizard.com/partitionmanager/powershell-get-folder-size.html. Consider creating a multi-instance DS with discovery based on a property value. You could create a property called folders_monitored_for_size. The value could be like this:

    ID1;Folder1DisplayName;C:\my folder|ID2;Folder2Name;D:\data

    Then your discovery script (which could be groovy even if collection is PS based) would look like this:

    hostProps.get("folders_monitored_for_size").tokenize("|").each{folder ->
    x = folder.tokenize(';')
    println("${x[0]}##${x[1]}##${x[2]}")
    }
    return 0

    To construct the value of the folders_monitored_for_size, start with the list of folders to monitor on a device:

    • C:\my folder
    • D:\data

    Then come up with a unique id and a display name for each (ID cannot have =, :, \, #, or space, but otherwise can be anything you want unique on that device):

    • Personal Directory - 1
    • Data Directory - 2

    Then your property would look like this:

    1;Personal Directory;C:\my folder|2;Data Directory;D:\data

    You’d end up with two instances, each of them would be monitored by the collection, which I’ll explain next.

    I’d make this a script not batchscript DS simply because it’ll make the script easier. You’ll need your script to pull the instance wildvalue and description into your PS script by doing $wildvalue= '##system.wildvalue##', similar for instance description.

    Then you’d just execute the method linked above and output the size. If i have more time later, I may flesh this out more, but you should at least be able to get started with what’s here.

  • FYI. Keep in mind that all checks run directly from the Collector server. So having the code just check c:\myfolder\ directly, will check the folder on the collector itself only, even if you add the check to another device in LM. The custom DataSource will need to do things like remote powershell or UNC paths to check other computers using the system.sysname property or the like.

  • @Mike Moniz , would the --computer parameter work in this case to access the path as if it were local (i’m not a windows/posh guy). We’d need to do an Invoke-Command -ComputerName <hostname>, right?

    Yeah, I’m pretty sure you need to use something like invoke-command unless you use a UNC path, as get-childitem doesn’t have a -computer param

  • trying the UNC using just the C:, the hostname, or IP doesn’t seem to link the directory… I am going to see if I can attempt to implement Stuart Weening’s method - though it seems I need to make both a property source and a datasource to test. 

  • You can test in the collector debug console. Since it’s PS, you could run it in a powershell window on the collector.

    @Mike Moniz , would the --computer parameter work in this case to access the path as if it were local (i’m not a windows/posh guy). We’d need to do an Invoke-Command -ComputerName <hostname>, right?

    @Jordan-Eil , i don’t think you’d need a property source.