interview question and answer

November 11, 2012

Monitoring free drive space with Windows Server 2008 R2 and Performance Monitor



Problem
You would like to monitor free drive space on a server with the native features of Windows Server 2008 R2 without having to purchase monitoring software such as SolarWinds, SCOM, etc.

Solution
I’ve found myself in plenty of situations where I need to set up a quick way of monitoring free drive space on various versions of Windows Server because I either don’t have access to the monitoring application that the company uses, lack of licenses for the monitoring application to add the new host or the company simply does not have monitoring.  When this situation comes across my deployments, I simply use the native Performance Monitor feature of Windows Server 2008 R2 to monitor and send an email alert to email addresses.  Note that this feature is also available in Windows Server 2003 but this blog post will just cover 2008.
Note that Microsoft has various articles that covers setting this up so I’ll include some of the links here:

HOW TO: Configure a Low Disk Space Alert by Using the Performance Logs and Alerts Feature in Windows Server 2003p://support.microsoft.com/kb/324796
Configure Windows Server 2008 to Notify you when Certain Events Occur http://technet.microsoft.com/en-us/magazine/ff458614.aspx
Create a Data Collector Set to Monitor Performance Counters
http://technet.microsoft.com/en-us/library/cc722414.aspx
The first step in setting the monitoring up is to open Performance Monitor and create an alert so begin by opening up the application in Administrative Tools then navigate to Data Collector Sets –> User Defined:
clip_image002
Right click on the User Defined node and select New –> Data Collector Set:
image
In the Create new Data Collector Set, type in a name for this collector, select Create manually (Advanced)and click Next:
clip_image002[4]
Select Performance Counter Alert and click Next:
clip_image002[6]
Click on the Add… button:
clip_image002[8]
Navigate to the Logical Disk selection:
clip_image002[10]
You’ll find various counters in this section and whether you prefer to use % Free Space or Free Megabytes will be based on the type of application and drive size you’ll be monitoring.  I personally prefer Free Megabytesbecause the drive I’m monitoring is a 1TB drive and setting up a hard threshold based on a constant value seems to make more sense:
clip_image002[12]
Note the logical drives are listed under the Instances of selected object so select the ones you’d like to monitor:
clip_image002[14]
Clicking on OK will bring you back to the Create new Data Collector Set window.  Proceed with setting a threshold:
clip_image002[16]
Notice how I’ve set the Alert when to Below and the Limit to 2048.  This simply means I’m setting a threshold to 2GB for each of the drives. Proceed with clicking the Next button when you’ve configured all of the drives’ thresholds:
clip_image002[18]
Unless you have restrictions on the service account, proceed by click on Finish:
clip_image002[20]
Notice how a new collector is now set up:
clip_image002[22]
Continue by right clicking on the data collector and choose properties:
image
Navigate to the Alert Action tab and select the Log an entry in the application event log:
clip_image002[24]
Start the data collector set by right clicking on the object and selecting Start:
image
Unlike Windows Server 2003, the data collector DOES NOT write logs to the application logs but rather the following log:
Applications and Services Logs/Microsoft/Windows/Diagnosis-PLA/Operational
image
Note that I changed the threshold from 2048 to 20480 so that I could trigger the alert:
image
Now that we’ve generated an information event with the ID 2031 in the logs, we can proceed with setting up a task to send an email to an address.  Proceed by right clicking on the event and select Attach Task To This Event…:
image
Give the task a meaningful name and proceed by clicking the Next button:
clip_image002[26]
There isn’t much to change in the When an Event Is Logged so continue by clicking on the Next button:
clip_image002[28]
In the Action step, change the action from Start a program to Send an e-mail:
clip_image002[30]
clip_image002[32]
Fill in the appropriate fields (make sure this server can relay mail off of your SMTP server:
image
Complete the wizard:
clip_image002[34]
clip_image002[36]
Trigger an event to test and you should see an email similar to the following:
image
I hope this helps anyone looking for a quick and dirty way to monitor free drive space on their servers.

No comments: