-   Linux - General (
-   -   top command issue (

Manjunath1847 07-19-2012 07:22 AM

top command issue

While debugging my linux application program, related to performance, sometimes I see top reporting huge value for %cpu usage. My system has 2 CPU. So I believe, what ever may be the application, %cpu utilization for any process can never go beyond 200% max. But when I run the top in batch mode and with 0 time gap on my application (i.e. top -b -d0 -p <app_pid>), I see at some point of time %cpu usage showing more than 1000 like 1657 or 1732. Can %cpu usage for an application can really go to such values or is it a top bug? Any ideas here.

Thanks in advance.


syg00 07-19-2012 07:28 AM

"-d0" makes no sense.
Garbage in, garbage out.

Manjunath1847 07-20-2012 12:08 AM

I suspect my application takes high CPU for very short interval of time - for less than 1 second. So I need to constantly monitor the %cpu usage of my process. If I give -d1, 1 second I believe is a big value, and I may miss the high cpu hit.

syg00 07-20-2012 01:36 AM

You can use fractions of a second with the -d (0.2 say)
Or better try collectl which has a daemon option and should give you much better data. This mention will no doubt cause the developer to drop by and offer better advice.

markseger 07-23-2012 05:40 PM

syg00 loves to tickle me and once again has succeeded. ;)
If you really want to take a real close look at a specific application, running collectl with --procfilt pointing you app is extremely efficient. while I haven't measured this in awhile, I'd bet you could sample every 0.01 second and not put much of a load on the system. you could also run as a daemon as suggested but at a monitoring interval with that sort of a frequency you will generate a lot of data.

All times are GMT -5. The time now is 02:50 AM.