views:

1010

answers:

4

I'm looking for something that will monitor Windows directories for size and file count over time. I'm talking about a handful of servers and a few thousand folders (millions of files).

Requirements:

  • Notification on X increase in size over Y time
  • Notification on X increase in file count over Y time
  • Historical graphing (or at least saving snapshot data over time) of size and file count
  • All of this on a set of directories and their child directories

I'd prefer a free solution but would also appreciate getting pointed in the right direction. If we were to write our own, how would we go about doing that? Available languages being Ruby, Groovy, Java, Perl, or PowerShell (since I'd be writing it).

+3  A: 

There are several solutions out there, including some free ones. Some that I have worked with include:

Nagios and Big Brother

A quick google search can probably find more.

Joel
+3  A: 

You might want to take a look at PolyMon, which is an open source systems monitoring solution. It allows you to write custom monitors in any .NET language, and allows you to create custom PowerShell monitors.

It stores data on a SQL Server back end and provides graphing. For your purpose, you would just need a script that would get the directory size and file count. Something like:

$size = 0
$count = 0
$path = '\\unc\path\to\directory\to\monitor'
get-childitem -path $path -recurse | Where-Object {$_ -is [System.IO.FileInfo]} | ForEach-Object {$size += $_.length; $count += 1}

In reply to Scott's comment: Sure. you could wrap it in a while loop

$ESCkey  = 27
Write-Host "Press the ESC key to stop sniffing" -foregroundcolor "CYAN"
$Running=$true

While ($Running)
    { 
         if ($host.ui.RawUi.KeyAvailable) {
         $key = $host.ui.RawUI.ReadKey("NoEcho,IncludeKeyUp,IncludeKeyDown")
            if ($key.VirtualKeyCode -eq $ESCkey) { 
             $Running=$False
            }
         #rest of function here 
        }

I would not do that for a PowerShell monitor, which you can schedule to run periodically, but for a script to run in the background, the above would work. You could even add some database access code to log the results to a database, or log it to a file.. what ever you want.

Steven Murawski
Very cool! In PowerShell, could this be put into some sort of loop that just continually runs?
Scott Saad
I edited my answer (not enough space to reply in comment.
Steven Murawski
Very nice Steven! Thanks!
Scott Saad
A: 

http://sourceforge.net/projects/dirviewer/ -- DirViewer is a light pure java application for directory tree view and recursive disk usage statistics, using JGoodies-Looks look and feel similar to windows XP.

anjanb
A: 

You can certainly accomplish this with PowerShell and WMI. You would need some sort of DB backend like SQL Express. But I agree that a tool like Polymon is a better approach. The one thing that might make a diffence is the issue of scale. Do you need to monitor 1 folder on 1 server or hundreds?

Jeffery Hicks
Edited to answer... handful of servers, thousands of folders (millions of files).
Instantsoup