我试图在Windows Server 2003的磁盘空间不足上configuration一个警报,我已经按照这个一步一步教程的微软 。 我尝试执行由我创build的bat文件,位于我正在使用的用户的主文件夹中。
当可用空间低于6 GB时,当磁盘的可用空间低于6 GB时,我会select“触发”以触发,“采样数据间隔”是默认值(5秒)。
问题是警报没有触发。
而另一件事情是,用于警报的用户不是root用户,但它具有pipe理权限。
提前致谢
计算服务器上的可用磁盘空间
Const HARD_DISK = 3
strComputer =“。”
设置objWMIService = GetObject(“winmgmts:”_
&“{impersonationLevel = impersonate}!\”&strComputer&“\ root \ cimv2”)
设置colDisks = objWMIService.ExecQuery _
(“Select * from Win32_LogicalDisk Where DriveType =”&HARD_DISK&“”)
Set objComputer = CreateObject(“Shell.LocalMachine”)
我= 0
intCharacters = 5
标志= 0
对于colDisks中的每个objDisk
freespace = objDisk.FreeSpace
drive = objDisk.DeviceID
totalspace = objDisk.Size
totalspace =总计空间/ 1073741824
totalspace = Left(totalspace,intCharacters)
总计空间=总计空间和“GB”
freespace = freespace / 1073741824
freespace = Left(freespace,intCharacters)
如果freespace <1,那么
标志= 1
万一
freespace = freespace&“GB”
display = display + Cstr(objDisk.DeviceID)&“”+ freespace + display1&“”+ Cstr(objDisk.DeviceID)&“”+ totalspace + vbNewLine + vbNewLine
computer =“Server:”&objComputer.MachineName + vbNewLine + vbNewLine +“Space available on each drives:”+ vbNewLine + vbNewLine
head =“可用空间总空间”+ vbNewLine + vbNewLine
下一个
如果flag = 1那么
Set objEmail = CreateObject(“CDO.Message”)
ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network). ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="SMTP SERVER" ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False) ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
'ObjEmail.Configuration.Fields.Item(“ http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ”)= 1'基本(纯文本)身份validation
'ObjEmail.Configuration.Fields.Item(“ http://schemas.microsoft.com/cdo/configuration/sendusername ”)=“[email protected]”
'ObjEmail.Configuration.Fields.Item(“ http://schemas.microsoft.com/cdo/configuration/sendpassword ”)=“EMAIL PASSWORD”ObjEmail.Configuration.Fields.Update
objEmail.From = "[email protected]" objEmail.To = "[email protected]" objEmail.Subject = "YOUR SUBJECT" objEmail.Textbody = head + display objEmail.Send Set ObjEmail = Nothing