How CPU usage is calculated

How to prove CPU usage is correct and it shows real data with lveinfo? Let us explain how lvetop works before answering this question.

sshot-2015-07-27-_-16-00-30The lvetop utility, as well as lveps -d, show dynamic CPU (and other) usage, collected during 3 seconds period. Before iteration the process gets running PIDs/threads (lets call them list1), and after iteration it gets them again (list2). If thread is in both list1 and list2 it will show some CPU%. If thread is only in list1 but is not in list2, then it is shown as NA. All newly created threads that exist in list2 but are absent in list1 will not be shown.

sshot-2015-07-27-_-16-03-21 Without ‘-d’ key it shows static processes/threads that are running ‘now’. The values in CPU column (yellow square in this example) are the number of seconds LVE/process/thread has been running. This is an increasing counter and is reset with reboot or with ‘lvectl destroy UID/all‘.

 

Overall it is not a trivial task to show all the processes that generate CPU usage for any LVE, and process accounting is not cheap for system. To summarize – there is no way to prove CPU usage shown in lveinfo/lvetop, like for example memory usage: http://kb.cloudlinux.com/2014/08/checking-personal-users-disk-cache-if-lveinfo-show-memory-usage-but-no-processes-there/

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *