-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Carlos,

    Here is another patch for wmmon. This implements the -b flag from
the Gentoo patchkit, which optionally includes kernel buffers and cache
in total memory usage calculation. Only the memory aka "SysInfo"
monitor is impacted. Default behaviour is unchanged. I've updated the
man page as well.

Thanks!
- -wbk

- -- 

[email protected]                                 http://devio.us/~coydog

Public key:                     http://devio.us/~coydog/public_keys.txt
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAEBAgAGBQJPeS1kAAoJEPAprai3G3cMDOIP/0B8675bNU4d5fG4QOKvNK7q
OgKk82MunNhmdBHRdHgAnohfqKCNsAUWpYY+IE12l33fvv/OiLe0GoaYk+mscv5r
xWY5MqgwY/GOEBUf3dp87BNm2O8lhsiZFSyDhLeR78iPYyixBaxz4rRf89oPk708
z+fWMSxGkRwbdsMlPeElfx+faSLjIdgSraxC1IlIvA/ky/ye1BGbwyHspf1H29FX
xIU9aQBmbTn4Svv3h5J+AoaIYXssP56BJLNVfxgR/bwzJBSvoShXQ7PVxLr+qmyP
Y87PJiaxmYbZk72uzZDWko+5j1AB7Y9Yu7Srseoi2gpMJJ6cDvFUk9LRHxXUGsJj
T9WoO3abDCV9MCxImMbMDoKdQPg7RlU8/XqrvjgCMN1d9r/g2CblWzwLcr2zmE07
cypnLL+OggI76/6RbUHnxaep/DaYmePD1wEV6CMW6M/bNinvJqdrKpBcjGXudPaZ
X8utDO64ckLyzvLWzx3CF1jrTiFALmgoo2irHVli7GfF1IIkcSVwRWagqNCPRqG2
7LDuOZAWIrwFsiUIj0YeeIQQEHp5Imk2XJDe9KfXmjsaohD+/cpzBUrC6KQGVBLw
rs34NjbCZhY1XOiV4YO+ArhIDVtquC7orGUimDSaxFKmnX7eRIaasqPyoQ9Dskkz
EzeQCh01hXH7GMQYsK78
=C0Ap
-----END PGP SIGNATURE-----
From 0f525f79c0c90b1ee1c7db249ddced0fdacf2c51 Mon Sep 17 00:00:00 2001
From: B. Kelly (wbk) <[email protected]>
Date: Sun, 1 Apr 2012 23:25:30 -0500
Subject: [PATCH] wmmon.c
   Added -b flag to include buffers and cache in total memory usage.
   Added global show_buffers, -b parsing code, associated logic in
   update_stat_mem(), and usage information.

wmmon.1
  Added -b documentation.
---
 wmmon/wmmon/wmmon.1 |    6 ++++++
 wmmon/wmmon/wmmon.c |   13 +++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/wmmon/wmmon/wmmon.1 b/wmmon/wmmon/wmmon.1
index 39a5e04..dfae000 100644
--- a/wmmon/wmmon/wmmon.1
+++ b/wmmon/wmmon/wmmon.1
@@ -80,6 +80,12 @@ Start in disk I/O mode, which displays instantaneous disk usage and
 average disk load.
 
 .TP
+.BR \-b
+Include buffers and cache in memory usage calculations. The trend in
+recent years has been to not include this in memory load monitors, but it
+can be useful information.
+
+.TP
 .BR \-s
 Start in system information mode, which displays memory usage, swap usage,
 and uptime.
diff --git a/wmmon/wmmon/wmmon.c b/wmmon/wmmon/wmmon.c
index 254437e..77d1ac0 100644
--- a/wmmon/wmmon/wmmon.c
+++ b/wmmon/wmmon/wmmon.c
@@ -137,6 +137,8 @@
 int	stat_current = 0; /* now global */
 int	mode_cycling = 1; /* Allow mode-cycling */
 int	cpu_avg_max  = 0; /* CPU stress meter with average and max for SMP */
+int show_buffers = 0; /* wbk adding per Gentoo -b enhancement. */
+
 FILE	*fp_meminfo;
 FILE	*fp_stat;
 FILE	*fp_loadavg;
@@ -183,6 +185,9 @@ int main(int argc, char *argv[]) {
 			case 'i' :
 				stat_current = 1;
 				break;
+			case 'b' :
+				show_buffers = 1;
+				break;
 			case 's' :
 				stat_current = 2;
 				break;
@@ -457,7 +462,7 @@ void wmmon_routine(int argc, char **argv) {
 			j = j * 0.32;
 			if (j > 32) j = 32;
 			copyXPMArea(32, 64, j, 12, 28+64, 4);
-			/*---------------------           ------------------*/
+			/*--------------------- swap?     ------------------*/
 			j = stat_device[3].rt_idle;
 			if (j != 0) {
 				j = (stat_device[3].rt_stat * 100) / j;
@@ -724,7 +729,10 @@ void update_stat_mem(stat_dev *st, stat_dev *st2) {
 	 * calculate it from MemTotal - MemFree
 	 */
 	st->rt_stat = st->rt_idle - free;
-	st->rt_stat -= buffers+cached;
+
+	/* wbk -b flag (from Gentoo patchkit) */
+	if (!show_buffers)
+		st->rt_stat -= buffers+cached;
 	/* As with the amount of memory used, it's not recorded any more, so
 	 * we have to calculate it ourselves.
 	 */
@@ -1059,6 +1067,7 @@ void usage(char *name) {
 	printf("                       default if there is more than %d processors\n", MAX_CPU);
 	printf("  -i                   start in Disk I/O mode\n");
 	printf("  -s                   start in System Info mode\n");
+	printf("  -b                   include buffers and cache in memory usage\n");
 	printf("  -h                   display this help and exit\n");
 	printf("  -v                   output version information and exit\n");
 }
-- 
1.7.3.4

Reply via email to