2017-06-27 01:51 AM
I am using perf-object-get-instances to fetch CPU busy percentage with object : system, instance : system and counter : cpu_busy. However, the returned value is 11 digit number.
How do I convert this to percentage ?
Is there any other way to fetch this information ?
Solved! SEE THE SOLUTION
2017-06-27 06:37 AM
In order to get the value you want you need the counter itself (cpu_busy) and the base counter (which I believe is processor_elapsed_time). You would then need to read the values at two different points in time and do some math...
# where t1 = first reading and t2 = second reading... ((t2.cpu_busy - t1.cpu_busy) / (t2.processor_elapsed_time - t1.processor_elapsed_time)) * 100 = % CPU busy during that time span
The base counter, if one is used, is returned back when you query the perf-object-counter-list-info API.
In general there are several different types of counters you'll find...
Hope that helps!