1

I'm trying to configure an alert on low space on disk in Windows Server 2003, I already followed this step by step tutorial of microsoft. I try to execute a bat file created by me, located on the home folder of the user I'm using.

I seted to trigger when the free space is below 6 GB when the disk have lower free space than 6 GB, the "Sample data interval" is the default (5 seconds).

The problem is that the alert isnt triggered.

And another thing, the user that is seted for the alert isnt the root user, but It have administration privileges.

Thanks in advance

Ferre06
  • 11
  • 2

1 Answers1

0

Try the following script, it is self explanatory. This script will send an email to RECEIPIENT@DOMAIN.COM if the disk space is less than 1 GB. You need to modify the email account details and schedule it as a task.

Calculate free disk space on the server

Const HARD_DISK = 3

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _

("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")

Set objComputer = CreateObject("Shell.LocalMachine")

i = 0

intCharacters = 5

flag = 0

For Each objDisk in colDisks

freespace = objDisk.FreeSpace

drive = objDisk.DeviceID

totalspace = objDisk.Size

totalspace = totalspace/1073741824

totalspace = Left(totalspace, intCharacters)

totalspace = totalspace & " GB"

freespace = freespace/1073741824

freespace = Left(freespace, intCharacters)

if freespace < 1 then

flag = 1

end if

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 = "Free Space Total Space" + vbNewLine + vbNewLine

Next

if flag = 1 then

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 'basic (clear-text) authentication

' ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="USER@DOMAIN.COM"

' ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="EMAIL PASSWORD" ObjEmail.Configuration.Fields.Update

        objEmail.From = "USER@DOMAIN.COM"

        objEmail.To = "RECEIPIENT@DOMAIN.COM"

        objEmail.Subject = "YOUR SUBJECT"

        objEmail.Textbody = head + display

        objEmail.Send

        Set ObjEmail = Nothing

end if

biju
  • 1