From c716d0fbdfbe92583592a46c99e5f8d87d34bb68 Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Sat, 18 Mar 2000 10:31:06 +0000 Subject: [lcd4linux @ 2000-03-18 10:31:06 by reinelt] added sensor handling (for temperature etc.) made data collecting happen only if data is used (reading /proc/meminfo takes a lot of CPU!) released lcd4linux-0.92 --- lcd4linux.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 23 deletions(-) (limited to 'lcd4linux.c') diff --git a/lcd4linux.c b/lcd4linux.c index 9797d9e..f006f97 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -1,4 +1,4 @@ -/* $Id: lcd4linux.c,v 1.5 2000/03/18 08:07:04 reinelt Exp $ +/* $Id: lcd4linux.c,v 1.6 2000/03/18 10:31:06 reinelt Exp $ * * LCD4Linux * @@ -20,6 +20,13 @@ * * * $Log: lcd4linux.c,v $ + * Revision 1.6 2000/03/18 10:31:06 reinelt + * + * added sensor handling (for temperature etc.) + * made data collecting happen only if data is used + * (reading /proc/meminfo takes a lot of CPU!) + * released lcd4linux-0.92 + * * Revision 1.5 2000/03/18 08:07:04 reinelt * * vertical bars implemented @@ -60,12 +67,15 @@ double overload; int tick, tack, tau; int rows, cols, xres, yres, supported_bars; +int token_usage[256]={0,}; + struct { int total, used, free, shared, buffer, cache, apps; } ram; struct { double load1, load2, load3, overload; } load; struct { double user, nice, system, idle; } busy; struct { int read, write, total, max, peak; } disk; struct { int rx, tx, total, max, peak; } net; struct { int usage, in, out, total, max, peak; } isdn; +struct { double val, min, max; } sensor[SENSORS]; static void usage(void) { @@ -75,27 +85,48 @@ static void usage(void) static void collect_data (void) { - Ram (&ram.total, &ram.free, &ram.shared, &ram.buffer, &ram.cache); - ram.used=ram.total-ram.free; - ram.apps=ram.used-ram.buffer-ram.cache; + int i; - Load (&load.load1, &load.load2, &load.load3); - Busy (&busy.user, &busy.nice, &busy.system, &busy.idle); - - Disk (&disk.read, &disk.write); - disk.total=disk.read+disk.write; - disk.max=disk.read>disk.write?disk.read:disk.write; - if (disk.max>disk.peak) disk.peak=disk.max; + if (token_usage[C_MEM]) { + Ram (&ram.total, &ram.free, &ram.shared, &ram.buffer, &ram.cache); + ram.used=ram.total-ram.free; + ram.apps=ram.used-ram.buffer-ram.cache; + } + + if (token_usage[C_LOAD]) { + Load (&load.load1, &load.load2, &load.load3); + } + + if (token_usage[C_CPU]) { + Busy (&busy.user, &busy.nice, &busy.system, &busy.idle); + } + + if (token_usage[C_DISK]) { + Disk (&disk.read, &disk.write); + disk.total=disk.read+disk.write; + disk.max=disk.read>disk.write?disk.read:disk.write; + if (disk.max>disk.peak) disk.peak=disk.max; + } + + if (token_usage[C_NET]) { + Net (&net.rx, &net.tx); + net.total=net.rx+net.tx; + net.max=net.rx>net.tx?net.rx:net.tx; + if (net.max>net.peak) net.peak=net.max; + } - Net (&net.rx, &net.tx); - net.total=net.rx+net.tx; - net.max=net.rx>net.tx?net.rx:net.tx; - if (net.max>net.peak) net.peak=net.max; + if (token_usage[C_ISDN]) { + Isdn (&isdn.in, &isdn.out, &isdn.usage); + isdn.total=isdn.in+isdn.out; + isdn.max=isdn.in>isdn.out?isdn.in:isdn.out; + if (isdn.max>isdn.peak) isdn.peak=isdn.max; + } - Isdn (&isdn.in, &isdn.out, &isdn.usage); - isdn.total=isdn.in+isdn.out; - isdn.max=isdn.in>isdn.out?isdn.in:isdn.out; - if (isdn.max>isdn.peak) isdn.peak=isdn.max; + for (i=1; i