Solved

C# code to monitor CPU

Posted on 2004-03-22
5
2,657 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
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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
listing all functions in JavaScript 19 178
Adoquery sql  left join does not work 25 80
Java Loop 6 49
Windows and other UI names - The Proper names for the Various elements! 1 59
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now