how to get the current HN CPU utilization by particular CT [message #42699] |
Thu, 12 May 2011 14:19 |
knawnd
Messages: 27 Registered: April 2011
|
Junior Member |
|
|
Hi!
Sorry if that question has been already asked and answered before but I
couldn't found the reply.
I wonder what the proper way is to determine the current HN CPU
utilization by particular container? I need to know what percentage from
total hardware node CPU power a certain CT consumes. It is mentioned in
[1] the CPUUNITS and CPULIMIT parameters but as far as I understand
they are used to set some HN CPU usage limits (mini and max
I wonder If the following algorithm is the proper one.
1) If CPULIMIT is not set then a formula would be as below:
(CPUUNITS assigned to particular CT) x (summary of user and system CPU
consumption shown by top inside the CT) / (Power of the node" produced
by vzcpucheck).
For example,
ct_cpuunits=`vzcpucheck -v|grep 139`
ct_user_cpu=`vzctl exec 139 top -bn1|grep -i "cpu(s)"|cut -d: -f2|awk
{'print $1'}`|cut -d% -f1
ct_sys_cpu=`vzctl exec 139 top -bn1|grep -i "cpu(s)"|cut -d: -f2|awk
{'print $2'}`|cut -d% -f1
total_hw_cpu=`vzcpucheck |tail -1|cut -d: -f2|tr -d '[:space:]'`
ct_cpu_usage = $ct_cpuunits * ($ct_user_cpu+$ct_sys_cpu) / $total_hw_cpu
2) if CPULIMIT is set then
(CPULIMIT assigned to particular CT) x (summary of user and system CPU
consumption shown by top inside the CT)
Or there is a simpler way?
Thanks!
Nikolay.
[1] http://wiki.openvz.org/Resource_shortage#CPU
|
|
|