From f615c85dc670e0062d61d76af4e7db8e4c9a8ea5 Mon Sep 17 00:00:00 2001 From: Zhangxiaoyu Date: Fri, 24 Jul 2020 16:02:18 +0800 Subject: [PATCH] stats info add cache/total cache field Signed-off-by: Zhangxiaoyu --- src/json/schema/container/info.json | 9 +++++++++ src/lcrcontainer.h | 3 +++ src/lcrcontainer_execute.c | 3 +++ 3 files changed, 15 insertions(+) diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json index 654f02f..de6557c 100644 --- a/src/json/schema/container/info.json +++ b/src/json/schema/container/info.json @@ -43,6 +43,15 @@ }, "kmem_limit": { "type": "uint64" + }, + "status": { + "type": "string" + }, + "cache": { + "type": "uint64" + }, + "cache_total": { + "type": "uint64" } } } diff --git a/src/lcrcontainer.h b/src/lcrcontainer.h index 52bc961..9b41fd9 100644 --- a/src/lcrcontainer.h +++ b/src/lcrcontainer.h @@ -96,6 +96,9 @@ struct lcr_container_state { /* Kernel Memory usage */ uint64_t kmem_used; uint64_t kmem_limit; + /* Cache usage */ + uint64_t cache; + uint64_t cache_total; }; typedef enum { diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c index 8147223..1486d2a 100644 --- a/src/lcrcontainer_execute.c +++ b/src/lcrcontainer_execute.c @@ -546,6 +546,9 @@ void do_lcr_state(struct lxc_container *c, struct lcr_container_state *lcs) lcs->mem_limit = stat_get_ull(c, "memory.limit_in_bytes"); lcs->kmem_used = stat_get_ull(c, "memory.kmem.usage_in_bytes"); lcs->kmem_limit = stat_get_ull(c, "memory.kmem.limit_in_bytes"); + + lcs->cache = stat_match_get_ull(c, "memory.stat", "cache", 1); + lcs->cache_total = stat_match_get_ull(c, "memory.stat", "total_cache", 1); } #define ExitSignalOffset 128 -- GitLab