Computer Performance Monitoring Tool (written in C#)
After a long long time.. I finally got the time to post a blog (this
is due to my very busy schedule). Today I will talked about measuring
computer performance remotely using WMI classes
Problem at hand: We have this Pentium III server that chokes from time
to time, due to heavy load processes . The server runs several
distributed and web applications. To monitor it and prevent possible
slowdown I decided to create a tool that will track the server CPU%
utilization, Memory Used and Disk Usage levels. The tool will alert
user/administrator when one or all of these variables reached
pre-defined criteria (ie. CPU% >= 90%).
The Solution: Using the WMI classes, the tool will connect to the
remote server and get these informations:CPU, Memory and Disk
using System.Management; //Namespace for to access WMI classes
ConnectionOptions options = new ConnectionOptions();
options.Username = strUserName; options.Password = strPassword;
mgmtScope = new ManagementScope("\\\\" + strHostName +
"\\root\\cimv2",options);
//Get the CPU %
ManagementPath mPath_CPU = new ManagementPath();
mPath_CPU.RelativePath =
"Win32_PerfRawData_PerfOS_Processor.Name='0'";
mObject_CPU = new ManagementObject(mgmtScope,mPath_CPU,null);
//Memory Available (in MBytes)
ManagementPath mPath_Mem = new ManagementPath();
mPath_Mem.RelativePath = "Win32_PerfRawData_PerfOS_Memory";
mc = new ManagementClass(mgmtScope,mPath_Mem,null);
// Disk %
mPath_Disk = new ManagementPath();
mPath_Disk.RelativePath =
"Win32_PerfRawData_PerfDisk_PhysicalDisk.Name='_total'";
mObject_Disk = new ManagementObject(mgmtScope,mPath_Disk,null);
Here's a screenshot of the final product.
Value-added features are processes list, disk collection and user
sessions. This tool was written in C# (Visual Studio .NET). Take note
No comments:
Post a Comment