summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 59a008e)
raw | patch | inline | side by side (parent: 59a008e)
author | Fabien Wernli <cpan@faxm0dem.org> | |
Tue, 25 Oct 2011 13:15:16 +0000 (15:15 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 25 Nov 2011 10:24:11 +0000 (11:24 +0100) |
Locked memory is now only tracking non-kernel locked memory.
We add kernel and unusable memory.
Source: http://www.brendangregg.com/K9Toolkit/swapinfo
Change-Id: I4f4d281e991068dc845d8c3615d285fc2a3296c8
We add kernel and unusable memory.
Source: http://www.brendangregg.com/K9Toolkit/swapinfo
Change-Id: I4f4d281e991068dc845d8c3615d285fc2a3296c8
src/memory.c | patch | blob | history |
diff --git a/src/memory.c b/src/memory.c
index b79a74b7cb42a307916eef911dbba3a968ac456a..d1cd32618094dc73a2c63cbc67cf43f2048b9105 100644 (file)
--- a/src/memory.c
+++ b/src/memory.c
/* #endif KERNEL_LINUX */
#elif HAVE_LIBKSTAT
+ /* Most of the additions here were taken as-is from the k9toolkit from
+ * Brendan Gregg and are subject to change I guess */
long long mem_used;
long long mem_free;
long long mem_lock;
+ long long mem_kern;
+ long long mem_unus;
+
+ long long pp_kernel;
+ long long physmem;
if (ksp == NULL)
return (-1);
mem_used = get_kstat_value (ksp, "pagestotal");
mem_free = get_kstat_value (ksp, "pagesfree");
mem_lock = get_kstat_value (ksp, "pageslocked");
+ mem_kern = 0;
+ mem_unus = 0;
+
+ pp_kernel = get_kstat_value (ksp, "pp_kernel");
+ physmem = get_kstat_value (ksp, "physmem");
if ((mem_used < 0LL) || (mem_free < 0LL) || (mem_lock < 0LL))
return (-1);
if (mem_used < (mem_free + mem_lock))
return (-1);
+ mem_unus = physmem - mem_used;
mem_used -= mem_free + mem_lock;
+
+ /* mem_kern is accounted for in mem_lock */
+ if ( pp_kernel < mem_lock )
+ {
+ mem_kern = pp_kernel;
+ mem_lock -= pp_kernel;
+ }
+ else
+ {
+ mem_kern = mem_lock;
+ mem_lock = 0;
+ }
+
mem_used *= pagesize; /* If this overflows you have some serious */
mem_free *= pagesize; /* memory.. Why not call me up and give me */
mem_lock *= pagesize; /* some? ;) */
+ mem_kern *= pagesize; /* it's 2011 RAM is cheap */
+ mem_unus *= pagesize;
memory_submit ("used", mem_used);
memory_submit ("free", mem_free);
memory_submit ("locked", mem_lock);
+ memory_submit ("kernel", mem_kern);
+ memory_submit ("unusable", mem_unus);
/* #endif HAVE_LIBKSTAT */
#elif HAVE_SYSCTL