This method is responsible to fetch all CPU Cgroup Stats and store data
into virDomainStatsRecordPtr structure.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/lxc/lxc_driver.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 72639e0d7d..86c98517d2 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -5277,6 +5277,45 @@ lxcDomainGetMetadata(virDomainPtr dom,
return ret;
}
+static int
+lxcDomainGetStatsCpu(virDomainObjPtr dom,
+ virDomainStatsRecordPtr record,
+ int *maxparams)
+{
+ virLXCDomainObjPrivatePtr priv = dom->privateData;
+ unsigned long long cpu_time = 0;
+ unsigned long long user_time = 0;
+ unsigned long long sys_time = 0;
+ int err = 0;
+
+ if (!priv->cgroup)
+ return 0;
+
+ err = virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time);
+ if (!err && virTypedParamsAddULLong(&record->params,
+ &record->nparams,
+ maxparams,
+ "cpu.time",
+ cpu_time) < 0)
+ return -1;
+
+ err = virCgroupGetCpuacctStat(priv->cgroup, &user_time, &sys_time);
+ if (!err && virTypedParamsAddULLong(&record->params,
+ &record->nparams,
+ maxparams,
+ "cpu.user",
+ user_time) < 0)
+ return -1;
+ if (!err && virTypedParamsAddULLong(&record->params,
+ &record->nparams,
+ maxparams,
+ "cpu.system",
+ sys_time) < 0)
+ return -1;
+
+ return 0;
+}
+
static virDomainStatsRecordPtr
lxcDomainGetStats(virConnectPtr conn,
virDomainObjPtr dom)
--
2.19.1