From 53d8bad0f484fbb481337e612fa06b2b75e2609e Mon Sep 17 00:00:00 2001 From: "B. Kelly (wbk)" Date: Sun, 1 Apr 2012 23:25:30 -0500 Subject: [PATCH] wmmon: Add -b flag, etc 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 @@ -79,6 +79,12 @@ each set to a different mode. 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, 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"); }