I'm querying the Kubernetes kubelet API (curl -s http://localhost:10255/stats/summary) for CPU/Memory statistics and the CPU info is showing up as follows.
"cpu": {
"time": "2016-08-04T22:48:22Z",
"usageNanoCores": 6392499,
"usageCoreNanoSeconds": 3270519504746
},
How do I convert usageNanoCores or usageCoreNanoSeconds to CPU utilization percentage?
If a process were to run on one cpu continuously for a second, its usage will be 1e+9 nanoseconds. If it ran on
n
cores continuously its usage will n * 1e+9 nanoseconds.Percentage will be usage_in_nanoseconds / (capacity_in_absolute_cores * 1e+9).
*source: https://github.com/kubernetes/heapster/issues/650#issuecomment-147795824