?
Solved

C# code to monitor CPU

Posted on 2004-03-22
5
Medium Priority
?
2,664 Views
Last Modified: 2007-12-19
i have to develop a C# code to monitor CPU and memory usage of any host in the Internet.Assume there is no security restriction
0
Comment
Question by:Hermoinee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:lorddef
ID: 10649780
I'm sure there is. Unless its a machine you have access to...
0
 
LVL 4

Expert Comment

by:kolpdc
ID: 10650314
i am absolutely sure that you do not have access from your computer to clients spread throughout the network. it should not be allowed. else you could collect all data of all cumputers connected to the internet.

if you are able to put little "satellite"-apps onto each client you want to monitor (for example in intranet), then there should be a possibility.
1.1) every satellite detects the data and writes it into a database (db, file, ...)
1.2.) ... sends collected data to a server containing more intelligence

2.) activeX-control and webbrowser? (microsoft-TECHNICs...;)
0
 
LVL 22

Accepted Solution

by:
cookre earned 2000 total points
ID: 10652924
Both of those requests can be handled by the c# WMI interface.

For available on the local box:
mgmtScope = new ManagementScope("root\\cimv2");
mgmtScope.Connect();
System.Management.ObjectQuery oqr = new System.Management.ObjectQuery("SELECT * FROM Win32_PerfRawData_PerfOS_Memory");
ManagementObjectSearcher query1r = new ManagementObjectSearcher(mgmtScope,oqr);
ManagementObjectCollection queryCollection1r = query1r.Get();            
foreach(ManagementObject mo in queryCollection1r)
       {
       return (UInt64)mo["AvailableBytes"];
       }  

Here's a description of what ManagementScope() looks like for remote boxes:
http://www.csharphelp.com/archives2/archive334.html

For CPU usage, you'll have to sift through these to decide which you want:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_perfformatteddata_perfos_processor.asp
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question