How to get %CPU usage of a process
Hi All,
I'm working on a client server application and i've a feature to calculate CPU utilization of server and display on client GUI panel. My server is running on Mono on SUSE linux. I know there have been similar threads open before for %CPU usage, but since there has been no discussion on them since 2003, i've started a new thread. I'm trying to find Peak CPU usage and average CPU usage of a process my server is running on. I also want to do it programmatically and not from command line. I've implemented a similar feature for windows using System.Management API in C#.NET. But Mono doesn't support System.Management API yet. Is there a way i can calculate CPU usage of a process programatically on linux. Thanks, Reema |
The top command is often used to do this.
Also, take a look at the various "files" in /proc. These will tell you a lot of real-time information about the processes on the system. Before you get too far, though, "google it" .. or rather, search this web-site. Monitoring the CPU usage et al of a process is a frequently-requested action that ought not require a new tool to be written from scratch. |
Thanks and i'm actually trying everywhere. But the bad news is, my deadline is tomorrow. I can't beleive how difficult is it to find CPU usage information for a process on linux :( as compare to how easy it is on windows to just use an .NET API.
|
All times are GMT -5. The time now is 08:24 PM. |