[collectd] swap.c problem on Solaris

Christophe Kalt collectd at klb.taranis.org
Fri Jun 9 19:19:30 CEST 2006


WITH Diff without the typo..


Sorry!
-------------- next part --------------
diff -ru collectd-3.9.3/src/swap.c collectd-3.9.3+swap/src/swap.c
--- collectd-3.9.3/src/swap.c	2006-06-01 17:07:10.000000000 -0400
+++ collectd-3.9.3+swap/src/swap.c	2006-06-09 12:56:26.407514400 -0400
@@ -162,26 +162,27 @@
 		return;
 
 	/* 
-	 * Calculations learned by reading
-	 * http://www.itworld.com/Comp/2377/UIR980701perf/
+	 * Calculations from:
+	 * http://cvs.opensolaris.org/source/xref/on/usr/src/cmd/swap/swap.c
+         * Also see:
+	 * http://www.itworld.com/Comp/2377/UIR980701perf/ (outdated?)
+         * /usr/include/vm/anon.h
 	 *
-	 * swap_resv += ani_resv
-	 * swap_alloc += MAX(ani_resv, ani_max) - ani_free
-	 * swap_avail += MAX(ani_max - ani_resv, 0) + (availrmem - swapfs_minfree)
-	 * swap_free += ani_free + (availrmem - swapfs_minfree)
-	 *
-	 * To clear up the terminology a bit:
-	 * resv  = reserved (but not neccessarily used)
-	 * alloc = used     (neccessarily reserved)
-	 * avail = not reserved  (neccessarily free)
-	 * free  = not allocates (possibly reserved)
+         * In short, swap -s shows: allocated + reserved = used, available
+         *
+         * However, Solaris does not allow to allocated/reserved more than the
+         * available swap (physical memory + disk swap), so the pedant may
+         * prefer: allocated + unallocated = reserved, available
+         * 
+         * We map the above to: used + resv = n/a, free
+         *
+         * Does your brain hurt yet?  - Christophe Kalt
 	 */
-	swap_resv  = pagesize * ai.ani_resv;
-	swap_alloc = pagesize * (MAX(ai.ani_resv, ai.ani_max) - ai.ani_free);
-	swap_avail = pagesize * (MAX(ai.ani_max - ai.ani_resv, 0) + (availrmem - swapfs_minfree));
-	/* swap_free  = pagesize * (ai.ani_free + (availrmem - swapfs_minfree)); */
+        swap_alloc = pagesize * ( ai.ani_max - ai.ani_free );
+        swap_resv  = pagesize * ( ai.ani_resv - swap_alloc );
+        swap_avail = pagesize * ( ai.ani_max - ai.ani_resv );
 
-	swap_submit (swap_alloc, swap_avail, -1LL, swap_resv - swap_alloc);
+	swap_submit (swap_alloc, swap_avail, -1LL, swap_resv);
 /* #endif defined(KERNEL_SOLARIS) */
 
 #elif defined(HAVE_LIBSTATGRAB)


More information about the collectd mailing list