diff -ruN wmmon.app.orig/wmmon/Makefile wmmon.app/wmmon/Makefile --- wmmon.app.orig/wmmon/Makefile 1998-05-19 23:13:16.000000000 +0200 +++ wmmon.app/wmmon/Makefile 2004-05-22 04:27:19.000000000 +0200 @@ -5,9 +5,8 @@ ../wmgeneral/misc.o \ ../wmgeneral/list.o - .c.o: - cc -c -O2 -Wall $< -o $*.o + cc -c $(CFLAGS) $(DEFINES) -Wall $< -o $*.o wmmon: $(OBJS) cc -o wmmon $^ $(LIBDIR) $(LIBS) diff -ruN wmmon.app.orig/wmmon/wmmon.c wmmon.app/wmmon/wmmon.c --- wmmon.app.orig/wmmon/wmmon.c 1998-05-19 23:13:16.000000000 +0200 +++ wmmon.app/wmmon/wmmon.c 2004-05-22 04:29:39.000000000 +0200 @@ -187,8 +187,7 @@ void update_stat_cpu(stat_dev *); void update_stat_io(stat_dev *); -void update_stat_mem(stat_dev *st, stat_dev *st2); -void update_stat_swp(stat_dev *); +void update_stat_mem_k26(stat_dev *st, stat_dev *st2); void wmmon_routine(int argc, char **argv) { @@ -297,8 +296,7 @@ update_stat_io(&stat_device[1]); if(stat_current == 2) { - update_stat_mem(&stat_device[2], &stat_device[3]); -// update_stat_swp(&stat_device[3]); + update_stat_mem_k26(&stat_device[2], &stat_device[3]); } if (stat_current < 2) { @@ -497,47 +495,56 @@ st->hisaddcnt += 1; } -void update_stat_mem(stat_dev *st, stat_dev *st2) { +void update_stat_mem_k26(stat_dev *st, stat_dev *st2) { char temp[128]; - unsigned long free, shared, buffers, cached; + unsigned long free, shared, buffers, cached, swap_free; freopen("/proc/meminfo", "r", fp_meminfo); while (fgets(temp, 128, fp_meminfo)) { - if (strstr(temp, "Mem:")) { - sscanf(temp, "Mem: %ld %ld %ld %ld %ld %ld", - &st->rt_idle, &st->rt_stat, - &free, &shared, &buffers, &cached); - st->rt_idle >>= 10; - st->rt_stat -= buffers+cached; - st->rt_stat >>= 10; -// break; + if (strstr(temp, "MemTotal:")) { + sscanf(temp, "MemTotal: %ld", &st->rt_idle); + continue; } - if (strstr(temp, "Swap:")) { - sscanf(temp, "Swap: %ld %ld", &st2->rt_idle, &st2->rt_stat); - st2->rt_idle >>= 10; - st2->rt_stat >>= 10; - break; + if (strstr(temp, "MemFree:")) { + sscanf(temp, "MemFree: %ld", &free); + continue; + } + if (strstr(temp, "Buffers:")) { + sscanf(temp, "Buffers: %ld", &buffers); + continue; + } + if (strstr(temp, "Cached:")) { + sscanf(temp, "Cached: %ld", &cached); + continue; + } + + if (strstr(temp, "SwapTotal:")) { + sscanf(temp, "SwapTotal: %ld", &st2->rt_idle); + continue; + } + if (strstr(temp, "SwapFree:")) { + sscanf(temp, "SwapFree: %ld", &swap_free); + continue; } } -} -void update_stat_swp(stat_dev *st) { + // used = total - free; + st->rt_stat = st->rt_idle - free; + st2->rt_stat = st2->rt_idle - swap_free; - char temp[128]; + // ignore shared + shared = 0; - fseek(fp_meminfo, 0, SEEK_SET); - while (fgets(temp, 128, fp_meminfo)) { - if (strstr(temp, "Swap:")) { - sscanf(temp, "Swap: %ld %ld", &st->rt_idle, &st->rt_stat); - st->rt_idle >>= 10; - st->rt_stat >>= 10; - break; - } - } + st->rt_idle >>= 10; + st->rt_stat -= buffers+cached; + st->rt_stat >>= 10; + st2->rt_idle >>= 10; + st2->rt_stat >>= 10; } + /*******************************************************************************\ |* get_statistics *| \*******************************************************************************/