Can't find Logical disk performance counter in Windows server 2003 (exchange 2003)

bominthu
bominthu used Ask the Experts™
on
Hi Expert,

I have windows server 2003 standard R2 installed with Exchange server 2003.
I'm trying to monitor Logical disk free space using windows Performance monitoring as mentioned in this lin khttp://jamesrossiter.wordpress.com/2011/02/23/send-email-alerts-for-low-disk-space-using-perfmon-exe-in-windows-using-bmail-exe/ but I can't find Logical disk counter in there.
I've tried finding using microsoft tool , exctrlst.exe but it is not listed there.
http://networkadminkb.com/KB/a56/how-to-enable-or-disable-performance-counters.aspx

Tried manually rebuilding http://support.microsoft.com/?kbid=300956 but still cannot see logical disk counter.

Is that because i need restart server? Since it is mail server i can't restart server,
can i restart service? which service I can restart ?
What step I miss in it ? Appreciate ur help as I find monitoring using Logical drive counter is simple and easy.

If above all fail, is there any free open source tool which is non Nagio as I find Nagio installation so many steps involved.

Is there any script availabel which can check free space and send out alert email if free space is less than xxx Mbytes ?

Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
You could try this:

http://www.simple-talk.com/sysadmin/powershell/disk-space-monitoring-and-early-warning-with-powershell/

Or a try something like this script I wrote as an example.  You can schedule to run nightly:

Get-WMIObject  -ComputerName SERVERNAME Win32_LogicalDisk | where {$_.deviceid -ilike "*C*"} | foreach {
	if ($_.freespace -lt 9999999999999) {
		$space = $_.freespace
		write-host "Low on space, sending email"
		$emailFrom = "someone@domain.com"
		$emailTo = "You@domain.com"
		$subject = "Low Space on SERVERNAME"
		$body = "Space on C: is $space"
		$smtpServer = "yourSMTPservername"
		$smtp = new-object Net.Mail.SmtpClient($smtpServer)
		$smtp.UseDefaultCredentials = $true
		$smtp.Send($emailFrom, $emailTo, $subject, $body)
	} else {
		write-host "All ok."
	} 
		Write-host "Freespace: $space"
}

Open in new window

Author

Commented:
Hi UnConn,

Thanks for your reply. Could you let me what is the content "if ($_.freespace -lt 9999999999999) {
            $space = $_.freespace" referring to ?

I'm sorry that I'm not good in script.

Anyway what I'm trying to configure is to receive email alert as soon as drive D: Free space becomes less than 2048MB. And I'll set that schedule to run every 3 hours by setting task schedule.

If the drive free space is not less than 2048MB, I don't want to receive email alert.

Could you please amend the script ?

Thanks
Commented:
This script will only email you when it is below that size, but will also only email you when it is run.  So you need to schedule it as often as needed.  I would go with once an hour.

I cannot explain the whole line without background in scripting, but basically -lt is 'less than' and the part with $space is creating a variable containing the space in bytes.

I have edited it below to be a bit more simple.

# Change the letter in "*C*" to the drive you want to check!
Get-WMIObject Win32_LogicalDisk | where {$_.deviceid -ilike "*C*"} | foreach {
	if ($_.freespace -lt 2048MB) {
		$space = $_.freespace
		write-host "Low on space, sending email"
		$emailFrom = "someone@domain.com"
# Change next line to your email address
		$emailTo = "You@domain.com"
		$subject = "Low Space on SERVERNAME"
		$body = "Space on C: is $space"
# Change next line to your SMTP/HTS server
		$smtpServer = "yourSMTPservername"
		$smtp = new-object Net.Mail.SmtpClient($smtpServer)
		$smtp.UseDefaultCredentials = $true
		$smtp.Send($emailFrom, $emailTo, $subject, $body)
	} else {
		write-host "All ok."
	} 
		Write-host "Freespace: $space"
}

Open in new window

How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Author

Commented:
Get-WMIObject Win32_LogicalDisk | where {$_.deviceid -ilike "*C*"} | foreach {
      if ($_.freespace -lt 2048MB) {
            $space = $_.freespace
            write-host "Low on space, sending email"
            $emailFrom = "email@mydomain.com"
            $emailTo = "email@mydomain.com"
            $subject = "Low Space on MYSERVER"
            $body = "Space on C: is $space"
            $smtpServer = "mail.mydomain.com"
            $smtp = new-object Net.Mail.SmtpClient($smtpServer)
            $smtp.UseDefaultCredentials = $true
            $smtp.Send($emailFrom, $emailTo, $subject, $body)
      } else {
            write-host "All ok."
      }
            Write-host "Freespace: $space"
}
   


Hi Unconn,

I saved above as checkHDD.vbs and test. I don't receive any email even though my C: drive is less than 2GB.
Could you please advise what I miss above
Thanks

Author

Commented:
I have my own email server hosted actually.
I don't receive any email even if I allow relay.

Thanks

Author

Commented:
Hi Experts,

Anyne help me write a working Vbs script which can check free space of Logical drive and send email alert if free space is less than 1GB ?

I'll set that as task schedule to run every one hour and if free disk space is less than 1024MB, I would like to receive email alert.

Thanks a lot

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial