This tip was submitted to the SearchWinSystems.com tip exchange by member Mike Douglas. Please let other users know how useful it is by rating it below.
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
By using this script (possibly as a scheduled job), free space on systems or shares can be monitored and reported on via e-mail. It's usually a better idea to let your system inform you of space outages rather than your users.
'** DRIVEMON.VBS '** '** Basic drive usage monitoring script '** Usage: cscript drivemon.vbs <TO: email> <FROM: email>
<path1> <path2> <path3>... Dim fso, drv, s, drvPath, bBAD on error resume next bBAD = False Set objArgs = WScript.Arguments if (objArgs.Count > 2) then For i = 2 to objArgs.count - 1 drvPath = objArgs(i) Set fso = CreateObject("Scripting.FileSystemObject") Set drv = fso.GetDrive(fso.GetDriveName(drvPath)) eText = Err.Description if i < 1 then s = "Drive " & UCase(drvPath) & " - " else s = s & "Drive " & UCase(drvPath) & " - " end if s = s & drv.VolumeName s = s & vbcrlf x=int(drv.Freespace) y=int(drv.totalsize * .1) if eText > "" then s = s & eText & vbcrlf & vbcrlf eText = "" bBAD = True end if if x < y then s = s & "*** SPACE USAGE ALERT ***" & vbcrlf bBAD = True s = s & "Total Space: " & FormatNumber(drv.TotalSize / 1024, 0) s = s & " Kb" & vbcrlf s = s & "Free Space: " & FormatNumber(drv.FreeSpace / 1024, 0) s = s & " Kb" & vbcrlf & vbcrlf end if Next if bBAD then Set oEmail = CreateObject("CDO.Message") oEmail.From = objArgs(1) oEmail.To = objArgs(0) oEmail.Subject = "WARNING! Drive Monitor Report - " & now() oEmail.TextBody = s oEmail.Send Set oEmail = Nothing end if else wscript.echo "DriveMon.vbs - Email a report of drive usage on any accessible path." & vbcrlf & vbcrlf & "Usage: cscript drivemon.vbs <TO: email> <FROM: email>
<path1> <path2> <path3>..." end if
Do you have comments on this tip? Let us know.