asp.netPRO




Subscription Services
Print Subscription
Online-Only Subscription
Renew Subscription
asp.netNOW Newsletter
Change of Address
Pay An Invoice
Subscription Packages

asp.netPRO
Articles
Podcasts
411asp.net Directory
New Products
Book Reviews
Blog Listings  
Awards- NEW
Crossword Answers- NEW
E-Newsletter Articles- NEW
Webcasts - NEW 
e-Learning - NEW 
Job Listings  
Product Reviews
Opinion
Back Issues
Reprints/E-prints



Contact Information
Contact Us
Advertise with Us
Write For Us




 
 
 











Co-Sponsored by:
Download your free trial now!


Latest Features

 •

Columns & Rows: Part II


 •

Model: The “M” in ASP.NET MVC


 •

Patterns & Practices


 •

XAML Marks the Spot


 •

Columns & Rows: Part I



Article Rating



Tell a friend
about this article!




asp:Feature

LANGUAGES: C#

ASP.NET VERSIONS: 2.0

 

WMI in .NET

Take a Close Look at Your System’s Performance

 

 

Windows Management Instrumentation (WMI) is a Microsoft technology that enables us to retrieve system-related information. It is efficient in retrieving both hardware-related and software-related information from a computer system. Using WMI, one can communicate with the Windows OS, the hardware devices, running processes, COM+ components, etc. The objective of this article is to provide the reader with a bird’s eye view of WMI, as well as a primer on its applicability.

 

What Is WMI?

Windows Management Instrumentation (WMI) is a technology that allows a robust, low-level communication with the Windows Operating System from Microsoft development environments. It can portray all details related to the hardware specifications of a computer system. It should be noted that the WMI classes are types defined using an abstract language called MOF (Managed Object Format) that predates the CLR. One can query for WMI data using the Windows Management Instrumentation Query Language (WQL), a subset of the American National Standard Query Language (ANSI SQL).

The following is an example of a WQL query:

 

SELECT * FROM Win32_Processor

 

Why WMI?

WMI is an extremely powerful technology that can be used to retrieve and monitor the system. It can be used in any of the following scenarios:

  • Retrieve hardware specifications and the Win 32 OS specifications for a system
  • Determine the CPU and memory load factors in a system
  • Work with performance counters to monitor application performance in a managed environment
  • Create applications for working with Mobile devices
  • Event notification and configuration management in distributed computing environments

 

Working with WMI in ASP.NET

WMI can be used in ASP.NET applications to track the application’s performance; it is supported by the following namespaces:

  • System.Diagnostics
  • System.Management
  • System.Management.Instrumentation

 

There are many classes and interfaces in the System.Diagnostics, System.Management, and System.Management.Instrumentation namespaces that can be used for reading WMI data.

 

Monitoring Performance

Performance Counters are used to retrieve performance-related information in the system. They can be used to monitor and manage the system’s details. They are organized by the following:

  • Category
  • Counter Name
  • Instance Name

 

The System.Diagnostics.PerformanceCounter class can be used to retrieve a variety of details related to the system’s hardware and OS details. As an example, we can retrieve the % CPU time using this code snippet:

 

PerformanceCounter performanceCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");

int requiredValue = performanceCounter.NextValue();

 

Note that the constructor of the PerformanceCounter class accepts the arguments as stated earlier. We can list the various performance counters by using the perfmon.exe tool and then selecting the Add Tool option. Moreover, VS.NET includes support for displaying performance counters using the Server Explorer.

 

Conclusion

There is a lot to the WMI architecture, including performance counters, event notifications, configuration management, and storage, all built for a distributed environment which makes WMI the preferred technology for monitoring applications on the Windows platform.

 

Working extensively in Microsoft technologies for more than 10 years, Joydip Kanjilal is a Senior Project Leader for a company in Hyderabad, India. His programming skills include C, C++, Java, C#, VB, VC++, ASP.NET, XML, and UML. He has worked with .NET and C# for more than five years. Reach Joydip at mailto:joydipkanjilal@yahoo.com.

 

 

 

 

Top of page


Penton Media

© 2009 Penton Media, Inc Terms of Use Privacy Statement