Post by MiguelAHi!!!
I need a script that monitors the hard drives of servers and when you
reach a minimum space constraints, I send an email warning.
How can I do?, Exists already implemented?
THANKS
You could use this script as a basis when working out the amount of free
disk space:
aDType = Split("Unknown Removable Fixed Network CDROM RAMDISK")
Set oFSO = CreateObject("Scripting.FileSystemObject")
LF = Chr(10)
sLine = "Drive Type State Label F/S Size Free
Serial"
WScript.Echo sLine
WScript.Echo String(Len(sLine)+2, "-")
For Each oDrive In oFSO.Drives
D = oDrive.DriveType
if D > UBound(aDType) then D = 0
sLine = oDrive.Path & " " & aDType(D)
If oDrive.IsReady Then
sLine = Append(sLine, "ready", 18, False)
If oDrive.DriveType = 3 Then
sLine = Append(sLine, Left(oDrive.ShareName, 13), 29, False)
Else
sLine = Append(sLine, Left(oDrive.VolumeName, 13), 29, False)
End If
sLine = Append(sLine, oDrive.FileSystem, 44, False)
sLine = Append(sLine, Int(oDrive.TotalSize/1000000), 51, True)
sLine = Append(sLine, Int(oDrive.FreeSpace/1000000), 59, True)
sLine = Append(sLine, Hex(oDrive.SerialNumber), 67, False)
Else
sLine = Append(sLine, "not ready", 18, False)
End If
WScript.Echo sLine
Next
Function Append(L, S, n, numerical)
if n < Len(L) + 2 then n = 2 Else n = n - Len(L)
If numerical Then
Append = L & Left(Space(60), n + 6 - Len(S)) & S
Else
Append = L & Left(Space(60), n) & S
End If
End Function
===================================
And here is something to send a message:
const cdoBasic=1
schema = "http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "***@company.com"
.To = "***@company.com"
.Subject = "Test Mail"
.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
.AddAttachment "d:\Testfile.txt"
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "mail.company.com"
.Item (schema & "smtpserverport") = 25
.Item (schema & "smtpauthenticate") = cdoBasic
.Item (schema & "sendusername") = "***@company.com"
.Item (schema & "smtpaccountname") = "***@company.com"
.Item (schema & "sendpassword") = "SomePassword"
End With
.Configuration.Fields.Update
.Send
End With