Why does htop meter show >90% while table is 0.0%

htoptop

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

Best Answer

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) }'
Related Question