Looking for tool to montior servers hard disk space within AD

  • Thread starter Thread starter Mugen
  • Start date Start date
M

Mugen

Guest
Hi,
We are running Windows 2003 server with AD. I am looking for a solution that
can montior member servers hard disk space and generate an alert when disk
space is running low by email notification etc. Does anyone knows a product
out there to achieve these tasks?

Thanks.
 
Re: Looking for tool to montior servers hard disk space within AD

"Mugen" <Mugen@discussions.microsoft.com> wrote in message
news:A601AD7B-DFEF-4173-A3C9-7F8AE2F5964D@microsoft.com...
> Hi,
> We are running Windows 2003 server with AD. I am looking for a solution
> that
> can montior member servers hard disk space and generate an alert when disk
> space is running low by email notification etc. Does anyone knows a
> product
> out there to achieve these tasks?
>
> Thanks.


You could save the script below as c:\Windows\DiskReport.vbs,
then do this:
1. Modify Lines 7-4 to suit your particular environment.
2. Remove the line numbers.
3. Temporarily set a low limit in Line 14, then type this command
from a Command Prompt to test the script:
cscript //nologo c:\Windows\DiskReport.vbs
4. Use the Task Scheduler to run the above command once
every day:

001. '==================
002. 'Collect disk stats
003. '30.5.2008 FNL
004. '==================
005. Option Explicit
006.
007. Const Sender = "mugen@isp.com"
008. Const Recipient = "mugen@isp.com"
009. Const SMTPServer = "mail.isp.com"
010. Const SMTPAcc = "mugen@isp.com" 'SMTP account
011. Const SMTPPW = "smtp" 'SMTP password
012. Const SMTPPort = 25 'SMTP port
013. Const SMTPAuth = True 'Use SMTP authentication
014. Const iDiskFull = 75 'Limit for %full warning for partitions
015.
016. Const Letter = 0, Size = 1, Type_ = 2, Percent = 3, full = 4, free = 5
017. Dim CRLF: CRLF = Chr(13) & Chr(10)
018. Dim Tab: Tab = Chr(9)
019. Dim Partitions(26, 6), sMessage, bDiskFull
020.
021. GetPartitionDetails
022. GenerateReport
023. if bDiskFull then Send
024.
025. '-------------------------
026. 'Extract partition details
027. '-------------------------
028. Sub GetPartitionDetails
029. Dim ObjWMIService, i, L, DiskSet, Disk
030.
031. bDiskFull = False
032. For i = Asc("C") To Asc("Z")
033. L = "'" & Chr(i) & ":" & "'"
034. Set DiskSet =
GetObject("winmgmts:{impersonationLevel=impersonate}!//" _
035. & "./root/cimv2").ExecQuery("select DeviceID, " _
036. & "FileSystem, Size, FreeSpace from Win32_LogicalDisk " _
037. & "where DeviceID = " & L & " and DriveType = '3'")
038.
039. For Each Disk In DiskSet
040. Partitions(i-Asc("C"), letter) = Chr(i) & ":"
041. Partitions(i-Asc("C"), type_) = "Type=" & Disk.FileSystem
042. Partitions(i-Asc("C"), size) = "Cap=" &
FormatNumber(Disk.Size/2^30,1) & " Gbytes"
043. Partitions(i-Asc("C"), free) = "Free=" &
FormatNumber(Disk.FreeSpace/2^30,1) & " Gbytes"
044. Partitions(i-Asc("C"), percent) = FormatNumber(100 * _
045. (Disk.Size - Disk.FreeSpace) / Disk.Size, 0) & "% full"
046. Partitions(i - Asc("C"), full) = ""
047. If 100 * (Disk.Size - Disk.FreeSpace) / Disk.Size > iDiskFull Then
048. bDiskFull = True
049. Partitions(i - Asc("C"), full) = " *** Partition is full!***"
050. End If
051. Next
052. Next
053. End Sub
054. '-------------------
055. 'Generate the report
056. '-------------------
057. Sub GenerateReport
058. Dim aux, i
059.
060. aux = "Partition report compiled on " _
061. & FormatDateTime(Now, 1) & " at " & FormatDateTime(Now, 4)
062. sMessage = aux
063. sMessage = sMessage & CRLF & String(Len(aux), "=") & CRLF
064. For i = 0 To 26
065. If Not IsEmpty(Partitions(i, letter)) Then sMessage = sMessage & _
066. RPad("Drive " & Partitions(i, letter), 10) _
067. & RPad(Partitions(i, type_), 12) _
068. & LPad(Partitions(i, size), 16, " ") _
069. & LPad(Partitions(i, free), 19, " ") _
070. & LPad(Partitions(i, percent), 11, " ") _
071. & Partitions(i, full) & CRLF
072. Next
073. End Sub
074. '----------------
075. 'Send the results
076. '----------------
077. Sub Send
078. Dim objWShell, sComputer, schema, objEmail, cdoBasic
079. Set objWShell = WScript.CreateObject("WScript.Shell")
080. sComputer = objWShell.Environment("PROCESS")("ComputerName")
081.
082. schema = "http://schemas.microsoft.com/cdo/configuration/"
083. Set objEmail = CreateObject("CDO.Message")
084. With objEmail
085. .From = Sender
086. .To = Recipient
087. .Subject = "Disk partition report for " & sComputer
088. .Textbody = sMessage
089. With .Configuration.Fields
090. .Item (schema & "sendusing") = 2
091. .Item (schema & "smtpserver") = SMTPServer
092. .Item (schema & "smtpserverport") = SMTPPort
093. .Item (schema & "smtpauthenticate") = cdoBasic
094. If SMTPAuth Then
095. .Item (schema & "sendusername") = SMTPAcc
096. .Item (schema & "sendpassword") = SMTPPW
097. End If
098. End With
099. .Configuration.Fields.Update
100. .Send
101. End With
102. End Sub
103. '----------------------------------------------
104. 'Left-pad a string to a length of n characters,
105. 'using the specified character
106. '----------------------------------------------
107. Function LPad (S, n, c)
108. LPad = Right(String(n, c) & S, n)
109. End Function
110. '------------------------------------------
111. 'Right-pad a string to a length of n spaces
112. '------------------------------------------
113. Function RPad (S, n)
114. RPad = Left(S & String(n, " "), n)
115. End Function
 
