From: Fabien Wernli Date: Tue, 25 Oct 2011 13:15:16 +0000 (+0200) Subject: This improves solaris memory plugin granularity. X-Git-Tag: collectd-4.10.5~11 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4e613c118e301a1a6a70336cd7b65bf18b4bc7b0;p=collectd.git This improves solaris memory plugin granularity. 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 --- diff --git a/src/memory.c b/src/memory.c index b79a74b7..d1cd3261 100644 --- a/src/memory.c +++ b/src/memory.c @@ -321,9 +321,16 @@ static int memory_read (void) /* #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); @@ -331,20 +338,43 @@ static int memory_read (void) 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