Option Explicit
Dim Msg,strComputer,objWMIService,colDisks,objDisk
strComputer = "ServerX"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DriveType = '3' AND DeviceID = 'E:'")
For Each objDisk in colDisks
Wscript.Echo "DeviceID: "& vbTab & objDisk.DeviceID
Wscript.Echo "Free Disk Space: " & vbTab & _
FormatNumber(objDisk.FreeSpace/objDisk.Size*100, 2) & "%"
Wscript.Echo "磁盘E上只剩下" & _
FormatNumber(objDisk.FreeSpace/(1024*1024*1024), 2) & "G的空间了!"
On Error Resume Next
If FormatNumber(objDisk.FreeSpace/objDisk.Size*100, 2) < 10 Then
Set Msg = CreateObject("CDO.Message")
Msg.Subject = "ServerX磁盘空间危机!"
Msg.Textbody = "管理员,请尽快想办法缓和危机!" & vbCRLF & _
"磁盘E: 快满了,无法存储数据!" & vbNewLine & "紧急!紧急!!" & vbNewLine & _
"E盘只剩下" & FormatNumber(objDisk.FreeSpace/(1024*1024*1024), 2) & " G." & _
vbNewLine & "占全磁盘的" & _
FormatNumber(objDisk.FreeSpace/objDisk.Size*100, 2) & "%"
Msg.To = """Bill GATES"""
Msg.CC = """Michel FOUCAULT"", _
""Lao LI"""
End If
With Msg
.From="""ServerX"""
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.10.10.10"
'邮件服务器IP地址
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
.Send
End With
Next
Bookmark this post:
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ![]() |
0 评论:
发表评论