Re: Looking for tool to montior servers hard disk space within AD

That's really good. I am going to try it out.
How come some of the line numbers are empty?

"Pegasus (MVP)" wrote:

> "Mugen" <Mugen@discussions.microsoft.com> wrote in message
> news:A601AD7B-DFEF-4173-A3C9-7F8AE2F5964D@microsoft.com...
> > Hi,
> > We are running Windows 2003 server with AD. I am looking for a solution
> > that
> > can montior member servers hard disk space and generate an alert when disk
> > space is running low by email notification etc. Does anyone knows a
> > product
> > out there to achieve these tasks?
> >
> > Thanks.

>
> You could save the script below as c:\Windows\DiskReport.vbs,
> then do this:
> 1. Modify Lines 7-4 to suit your particular environment.
> 2. Remove the line numbers.
> 3. Temporarily set a low limit in Line 14, then type this command
> from a Command Prompt to test the script:
> cscript //nologo c:\Windows\DiskReport.vbs
> 4. Use the Task Scheduler to run the above command once
> every day:
>
> 001. '==================
> 002. 'Collect disk stats
> 003. '30.5.2008 FNL
> 004. '==================
> 005. Option Explicit
> 006.
> 007. Const Sender = "mugen@isp.com"
> 008. Const Recipient = "mugen@isp.com"
> 009. Const SMTPServer = "mail.isp.com"
> 010. Const SMTPAcc = "mugen@isp.com" 'SMTP account
> 011. Const SMTPPW = "smtp" 'SMTP password
> 012. Const SMTPPort = 25 'SMTP port
> 013. Const SMTPAuth = True 'Use SMTP authentication
> 014. Const iDiskFull = 75 'Limit for %full warning for partitions
> 015.
> 016. Const Letter = 0, Size = 1, Type_ = 2, Percent = 3, full = 4, free = 5
> 017. Dim CRLF: CRLF = Chr(13) & Chr(10)
> 018. Dim Tab: Tab = Chr(9)
> 019. Dim Partitions(26, 6), sMessage, bDiskFull
> 020.
> 021. GetPartitionDetails
> 022. GenerateReport
> 023. if bDiskFull then Send
> 024.
> 025. '-------------------------
> 026. 'Extract partition details
> 027. '-------------------------
> 028. Sub GetPartitionDetails
> 029. Dim ObjWMIService, i, L, DiskSet, Disk
> 030.
> 031. bDiskFull = False
> 032. For i = Asc("C") To Asc("Z")
> 033. L = "'" & Chr(i) & ":" & "'"
> 034. Set DiskSet =
> GetObject("winmgmts:{impersonationLevel=impersonate}!//" _
> 035. & "./root/cimv2").ExecQuery("select DeviceID, " _
> 036. & "FileSystem, Size, FreeSpace from Win32_LogicalDisk " _
> 037. & "where DeviceID = " & L & " and DriveType = '3'")
> 038.
> 039. For Each Disk In DiskSet
> 040. Partitions(i-Asc("C"), letter) = Chr(i) & ":"
> 041. Partitions(i-Asc("C"), type_) = "Type=" & Disk.FileSystem
> 042. Partitions(i-Asc("C"), size) = "Cap=" &
> FormatNumber(Disk.Size/2^30,1) & " Gbytes"
> 043. Partitions(i-Asc("C"), free) = "Free=" &
> FormatNumber(Disk.FreeSpace/2^30,1) & " Gbytes"
> 044. Partitions(i-Asc("C"), percent) = FormatNumber(100 * _
> 045. (Disk.Size - Disk.FreeSpace) / Disk.Size, 0) & "% full"
> 046. Partitions(i - Asc("C"), full) = ""
> 047. If 100 * (Disk.Size - Disk.FreeSpace) / Disk.Size > iDiskFull Then
> 048. bDiskFull = True
> 049. Partitions(i - Asc("C"), full) = " *** Partition is full!***"
> 050. End If
> 051. Next
> 052. Next
> 053. End Sub
> 054. '-------------------
> 055. 'Generate the report
> 056. '-------------------
> 057. Sub GenerateReport
> 058. Dim aux, i
> 059.
> 060. aux = "Partition report compiled on " _
> 061. & FormatDateTime(Now, 1) & " at " & FormatDateTime(Now, 4)
> 062. sMessage = aux
> 063. sMessage = sMessage & CRLF & String(Len(aux), "=") & CRLF
> 064. For i = 0 To 26
> 065. If Not IsEmpty(Partitions(i, letter)) Then sMessage = sMessage & _
> 066. RPad("Drive " & Partitions(i, letter), 10) _
> 067. & RPad(Partitions(i, type_), 12) _
> 068. & LPad(Partitions(i, size), 16, " ") _
> 069. & LPad(Partitions(i, free), 19, " ") _
> 070. & LPad(Partitions(i, percent), 11, " ") _
> 071. & Partitions(i, full) & CRLF
> 072. Next
> 073. End Sub
> 074. '----------------
> 075. 'Send the results
> 076. '----------------
> 077. Sub Send
> 078. Dim objWShell, sComputer, schema, objEmail, cdoBasic
> 079. Set objWShell = WScript.CreateObject("WScript.Shell")
> 080. sComputer = objWShell.Environment("PROCESS")("ComputerName")
> 081.
> 082. schema = "http://schemas.microsoft.com/cdo/configuration/"
> 083. Set objEmail = CreateObject("CDO.Message")
> 084. With objEmail
> 085. .From = Sender
> 086. .To = Recipient
> 087. .Subject = "Disk partition report for " & sComputer
> 088. .Textbody = sMessage
> 089. With .Configuration.Fields
> 090. .Item (schema & "sendusing") = 2
> 091. .Item (schema & "smtpserver") = SMTPServer
> 092. .Item (schema & "smtpserverport") = SMTPPort
> 093. .Item (schema & "smtpauthenticate") = cdoBasic
> 094. If SMTPAuth Then
> 095. .Item (schema & "sendusername") = SMTPAcc
> 096. .Item (schema & "sendpassword") = SMTPPW
> 097. End If
> 098. End With
> 099. .Configuration.Fields.Update
> 100. .Send
> 101. End With
> 102. End Sub
> 103. '----------------------------------------------
> 104. 'Left-pad a string to a length of n characters,
> 105. 'using the specified character
> 106. '----------------------------------------------
> 107. Function LPad (S, n, c)
> 108. LPad = Right(String(n, c) & S, n)
> 109. End Function
> 110. '------------------------------------------
> 111. 'Right-pad a string to a length of n spaces
> 112. '------------------------------------------
> 113. Function RPad (S, n)
> 114. RPad = Left(S & String(n, " "), n)
> 115. End Function
>
>
>
 
