summaryrefslogtreecommitdiff
path: root/0179-iSulad-support-shim-stats-cmd.patch
blob: b2a542ea868395cf5b14a573532419031a13ac6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From ab9c9d71482e355e0015ac1c6331849f4ff98ee0 Mon Sep 17 00:00:00 2001
From: zhongjiawei <zhongjiawei1@huawei.com>
Date: Fri, 10 Jan 2025 11:51:52 +0800
Subject: [PATCH 179/198] iSulad: support shim stats cmd

---
 src/daemon/modules/runtime/shim/shim_rt_ops.c | 32 +++++++++++++++++--
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/daemon/modules/runtime/shim/shim_rt_ops.c b/src/daemon/modules/runtime/shim/shim_rt_ops.c
index fce18ade..30b5e442 100644
--- a/src/daemon/modules/runtime/shim/shim_rt_ops.c
+++ b/src/daemon/modules/runtime/shim/shim_rt_ops.c
@@ -779,11 +779,37 @@ int rt_shim_listpids(const char *id, const char *runtime, const rt_listpids_para
     return 0;
 }
 
+static void transform_stats_info_from_runtime(struct Stats *stats,
+                                              struct runtime_container_resources_stats_info *info)
+{
+    if (info == NULL) {
+        return;
+    }
+    info->pids_current = stats->pids_current;
+    info->cpu_use_nanos = stats->cpu_use_nanos;
+    info->cpu_system_use = stats->cpu_system_use;
+    info->mem_used = stats->mem_used;
+    info->mem_limit = stats->mem_limit;
+    info->rss_bytes = stats->rss_bytes;
+    info->inactive_file_total = stats->inactive_file_total;
+    info->page_faults = stats->page_faults;
+    info->major_page_faults = stats->major_page_faults;
+    info->swap_used = stats->swap_used;
+    info->swap_limit = stats->swap_limit;
+    info->blkio_read = stats->blkio_read;
+    info->blkio_write = stats->blkio_write;
+}
+
 int rt_shim_resources_stats(const char *id, const char *runtime, const rt_stats_params_t *params,
                             struct runtime_container_resources_stats_info *rs_stats)
 {
-    ERROR("rt_shim_resources_stats not impl");
-    return -1;
+    struct Stats ss = { 0 };
+    if (shim_v2_stats(id, &ss) != 0) {
+        ERROR("rt_shim_stats failed");
+        return -1;
+    }
+    transform_stats_info_from_runtime(&ss, rs_stats);
+    return 0;
 }
 
 int rt_shim_resize(const char *id, const char *runtime, const rt_resize_params_t *params)
@@ -820,4 +846,4 @@ int rt_shim_kill(const char *id, const char *runtime, const rt_kill_params_t *pa
 int rt_shim_rebuild_config(const char *name, const char *runtime, const rt_rebuild_config_params_t *params)
 {
     return 0;
-}
\ No newline at end of file
+}
-- 
2.34.1