How to monitor application performance and send alerts on Windows Server 2008

Create a Data Collector Set to Monitor Performance Counters

http://technet.microsoft.com/en-us/library/cc722414.aspx

http://social.technet.microsoft.com/Forums/en-US/c076f0c3-3219-4d38-b90d-48578090c286/sending-email-on-perfmon-alert-windows-server-2003?forum=perfmon

http://support.microsoft.com/kb/324752/en-us

 

Written by Yves Lacombe on . Posted in Email Security & Antispam

 

In my previous article, I outlined how one could monitor a performance counter and send alerts to a pager or smartphone on a Windows 2003 server.

This is how to do it on Windows Server 2008:

  1. Create a command-line script (batch file) that will be called to send the alert.

First, I usually create a folder to store my task files (i.e., C:tasks), and this is where 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:

 

 

  1. 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 2008):

  1. Go to Start > Run >    Perfmon.msc
  2. Expand Data Collector Sets > User Defined  > New Data Collector Set

 

 

  1. Right-click and select New Collector Set
  2. Enter a name for the data collector, select Performance counter alert from the list and click Next.

 

 

  1. Select the counter you want to use for monitoring and add it to the counter list by clicking the Add button at the bottom and click OK.

In this example, I’m monitoring the Outbound Delivery Queue of my mail server.

 

 

  1. Enter the Limit (threshold) and click Next.

In my case, I want an alert if there are more than 200 messages in the outbound queue.

 

 

  1. Check Open properties for this data collector and click Finish.

 

 

  1. The collector information pane should appear next.

 

 

  1. Open the Alert Task tab.

 

 

  1.  In the Run this task… field, enter the location of the script you created to send alerts to you (in Step 1), and click OK to finalize.

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.

 

Most of the times, web hosting accounts get suspended due to the exceeding of CPU usage limits allocated to your server. In this tutorial, we will show you how to get high cpu usage alerts of server on your email. The following script on the server will automatically send alert on your email, when the disk space, high memory and cpu usage exceeds the limit.

Let’s see how…

Step 1: Download Blat from its official site and extract it in the root of the C:\ drive:

http://www.blat.net

Blat is a small, efficient SMTP command line mailer for Windows available for free.

Step 2: Create a batch file named “send.bat” and add the following code in it:

c:\blat\blat.exe -body %1 –f “ServerName” -server smtp.yoursite.com –to email@yoursite.com -subject “ALERT: ServerName CPU Usage High”
echo %1 > alert.out

Make sure you change the server name, smtp address, email with your own settings and simply save the batch file within the blat folder into the root drive.

Step 3: Now, right-click on the “My Computer” icon on your server and click the Manage. Open the options under “Performance logs >> Alerts” and right-click “Alerts” and choose “New Alert Settings“. (See image below)

Step 4: Enter a name for the new alert. (See image below)

Step 5: Select Performance Object as “Processor” and select “%Processor Time” from the counters list and click on the “Close” button. (See image below)

Step 6: On the next window, set a limit value when you wish to receive alert. For example: if you set a value of 90, you will receive an alert on your email if the CPU usage exceeds more than 90% for the time interval mentioned below. (See image below)

You can also run the alert on a different credentials, for that you just need to enter the username in the “Run As” field and click the “Set Password” button and fill out the rest of the credentials.

Step 7: Click on the “Action tab >> Tick the “Run this program” and click on the “Browse” button. Browse the “send.bat” file. (See image below)

Step 8: Lastly, Hit the OK button.

That’s it ! Now, simply right-click the alert and start it. From now on, whenever your server exceeds the CPU usage limit you have set, you will receive an email alert on your specified email address. This script is applicable only for Windows VPS and Windows Dedicated Server.

发表评论

电子邮件地址不会被公开。 必填项已用*标注