From: MiguelA on 23 Dec 2009 16:59 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 23 Dec 2009 17:19 "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 31 Dec 2009 10:23 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 31 Dec 2009 10:31 "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 31 Dec 2009 10:36 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. > > >
|
Next
|
Last
Pages: 1 2 3 4 Prev: Trying to run a non-Win32 Application Next: Rename files based on file name? |