Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-24-2006, 11:27 AM   #1
LQ Newbie
Registered: May 2006
Posts: 3

Rep: Reputation: 0
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.

Old 05-24-2006, 12:37 PM   #2
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,910

Rep: Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562
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.
Old 05-24-2006, 01:02 PM   #3
LQ Newbie
Registered: May 2006
Posts: 3

Original Poster
Rep: Reputation: 0
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
limit cpu % usage for a process student04 Linux - General 15 03-18-2014 07:22 PM
How to get %CPU usage of a process devershetty Linux - Newbie 1 08-18-2008 01:52 AM
How to get %CPU usage of a process devershetty Linux - Newbie 13 08-16-2008 11:51 AM
process cpu usage vanv101 Fedora 9 06-24-2005 05:53 PM
CPU usage of a process asharma Solaris / OpenSolaris 7 03-29-2003 02:17 PM

All times are GMT -5. The time now is 02:42 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration