Click here to Skip to main content
Click here to Skip to main content
Go to top

Monitor System Information

, 18 Jul 2009
Rate this:
Please Sign up or sign in to vote.
A program to monitor and collect basic system information from remote machines.

Introduction

Monitor Center is a system designed to help you control and monitor your computers in a local network. The system allows you to see, in real time, useful information about any of your computers using an easy interface that can be suited to your own needs.

This article supplies examples of how to access different information on the Windows Operating System, such as process information, performance counters, and basic system information.

MonitorSystem.gif

Background

The program uses the .NET Framework libraries in order to get the requested information.

Using the code

How can you use the program?

After you unzipp the demo file, copy MonitorCenter1.0.exe from the Server folder to any location on the server machine. This EXE is the central interface of the system from which you can perform all your actions on each one of the clients you wish to monitor (including the machine on which MonitorCenter1.0.exe is located). After this, copy the folder named Client to a location of your choice.

You can read the User Guide document that is included in the demo zip file for further instructions about using the program.

Now, the system is ready for use; just run both the server and client exe files! Here are some examples of collecting the required information.

Reading the processes information:

using System.Diagnostic;

Process[] ProcessList = Process.GetProcesses();

foreach (Process CurrProcess in ProcessList)
{
    Console.WriteLine("Process Name:" + CurrProcess.ProcessName);
    Console.WriteLine("Main Module FileName:" + CurrProcess.MainModule.FileName);
    Console.WriteLine("Start Time:" + CurrProcess.CurrProcess.StartTime);
}

The process owner, for example, is not part of the Process class, so we get this data from WMI:

using System.Management;

public string GetProcessOwner(int processID)
{
    string owner = string.Empty;
    string queryString = "Select * From Win32_Process Where ProcessID = " + processID;
    ManagementObjectSearcher searcher = new ManagementObjectSearcher(queryString);
    ManagementObjectCollection processList = searcher.Get(); 

    foreach (ManagementObject currentProcess in processList)
    {
        string[] argList = { string.Empty };
        int returnValue = Convert.ToInt32(currentProcess.InvokeMethod("GetOwner", argList));
        if (returnValue == 0)
            owner = argList[0];
    }

    return owner;
}

In order to get information of the Operating System performance counters, such as CPU usage, use the following code:

using System.Diagnostic;

PerformanceCounter CurrCounter = new PerformanceCounter("Processor%", 
                                 "ProcessorTime", "_Total");
int CPUTimeValue = CurrCounter.NextValue(); 

The information we collected was presented in line graphs which we built using ZedGraph. ZedGraph is an open source which you can download for free and use it to build any kind of graph you like.

All the above code examples are parts of the project source file.

Points of interest

Not all users have permissions to access system information. Moreover, sometimes, even the system administrator cannot access certain data. Use try and catch blocks when accessing information of the Operating System.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

NitzanO
Software Developer
United States United States
No Biography provided

Comments and Discussions

 
Questioncan it work internet??? Pinmemberjfan20919-Jul-09 2:59 
Generalmy vote of 1 PinmemberMaximus Byamukama16-Jul-09 1:02 
GeneralRe: my vote of 1 Pinmemberadambl17-Jul-09 2:05 
GeneralAwesome! [modified] PinmemberBit-Smacker14-Jul-09 8:27 
GeneralMore clarification PinmemberMd. Marufuzzaman7-Jul-09 22:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 18 Jul 2009
Article Copyright 2009 by NitzanO
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid