From: MiguelA on
Hi!!!

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

From: Pegasus [MVP] on


"MiguelA" <ma.camaleon(a)NOSPAMgmail.com> said this in news item
news:84B02BEC-D648-4050-A796-7599E263880E(a)microsoft.com...
> Hi!!!
>
> 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 = "James(a)company.com"
.To = "Jim(a)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") = "James(a)company.com"
.Item (schema & "smtpaccountname") = "James(a)company.com"
.Item (schema & "sendpassword") = "SomePassword"
End With
.Configuration.Fields.Update
.Send
End With


From: MiguelA on
I can not implement all the code!

"Pegasus [MVP]" <news(a)microsoft.com> wrote in message
news:OvHfG4BhKHA.1236(a)TK2MSFTNGP04.phx.gbl...
>
>
> "MiguelA" <ma.camaleon(a)NOSPAMgmail.com> said this in news item
> news:84B02BEC-D648-4050-A796-7599E263880E(a)microsoft.com...
>> Hi!!!
>>
>> 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 = "James(a)company.com"
> .To = "Jim(a)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") = "James(a)company.com"
> .Item (schema & "smtpaccountname") = "James(a)company.com"
> .Item (schema & "sendpassword") = "SomePassword"
> End With
> .Configuration.Fields.Update
> .Send
> End With
>
>

From: Pegasus [MVP] on


"MiguelA" <ma.camaleon(a)NOSPAMgmail.com> said this in news item
news:86144BCB-29F3-43B4-AF6A-081C68F0E83B(a)microsoft.com...
> I can not implement all the code!

The idea is for you to grab the parts that are relevant for you. Feel free
to ask if certain details are unclear.


From: MiguelA on
I do not understand is as if it detects that there is little space to run
the email sending.
If a server has multiple disks, it detects all?.

"Pegasus [MVP]" <news(a)microsoft.com> wrote in message
news:OJ4oH5iiKHA.1236(a)TK2MSFTNGP04.phx.gbl...
>
>
> "MiguelA" <ma.camaleon(a)NOSPAMgmail.com> said this in news item
> news:86144BCB-29F3-43B4-AF6A-081C68F0E83B(a)microsoft.com...
>> I can not implement all the code!
>
> The idea is for you to grab the parts that are relevant for you. Feel free
> to ask if certain details are unclear.
>
>
>