Before investing in an expensive tool to monitor the performance of your various applications, it’s important to know that Windows is equipped with many of the tools you need. If the applications provide performance counters, the Performance Monitor utility makes it easy to keep track of dynamically changing statistics.
I’ll use an example to illustrate:
I often support the modusGate and modusMail applications (a spam filtering gateway and mail server, respectively). The number of messages accumulating in the queues must be counted in real time. If the mail can’t be delivered to remote destinations for some reason, such as when a DNS server goes down, it stands to reason that the outgoing delivery queue will pile up.
Since a performance counter exists for that measurement, it’s possible to create an alert that triggers an email when a problem occurs. The email can be sent to a device of your choice, such as a Blackberry.
Here’s how you set it up:
1. Create a command-line script (batch file) that will be called to actually send the alert
First, I usually create a folder to store my task files (i.e., C:tasks). So in this folder I would create the batch file needed to send an alert to my cell phone. The message will be sent via the mail server used by my cell phone service provider.
To actually send an email from the command line, I use a nifty tool called bmail.exe from Beyond Logic. You can get it from here: http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm
Put the bmail.exe tool in the same folder where the script will be stored (or place it somewhere in the system path).
Here is my sample batch file or script, which you can test yourself by substituting your own addresses:
2. Use Performance Monitor (or PerfMon) to identify the counter to be monitored and set the threshold trigger to call the script
Here’s the procedure for Windows 2003:
- Go to Start > Run > Perfmon.msc
- Expand Performance Logs and Alerts
3. Right-click Alerts, select New Alert Settings and enter a name
4. In the new Alert dialog, fill in the information and click Add to select the performance counter. In my case, I wanted to monitor the Outbound Delivery Queue Length.
5. Set the threshold value that will trigger your script. In my case, I set it to 5000.
6. Next, open the Action tab and specify the script to trigger
7. When you click Apply, it will ask you for credentials: use an account that has sufficient privilege to run the script.
Assuming you tested the script beforehand and it was shown to work, you should get an email or alert when the counter passes the threshold you specified.
In Windows 2008, the procedure is a bit more complicated because the settings are in different locations. I will provide you with the details in my next post.
Leave a Comment