[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2668
  • Last Modified:

C# code to monitor CPU

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
Hermoinee
Asked:
Hermoinee
1 Solution
 
lorddefCommented:
I'm sure there is. Unless its a machine you have access to...
0
 
kolpdcCommented:
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
 
cookreCommented:
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now