From c834b85088e665bf5c64132bbb6b118f59499c00 Mon Sep 17 00:00:00 2001 From: jikai Date: Thu, 11 Jan 2024 20:36:56 +0800 Subject: [PATCH] add swap usage in lxc_container_metrics Signed-off-by: jikai --- ...-swap-usage-in-lxc_container_metrics.patch | 42 +++++++++++++++++++ lxc.spec | 9 +++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 0012-add-swap-usage-in-lxc_container_metrics.patch diff --git a/0012-add-swap-usage-in-lxc_container_metrics.patch b/0012-add-swap-usage-in-lxc_container_metrics.patch new file mode 100644 index 0000000..072dfa7 --- /dev/null +++ b/0012-add-swap-usage-in-lxc_container_metrics.patch @@ -0,0 +1,42 @@ +From 2857204830f0aea682f9fb261ac884d49f75925f Mon Sep 17 00:00:00 2001 +From: jikai +Date: Thu, 11 Jan 2024 20:32:17 +0800 +Subject: [PATCH] add swap usage in lxc_container_metrics + +Signed-off-by: jikai +--- + src/lxc/lxccontainer.c | 3 +++ + src/lxc/lxccontainer.h | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c +index 5720cf7..3a23152 100644 +--- a/src/lxc/lxccontainer.c ++++ b/src/lxc/lxccontainer.c +@@ -6093,6 +6093,9 @@ static bool do_lxcapi_get_container_metrics(struct lxc_container *c, struct lxc + metrics->cache_total = metrics_match_get_ull(c, cgroup_ops, "memory.stat", "total_cache", 1); + metrics->inactive_file_total = metrics_match_get_ull(c, cgroup_ops, "memory.stat", "total_inactive_file", 1); + ++ metrics->swap_used = metrics_get_ull(c, cgroup_ops, "memory.memsw.usage_in_bytes"); ++ metrics->swap_limit = metrics_get_ull(c, cgroup_ops, "memory.memsw.limit_in_bytes"); ++ + return true; + } + +diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h +index 06e8f0b..d5b67bb 100644 +--- a/src/lxc/lxccontainer.h ++++ b/src/lxc/lxccontainer.h +@@ -79,6 +79,9 @@ struct lxc_container_metrics { + uint64_t cache_total; + /* total inactive file */ + uint64_t inactive_file_total; ++ /* Swap usage*/ ++ uint64_t swap_used; ++ uint64_t swap_limit; + }; + #endif + +-- +2.33.0 + diff --git a/lxc.spec b/lxc.spec index 3d7da5a..ba64503 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 8 +%global _release 9 %global enable_isulad 1 Name: lxc @@ -20,6 +20,7 @@ Patch0008: 0008-bugfix-for-system-container-and-stream.patch Patch0009: 0009-bugfix-about-cgroup-mount-propagation-and-capabiliti.patch Patch0010: 0010-add-storage-block-code-for-embedded-image.patch Patch0011: 0011-skip-setup-console-if-disable-pty-and-fix-syscontain.patch +Patch0012: 0012-add-swap-usage-in-lxc_container_metrics.patch BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: pkgconfig(libseccomp) @@ -207,6 +208,12 @@ meson test -C build %endif %changelog +* Thu Jan 11 2024 jikai - 5.0.2-9 +- Type: bugfix +- ID:NA +- SUG:NA +- DESC: add swap usage in lxc_container_metrics + * Thu Jan 04 2024 zhangxiaoyu - 5.0.2-8 - Type: bugfix - ID:NA -- Gitee