Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
'WScript.Echo "Computer Name: " & strComputerName
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Disk Space Alert: " &strComputerName
objMessage.From = "kshitij.rakesh@arihantcapital.com"
objMessage.To = "kshitij.rakesh@arihantcapital.com"
Dim objShell, space_value, Result
Set objShell = Wscript.CreateObject("WScript.Shell")
Set DiskSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery ("select * from Win32_LogicalDisk where DriveType=3")
For each Disk in DiskSet
If (Disk.Name="D:") Then
Disk.FreeSpace=Disk.FreeSpace/1024
Disk.FreeSpace=Disk.FreeSpace/1024
Disk.FreeSpace=Disk.FreeSpace/1024
Result = Disk.FreeSpace
End If
Next
space_value = Result
Wscript.echo space_value
if space_value < 150 then
objMessage.TextBody = "Server Disk Space Low, " & space_value & " GB"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.arihantcapital.com"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
end if
No comments:
Post a Comment