OpenVZ Forum


Home » General » Support » Calculating VE CPU Usage
Calculating VE CPU Usage [message #38480] Thu, 24 December 2009 20:53
xous is currently offline  xous
Messages: 1
Registered: December 2009
Junior Member
How should I be calculating per VE CPU usage

I'm reading the values from /proc/vz/vestat

idle_c is the change in number of idle cycles
user_j, nice_j, system_j is the change in usage in jiffies


$cpu_usage =  100 - (idle_c / (user_j + nice_j + system_j + idle_c) * 100);



To me the above seems incorrect because I'm mixing cycles and jiffies.


I've found the following definitions of jiffies and cycles


$seconds = $jiffies / $CONFIG_HZ;
$seconds = $cycles / $CPU_FREQ;



So I should be able rework this to:

$jiffies = $cycles / $CPU_FREQ * $CONFIG_HZ;


My code becomes:


$idle_j = $idle_c / $CPU_FREQ * $CONFIG_HZ;

$cpu_usage =  100 - (idle_j / (user_j + nice_j + system_j + idle_j) * 100);



Am I completely off base?
Previous Topic: how to separate this server for 3 VPS's
Next Topic: Multiple Networks on OpenVZ
Goto Forum:
  


Current Time: Wed Jul 17 07:42:01 GMT 2024

Total time taken to generate the page: 0.02918 seconds