You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ez...@apache.org on 2023/02/03 18:24:04 UTC

[trafficserver] branch master updated: Added memory info to system_stats plugin (#9379)

This is an automated email from the ASF dual-hosted git repository.

eze pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 0e9ff82718 Added memory info to system_stats plugin (#9379)
0e9ff82718 is described below

commit 0e9ff8271811a46b46825fe22a272347b64df078
Author: Joshua Zenn <wo...@gmail.com>
AuthorDate: Fri Feb 3 13:23:56 2023 -0500

    Added memory info to system_stats plugin (#9379)
---
 doc/admin-guide/plugins/system_stats.en.rst      |  6 ++++++
 plugins/experimental/system_stats/system_stats.c | 14 ++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/doc/admin-guide/plugins/system_stats.en.rst b/doc/admin-guide/plugins/system_stats.en.rst
index d71460f2bb..3c62140257 100644
--- a/doc/admin-guide/plugins/system_stats.en.rst
+++ b/doc/admin-guide/plugins/system_stats.en.rst
@@ -55,6 +55,12 @@ Some example output is:
 	"plugin.system_stats.loadavg.five": 132032,
 	"plugin.system_stats.loadavg.ten": 88864,
 	"plugin.system_stats.current_processes": 503,
+	"plugin.system_stats.total_ram": 4127707136,
+	"plugin.system_stats.free_ram": 93474816,
+	"plugin.system_stats.shared_ram": 430710784,
+	"plugin.system_stats.buffer_ram": 399872000,
+	"plugin.system_stats.total_swap": 0,
+	"plugin.system_stats.free_swap": 0,
 	"plugin.system_stats.net.enp0s3.speed": 1000,
 	"plugin.system_stats.net.enp0s3.collisions": 0,
 	"plugin.system_stats.net.enp0s3.multicast": 0,
diff --git a/plugins/experimental/system_stats/system_stats.c b/plugins/experimental/system_stats/system_stats.c
index 347e75e866..e0442ec444 100644
--- a/plugins/experimental/system_stats/system_stats.c
+++ b/plugins/experimental/system_stats/system_stats.c
@@ -54,6 +54,14 @@
 // Process Strings
 #define CURRENT_PROCESSES "plugin." PLUGIN_NAME ".current_processes"
 
+// Memory/Swap Strings
+#define TOTAL_RAM  "plugin." PLUGIN_NAME ".total_ram"
+#define FREE_RAM   "plugin." PLUGIN_NAME ".free_ram"
+#define SHARED_RAM "plugin." PLUGIN_NAME ".shared_ram"
+#define BUFFER_RAM "plugin." PLUGIN_NAME ".buffer_ram"
+#define TOTAL_SWAP "plugin." PLUGIN_NAME ".total_swap"
+#define FREE_SWAP  "plugin." PLUGIN_NAME ".free_swap"
+
 // Base net stats name, full name needs to populated
 // with NET_STATS.infname.RX/TX.standard_net_stats field
 #define NET_STATS "plugin." PLUGIN_NAME ".net."
@@ -256,6 +264,12 @@ getStats(TSMutex stat_creation_mutex)
   statSet(LOAD_AVG_FIVE_MIN, info.loads[1], stat_creation_mutex);
   statSet(LOAD_AVG_FIFTEEN_MIN, info.loads[2], stat_creation_mutex);
   statSet(CURRENT_PROCESSES, info.procs, stat_creation_mutex);
+  statSet(TOTAL_RAM, info.totalram, stat_creation_mutex);
+  statSet(FREE_RAM, info.freeram, stat_creation_mutex);
+  statSet(SHARED_RAM, info.sharedram, stat_creation_mutex);
+  statSet(BUFFER_RAM, info.bufferram, stat_creation_mutex);
+  statSet(TOTAL_SWAP, info.totalswap, stat_creation_mutex);
+  statSet(FREE_SWAP, info.freeswap, stat_creation_mutex);
 #endif // #ifdef HAVE_SYS_SYSINFO_H
   netStatsInfo(stat_creation_mutex);