LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-16-2008, 05:15 PM   #1
jr8rdt
LQ Newbie
 
Registered: Oct 2006
Posts: 17

Rep: Reputation: 0
PS command capturing CPU


I want to capture the cpu utilization of a process.
so I write a small script using this command

ps -o pid,pcpu <PID>

it does give me the cpu util for that pid however the number is different from TOP (irix on). the number from TOP is more accurate. since I have dual core cpu , how can I make the "ps" command works ?

thanks
 
Old 05-16-2008, 09:04 PM   #2
aus9
LQ Guru
 
Registered: Oct 2003
Posts: 5,124

Rep: Reputation: Disabled
don't use irix but try
Code:
ps aux
to get a bigger range of pids
 
Old 05-16-2008, 09:39 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,848

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
Quote:
Originally Posted by jr8rdt View Post
it does give me the cpu util for that pid however the number is different from TOP (irix on). the number from TOP is more accurate. since I have dual core cpu , how can I make the "ps" command works ?
Noooo ...
The number from "top" is a different metric to that presented by "ps". Neither is necessarily more accurate than the other, given that /proc is the source of the data used by both.

Read the man pages, then decide what it really is you are trying to measure.
 
Old 05-17-2008, 09:08 PM   #4
jr8rdt
LQ Newbie
 
Registered: Oct 2006
Posts: 17

Original Poster
Rep: Reputation: 0
the program that I am tracking is a single threaded program. does that mean pcpu is more accurate ?
I do have quad dual core CPU (4 @dual core).

I read somewhere that pcpu is for the whole machine ie a CPU hog(100%) on a 4 CPU machine would register as 25%. Is this correct? So why then in my case , pcpu gives 75% and top irix on gives 25%?
What I want is a total CPU percentage.just like the description of pcpu I found on the net
Could you please help me understand ?

btw is there a command or switch to turn on irix mode in top if I want to use batch?

thanks
 
  


Reply


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
Capturing output from background FTP command Lazypete Linux - Server 6 05-22-2008 11:41 AM
Perl: Running Command line apps in background and capturing output s0l1dsnak3123 Programming 8 03-28-2008 02:24 PM
expect_out(buffer) is not capturing all output from a Cisco IOS command eentonig Programming 1 01-30-2008 08:29 AM
What command gives me CPU load? nodger Linux - Software 2 01-09-2005 09:28 AM
Capturing video with Cinelerra works, capturing video with Xawtv doesn't! seaelf Slackware 0 06-27-2004 06:18 PM


All times are GMT -5. The time now is 06:28 AM.

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