Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why do the progress meters across the top of the screen in htop show CPU usage consistently above >90% while the numbers in the table below show a nearly idle system with CPU usage and load average at 0.0%?

partial htop screen grab

share|improve this question
1  
I have the exact same issue and I am also on a Dreamhost VPS (virtual private server). – duality_ Jan 30 '13 at 22:22
    
@duality_, thanks for the confirmation. – matt wilkie Jan 31 '13 at 17:05
    
BTW, look at my example, it's even worse: demo.ddesign.si/temp/dh3.png – duality_ Jan 31 '13 at 22:06
up vote 5 down vote accepted

htop is unaware it is running on a kernel level virtualized environment (Dreamhost VPS is using VServer technology). It is then showing the CPU usage for all the OS instances sharing the same kernel, not just yours.

Have a look to vtop output which sho ws all processes sharing the CPUs, not just the ones in your container.

If vtop is not installed, and this is probably expected for a commercial solution as one wouldn't like to a customer to see what processes are running other customers, there is no way to fix the issue from inside your container, unless patching top source to compute CPU usage instead of getting it from the kernel statistics.

It might do it by summing up CPU usage of all the processes running in your VServer, e.g.:

ps aux | awk '
    {cpu+=$3; ram+=$6} 
    END {printf("cpu: %d%%, RAM: %.2f MiB\n",cpu,ram/1024) }'
share|improve this answer
    
+1 for the explanation; top reports similarly to htop on this machine. Vtop not tested as not installed. Marking this as accepted because it answers "why?", though it doesn't address the implicit "and what can be done about it?", as that was unspoken – matt wilkie Mar 22 '13 at 17:49

This sort of inconsistency is usually indicative of high processor usage by kernel threads, which aren't displayed in htop by default. To display them, in htop go to Setup, then Display options, and then uncheck Hide kernel threads. This should allow you to see the thread(s) that are responsible.

You can also disable this behaviour by setting hide_kernel_threads to 0 in ~/.htoprc.

share|improve this answer
2  
thanks Chris. I did that but the table values are still 0%. Maybe this is something peculiar to running in a virtual machine? The host is Virtual Private Server (on Dreamhost.com). – matt wilkie Feb 17 '12 at 21:37

Try launching htop with sudo. You need root access to see those active threads in the table.

share|improve this answer
    
I don't know how well or not this works on regular virtualized environments, if there is such a thing as regular, but doesn't work on dreamhost VPS. – matt wilkie Mar 22 '13 at 17:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.