Hello all,
This patch adds a new metric for memory module: Large Page Used.
Although Linux currently support the dynamic allocation, this metric
could be useful to show how many large pages a system used over a
period, so a system administrator can use it to enforce a threshold or
limits.
OBS:
1) I implemented it only for Linux and I tested on both PPC64 and ia32
(although on my i386 box I haven't used any large pages).
--- monitor-core/libmetrics/libmetrics.h (revision 2318)
+++ monitor-core/libmetrics/libmetrics.h (working copy)
@@ -70,6 +70,7 @@
g_val_t mem_shared_func(void);
g_val_t mem_buffers_func(void);
g_val_t mem_cached_func(void);
+ g_val_t mem_huge_page_used(void);
g_val_t swap_free_func(void);
g_val_t gexec_func(void);
g_val_t heartbeat_func(void);
Index: monitor-core/libmetrics/linux/metrics.c
===================================================================
--- monitor-core/libmetrics/linux/metrics.c (revision 2318)
+++ monitor-core/libmetrics/linux/metrics.c (working copy)
@@ -1080,6 +1080,38 @@
return val;
}
+g_val_t
+mem_huge_page_used( void )
+{
+ /* Total used Large pages is:
+ * (HugePages_Total - HugePages_Free) + HugePages_Rsvd
+ */
+ char *p;
+ g_val_t val;
+ unsigned int total = 0;
+ unsigned int free = 0;
+ unsigned int rsvd = 0;
+
+ p = strstr(update_file(&proc_meminfo), "HugePages_Total:");
+ if (p) {
+ p = skip_token(p);
+ total = atoi( p );
+ }
+ p = strstr(update_file(&proc_meminfo), "HugePages_Free:");
+ if (p) {
+ p = skip_token(p);
+ free = atoi( p );
+ }
+ p = strstr(update_file(&proc_meminfo), "HugePages_Rsvd:");
+ if (p) {
+ p = skip_token(p);
+ rsvd = atoi( p );
+ }
+
+ val.f = (total - free) + rsvd;
+ return val;
+}
+
/* --------------------------------------------------------------------------- */
g_val_t
mtu_func ( void )
Index: monitor-core/gmond/modules/memory/mod_mem.c
===================================================================
--- monitor-core/gmond/modules/memory/mod_mem.c (revision 2318)
+++ monitor-core/gmond/modules/memory/mod_mem.c (working copy)
@@ -42,19 +42,21 @@
case 3:
return mem_buffers_func();
case 4:
+ return mem_huge_page_used();
+ case 5:
return mem_cached_func();
- case 5:
+ case 6:
return swap_free_func();
- case 6:
+ case 7:
return swap_total_func();
#if HPUX
- case 7:
+ case 8:
return mem_arm_func();
- case 8:
+ case 9:
return mem_rm_func();
- case 9:
+ case 10:
return mem_avm_func();
- case 10:
+ case 11:
return mem_vm_func();
#endif
}
@@ -70,6 +72,7 @@
{0, "mem_free", 180, GANGLIA_VALUE_FLOAT, "KB", "both", "%.0f", UDP_HEADER_SIZE+8, "Amount of available memory"},
{0, "mem_shared", 180, GANGLIA_VALUE_FLOAT, "KB", "both", "%.0f", UDP_HEADER_SIZE+8, "Amount of shared memory"},
{0, "mem_buffers", 180, GANGLIA_VALUE_FLOAT, "KB", "both", "%.0f", UDP_HEADER_SIZE+8, "Amount of buffered memory"},
+ {0, "huge_used", 180, GANGLIA_VALUE_FLOAT, "", "both", "%.0f", UDP_HEADER_SIZE+8, "Number of Large Pages used" },
{0, "mem_cached", 180, GANGLIA_VALUE_FLOAT, "KB", "both", "%.0f", UDP_HEADER_SIZE+8, "Amount of cached memory"},
{0, "swap_free", 180, GANGLIA_VALUE_FLOAT, "KB", "both", "%.0f", UDP_HEADER_SIZE+8, "Amount of available swap memory"},
{0, "swap_total", 1200, GANGLIA_VALUE_FLOAT, "KB", "zero", "%.0f", UDP_HEADER_SIZE+8, "Total amount of swap space displayed in KBs"},
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers