Tuesday, November 27, 2012

Monitor Disk Space

In the following script, you monitor the disk space on a server to let you know when it falls below 100000000 bytes. If the free space falls below 100000000, a message is echoed to the screen every 5 seconds.



Option Explicit
On Error Resume Next

Const FIVE_SEC = 5000
Const LOCAL_HARD_DISK = 3
Dim colMonitoredDisks
Dim objWMIService
Dim objDiskChange
Dim i

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}").ExecQuery _
("SELECT * FROM Win32_Process")
Set colMonitoredDisks = objWMIService.ExecNotificationQuery _
("Select * from __instancemodificationevent within 30 where " _
& "TargetInstance is a 'Win32_LogicalDisk'")

i = 0
Do While i = 0
Set objDiskChange = colMonitoredDisks.NextEvent
If objDiskChange.TargetInstance.DriveType = _
LOCAL_HARD_DISK Then
If objDiskChange.TargetInstance.Size < 100000000 Then
WScript.Echo _
"Hard disk space is below 100000000 bytes."
WScript.Sleep(FIVE_SEC)
End If
End If
Loop

2 comments:

  1. Youre so cool! I dont suppose Ive read something like this before. So nice to find somebody with some original thoughts on this subject. realy thank you for beginning this up. this web site is one thing that�s needed on the web, somebody with a bit of originality. helpful job for bringing one thing new to the internet! for seagate 2tb external hard disk visit Nayashopi

    ReplyDelete

Azure Policy support for remediating tags for existing resources

Use Azure policy to remediate tags for existing resources. https://azure.microsoft.com/en-us/updates/azure-provides-at-scale-tags-managem...