Send email alerts for low disk space using perfmon.exe in Windows using bmail.exe

I needed to set up email alerts for one of the servers so when disc space dropped below a threshold it would email the team to deal with the issue. I know you can use full monitoring packages for this kind of thing (like Nagios etc) but in this case that kind of monitoring is overkill. I used the bmail.exe command line SMTP mailer from but you can use any command line mailer you want really.

First I created a simple .cmd script to send the warning email, making sure to include %1 so as to include any command line arguments produced by perfmon.exe. Apparently if you don’t have any commmand line arguments when you set up alerts the script will not be called:

c:\emailfromcmdbmail.exe -s mail.server.ip -t -f email@addresstosendfrom -h -a “Disk Space Warning on” -b “Less than 100GB free on Please free space to ensure weekly backups can continue. Free: %1 MB”

The direct path to the executable must be explicitly stated, otherwise it will not be called and no error/warning will be shown.

Now open perfmon.exe, expand “Performance Logs and Alerts” – “Alerts”. Right click and select “New Alert Settings…” and choose a name. The comment can be anything.

Now add a counter. I used “LogicalDisk” – “Free Megabytes” – “C:” to select free space on the C drive. Set “Alert when the value is:” to “Under” and the “Limit:” to whatever free space warning you need. I set the sample interval to 3 hours. Now select run as to be an administrator on the machine and set the password.

Click the action tab and select “Run this program:” and put in the path to your .cmd file, in my case “C:emailfromcmdemailteam.cmd”. Select “Measured value” in “Command Line Arguments…”. Now click OK, you may need to enter the password for the user with permission to run your .cmd.

Done, now your server will email you when drive space gets low.

9 thoughts on “Send email alerts for low disk space using perfmon.exe in Windows using bmail.exe

  1. Perfect solution to a problem that has been plaguing me for awhile. No more manually checking the disk space on the server since it can now be automated. Thanks for the info.

  2. I guess I am missing something on my cmd file. I can not run the alert to test . Can some one write the code that you put on .cmd file? Thanks in advance !

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>