Re: Looking for tool to montior servers hard disk space within AD

For the same reason as there is a slightly increased space
between two adjacent paragraphs in a printed book:
Readability. Feel free to omit all empty lines!


"Mugen" <Mugen@discussions.microsoft.com> wrote in message
news:28C6800B-050A-4A2A-BAAE-4FC33666D826@microsoft.com...
> That's really good. I am going to try it out.
> How come some of the line numbers are empty?
>
> "Pegasus (MVP)" wrote:
>
>> "Mugen" <Mugen@discussions.microsoft.com> wrote in message
>> news:A601AD7B-DFEF-4173-A3C9-7F8AE2F5964D@microsoft.com...
>> > Hi,
>> > We are running Windows 2003 server with AD. I am looking for a solution
>> > that
>> > can montior member servers hard disk space and generate an alert when
>> > disk
>> > space is running low by email notification etc. Does anyone knows a
>> > product
>> > out there to achieve these tasks?
>> >
>> > Thanks.

>>
>> You could save the script below as c:\Windows\DiskReport.vbs,
>> then do this:
>> 1. Modify Lines 7-4 to suit your particular environment.
>> 2. Remove the line numbers.
>> 3. Temporarily set a low limit in Line 14, then type this command
>> from a Command Prompt to test the script:
>> cscript //nologo c:\Windows\DiskReport.vbs
>> 4. Use the Task Scheduler to run the above command once
>> every day:
>>
>> 001. '==================
>> 002. 'Collect disk stats
>> 003. '30.5.2008 FNL
>> 004. '==================
>> 005. Option Explicit
>> 006.
>> 007. Const Sender = "mugen@isp.com"
>> 008. Const Recipient = "mugen@isp.com"
>> 009. Const SMTPServer = "mail.isp.com"
>> 010. Const SMTPAcc = "mugen@isp.com" 'SMTP account
>> 011. Const SMTPPW = "smtp" 'SMTP password
>> 012. Const SMTPPort = 25 'SMTP port
>> 013. Const SMTPAuth = True 'Use SMTP authentication
>> 014. Const iDiskFull = 75 'Limit for %full warning for partitions
>> 015.
>> 016. Const Letter = 0, Size = 1, Type_ = 2, Percent = 3, full = 4, free =
>> 5
>> 017. Dim CRLF: CRLF = Chr(13) & Chr(10)
>> 018. Dim Tab: Tab = Chr(9)
>> 019. Dim Partitions(26, 6), sMessage, bDiskFull
>> 020.
>> 021. GetPartitionDetails
>> 022. GenerateReport
>> 023. if bDiskFull then Send
>> 024.
>> 025. '-------------------------
>> 026. 'Extract partition details
>> 027. '-------------------------
>> 028. Sub GetPartitionDetails
>> 029. Dim ObjWMIService, i, L, DiskSet, Disk
>> 030.
>> 031. bDiskFull = False
>> 032. For i = Asc("C") To Asc("Z")
>> 033. L = "'" & Chr(i) & ":" & "'"
>> 034. Set DiskSet =
>> GetObject("winmgmts:{impersonationLevel=impersonate}!//" _
>> 035. & "./root/cimv2").ExecQuery("select DeviceID, " _
>> 036. & "FileSystem, Size, FreeSpace from Win32_LogicalDisk " _
>> 037. & "where DeviceID = " & L & " and DriveType = '3'")
>> 038.
>> 039. For Each Disk In DiskSet
>> 040. Partitions(i-Asc("C"), letter) = Chr(i) & ":"
>> 041. Partitions(i-Asc("C"), type_) = "Type=" & Disk.FileSystem
>> 042. Partitions(i-Asc("C"), size) = "Cap=" &
>> FormatNumber(Disk.Size/2^30,1) & " Gbytes"
>> 043. Partitions(i-Asc("C"), free) = "Free=" &
>> FormatNumber(Disk.FreeSpace/2^30,1) & " Gbytes"
>> 044. Partitions(i-Asc("C"), percent) = FormatNumber(100 * _
>> 045. (Disk.Size - Disk.FreeSpace) / Disk.Size, 0) & "% full"
>> 046. Partitions(i - Asc("C"), full) = ""
>> 047. If 100 * (Disk.Size - Disk.FreeSpace) / Disk.Size > iDiskFull
>> Then
>> 048. bDiskFull = True
>> 049. Partitions(i - Asc("C"), full) = " *** Partition is full!***"
>> 050. End If
>> 051. Next
>> 052. Next
>> 053. End Sub
>> 054. '-------------------
>> 055. 'Generate the report
>> 056. '-------------------
>> 057. Sub GenerateReport
>> 058. Dim aux, i
>> 059.
>> 060. aux = "Partition report compiled on " _
>> 061. & FormatDateTime(Now, 1) & " at " & FormatDateTime(Now, 4)
>> 062. sMessage = aux
>> 063. sMessage = sMessage & CRLF & String(Len(aux), "=") & CRLF
>> 064. For i = 0 To 26
>> 065. If Not IsEmpty(Partitions(i, letter)) Then sMessage = sMessage & _
>> 066. RPad("Drive " & Partitions(i, letter), 10) _
>> 067. & RPad(Partitions(i, type_), 12) _
>> 068. & LPad(Partitions(i, size), 16, " ") _
>> 069. & LPad(Partitions(i, free), 19, " ") _
>> 070. & LPad(Partitions(i, percent), 11, " ") _
>> 071. & Partitions(i, full) & CRLF
>> 072. Next
>> 073. End Sub
>> 074. '----------------
>> 075. 'Send the results
>> 076. '----------------
>> 077. Sub Send
>> 078. Dim objWShell, sComputer, schema, objEmail, cdoBasic
>> 079. Set objWShell = WScript.CreateObject("WScript.Shell")
>> 080. sComputer = objWShell.Environment("PROCESS")("ComputerName")
>> 081.
>> 082. schema = "http://schemas.microsoft.com/cdo/configuration/"
>> 083. Set objEmail = CreateObject("CDO.Message")
>> 084. With objEmail
>> 085. .From = Sender
>> 086. .To = Recipient
>> 087. .Subject = "Disk partition report for " & sComputer
>> 088. .Textbody = sMessage
>> 089. With .Configuration.Fields
>> 090. .Item (schema & "sendusing") = 2
>> 091. .Item (schema & "smtpserver") = SMTPServer
>> 092. .Item (schema & "smtpserverport") = SMTPPort
>> 093. .Item (schema & "smtpauthenticate") = cdoBasic
>> 094. If SMTPAuth Then
>> 095. .Item (schema & "sendusername") = SMTPAcc
>> 096. .Item (schema & "sendpassword") = SMTPPW
>> 097. End If
>> 098. End With
>> 099. .Configuration.Fields.Update
>> 100. .Send
>> 101. End With
>> 102. End Sub
>> 103. '----------------------------------------------
>> 104. 'Left-pad a string to a length of n characters,
>> 105. 'using the specified character
>> 106. '----------------------------------------------
>> 107. Function LPad (S, n, c)
>> 108. LPad = Right(String(n, c) & S, n)
>> 109. End Function
>> 110. '------------------------------------------
>> 111. 'Right-pad a string to a length of n spaces
>> 112. '------------------------------------------
>> 113. Function RPad (S, n)
>> 114. RPad = Left(S & String(n, " "), n)
>> 115. End Function
>>
>>
>>
 
Back
Top