LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 04-18-2012, 02:23 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Rep: Reputation: 30
top and ps


Hello

I am monitoring clamd (clamAV antivirus usage) . If I use top I receive this

28562 root 25 0 381m 317m 2076 R 100 8.0 0:41.35 clamd

100% cpu usage due to clamd

If in the same time I execute this ps command
ps aux | grep "clamd"
root 28562 6.1 8.1 392088 330376 ? Ssl 02:07 0:41 /usr/sbin/clamd

6.1% cpu usage used by clamd

Which is correct , ps which is reporting 6.1% or top which is reporting 100% ?

I have an Intel Xeon E5430 @ 2.66GHz with 8 cores .


Thank you
Graziano
 
Old 04-18-2012, 02:45 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,466

Rep: Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213
I assume top displays 100% of one core, ps displays 6.1% of the full capacity.
 
Old 04-18-2012, 02:57 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,050

Rep: Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971
They are both correct.
Understand what you are measuring before even considering comparing the results. Top, when run interactively, displays interval usage - "ps" displays usage since process start.
Potentially vastly different - especially on multi-cores.
 
Old 04-18-2012, 03:09 AM   #4
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by syg00 View Post
They are both correct.
Understand what you are measuring before even considering comparing the results. Top, when run interactively, displays interval usage - "ps" displays usage since process start.
Potentially vastly different - especially on multi-cores.
So , if I want to know the "current" usage , top should be better , am I correct ? But , is it 100% of a single core , right ?
 
Old 04-18-2012, 03:18 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,050

Rep: Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971
Yes - it is not normalized.
For multi-threaded apps, it is not uncommon to see several hundred percent reported.
 
Old 04-18-2012, 03:19 AM   #6
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,466

Rep: Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213
see man top:
k: %CPU -- CPU usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.
 
Old 04-18-2012, 03:51 AM   #7
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by syg00 View Post
Yes - it is not normalized.
For multi-threaded apps, it is not uncommon to see several hundred percent reported.
Clamd should not be a multi-threaded app. So 100% should be "100% single core" .
 
Old 04-18-2012, 04:03 AM   #8
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by pan64 View Post
see man top:
k: %CPU -- CPU usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.
interesting .. using "I" all the values are divided by 8 which is the number of my cores , thank you.
BTW I was thinking top was doing this automatically .

Last edited by graziano1968; 04-18-2012 at 04:06 AM.
 
Old 04-18-2012, 04:06 AM   #9
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by syg00 View Post
They are both correct.
"ps" displays usage since process start..
I read ps documentation , and truly I can't see that the values are a medium since the process start. However
do you think possible to receive current usage (not from the start) using ps ?

Last edited by graziano1968; 04-18-2012 at 04:20 AM.
 
Old 04-18-2012, 04:14 AM   #10
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,466

Rep: Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213
man ps see NOTES:
CPU usage is currently expressed as the percentage of time spent
running during the entire lifetime of a process. This is not ideal,
and it does not conform to the standards that ps otherwise conforms to.
CPU usage is unlikely to add up to exactly 100%.


but unfortunately it may slightly differ on some linux.
 
Old 04-18-2012, 04:16 AM   #11
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by pan64 View Post
see man top:
k: %CPU -- CPU usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.

do you think possible to toggle Irix/Solaris when the interactive mode is off

for example
# top -n1 | grep "clamd"

however I would have Irix
 
Old 04-18-2012, 04:30 AM   #12
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,466

Rep: Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213Reputation: 1213
Quote:
Originally Posted by graziano1968 View Post
do you think possible to toggle Irix/Solaris when the interactive mode is off
see the man page:

Startup Defaults

The following startup defaults assume no configuration file, thus no user customizations. Even so, items shown with an asterisk ('*') could be overridden through the command-line.

Global_defaults 'A' - Alt display Off (full-screen) * 'd' - Delay time 3.0 seconds 'I' - Irix mode On (no, 'solaris' smp) * 'p' - PID monitoring Off * 's' ...

I can be only toggled using interactive mode
 
  


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
Threatpost's List of the Top 10 Security Top 10 Lists win32sux Linux - Security 3 02-02-2011 01:20 AM
High Load Averages on my Forum- whostmgr2 - top ./top ohlookaforum Linux - Server 6 08-09-2010 05:26 PM
LXer: Firebird download statistics : Top Country : Brazil , Top OS: Linux LXer Syndicated Linux News 0 05-31-2010 07:00 AM
LXer: Can You Top This? 15 Practical Linux Top Command Examples LXer Syndicated Linux News 0 01-09-2010 09:42 PM


All times are GMT -5. The time now is 01:16 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration