aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2000-03-18 10:31:06 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2000-03-18 10:31:06 +0000
commit74dc0b10c7ab905c8fb7b4098774155a9b2828fd (patch)
tree49cf4c04d1582ed6feb10836d54dbcbfb032d32e
parent0ec6be5c5334768655395a3f6a3c6ed38c380e8d (diff)
downloadlcd4linux-74dc0b10c7ab905c8fb7b4098774155a9b2828fd.tar.gz
[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 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@13 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rwxr-xr-xconfigure68
-rw-r--r--configure.in5
-rw-r--r--lcd4linux.c99
-rw-r--r--lcd4linux.conf.sample21
-rw-r--r--parser.c121
-rw-r--r--parser.h17
6 files changed, 211 insertions, 120 deletions
diff --git a/configure b/configure
index 9c0547a..89cc8de 100755
--- a/configure
+++ b/configure
@@ -691,7 +691,7 @@ fi
PACKAGE=lcd4linux
-VERSION=0.91
+VERSION=0.92
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
@@ -997,9 +997,9 @@ else
fi
-echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
-echo "configure:1002: checking for main in -lm" >&5
-ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for log in -lm""... $ac_c" 1>&6
+echo "configure:1002: checking for log in -lm" >&5
+ac_lib_var=`echo m'_'log | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1008,12 +1008,16 @@ LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1010 "configure"
#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char log();
int main() {
-main()
+log()
; return 0; }
EOF
-if { (eval echo configure:1017: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1021: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1042,7 +1046,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1046: checking how to run the C preprocessor" >&5
+echo "configure:1050: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1057,13 +1061,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1061 "configure"
+#line 1065 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1067: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1071: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1074,13 +1078,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1078 "configure"
+#line 1082 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1084: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1088: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1091,13 +1095,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1095 "configure"
+#line 1099 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1101: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1105: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1122,12 +1126,12 @@ fi
echo "$ac_t""$CPP" 1>&6
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1126: checking for ANSI C header files" >&5
+echo "configure:1130: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1131 "configure"
+#line 1135 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1135,7 +1139,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1139: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1143: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1152,7 +1156,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1156 "configure"
+#line 1160 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1170,7 +1174,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1174 "configure"
+#line 1178 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1191,7 +1195,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1195 "configure"
+#line 1199 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1202,7 +1206,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1229,17 +1233,17 @@ for ac_hdr in fcntl.h sys/ioctl.h sys/time.h unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1233: checking for $ac_hdr" >&5
+echo "configure:1237: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1238 "configure"
+#line 1242 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1243: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1247: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1267,12 +1271,12 @@ done
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1271: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1275: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1276 "configure"
+#line 1280 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -1281,7 +1285,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:1285: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1289: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -1304,13 +1308,13 @@ fi
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:1308: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:1312: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
-#line 1314 "configure"
+#line 1318 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -1328,7 +1332,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 1332 "configure"
+#line 1336 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -1352,12 +1356,12 @@ fi
for ac_func in gettimeofday strdup strerror strstr strtol uname
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1356: checking for $ac_func" >&5
+echo "configure:1360: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1361 "configure"
+#line 1365 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1380,7 +1384,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
diff --git a/configure.in b/configure.in
index bac7539..b195cb6 100644
--- a/configure.in
+++ b/configure.in
@@ -1,13 +1,12 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(lcd4linux.c)
-AM_INIT_AUTOMAKE(lcd4linux, 0.91)
+AM_INIT_AUTOMAKE(lcd4linux, 0.92)
dnl Checks for programs.
AC_PROG_CC
dnl Checks for libraries.
-dnl Replace `main' with a function in -lm:
-AC_CHECK_LIB(m, main)
+AC_CHECK_LIB(m, log)
dnl Checks for header files.
AC_HEADER_STDC
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<SENSORS; i++) {
+ if (token_usage[T_SENSOR_1+i-1]) {
+ Sensor (i, &sensor[i].val, &sensor[i].min, &sensor[i].max);
+ }
+ }
}
static double query (int token)
@@ -171,12 +202,14 @@ static double query (int token)
case T_SENSOR_7:
case T_SENSOR_8:
case T_SENSOR_9:
+ return sensor[token-T_SENSOR_1+1].val;
}
return 0.0;
}
static double query_bar (int token)
{
+ int i;
double value=query(token);
switch (token) {
@@ -216,6 +249,17 @@ static double query_bar (int token)
case T_ISDN_TOTAL:
return value/isdn.peak/2.0;
+ case T_SENSOR_1:
+ case T_SENSOR_2:
+ case T_SENSOR_3:
+ case T_SENSOR_4:
+ case T_SENSOR_5:
+ case T_SENSOR_6:
+ case T_SENSOR_7:
+ case T_SENSOR_8:
+ case T_SENSOR_9:
+ i=token-T_SENSOR_1+1;
+ return (value-sensor[i].min)/(sensor[i].max-sensor[i].min);
}
return value;
}
@@ -258,6 +302,15 @@ void print_token (int token, char **p)
case T_LOAD_1:
case T_LOAD_2:
case T_LOAD_3:
+ case T_SENSOR_1:
+ case T_SENSOR_2:
+ case T_SENSOR_3:
+ case T_SENSOR_4:
+ case T_SENSOR_5:
+ case T_SENSOR_6:
+ case T_SENSOR_7:
+ case T_SENSOR_8:
+ case T_SENSOR_9:
val=query(token);
if (val<10.0) {
*p+=sprintf (*p, "%4.2f", val);
@@ -342,8 +395,8 @@ void main (int argc, char *argv[])
cfg=argv[1];
}
- cfg_set ("row1", "*** %o %r ***");
- cfg_set ("row2", "%p CPU %m MB RAM");
+ cfg_set ("row1", "*** %o %v ***");
+ cfg_set ("row2", "%p CPU %r MB RAM");
cfg_set ("row3", "Busy %cu%% $r10cu");
cfg_set ("row4", "Load %l1%L$r10l1");
@@ -376,9 +429,9 @@ void main (int argc, char *argv[])
for (i=1; i<=rows; i++) {
char buffer[8];
snprintf (buffer, sizeof(buffer), "row%d", i);
- row[i]=strdup(parse(cfg_get(buffer), supported_bars));
+ row[i]=strdup(parse(cfg_get(buffer), supported_bars, token_usage));
}
-
+
lcd_clear();
lcd_put (1, 1, "** LCD4Linux V" VERSION " **");
lcd_put (2, 1, " (c) 2000 M.Reinelt");
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index 69e6a53..efcbe78 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -8,10 +8,15 @@ Contrast 160
#Row3 "Busy %cu%% $r10cs+cb"
#Row4 "Load %l1%L$r10l1"
+#Row1 "Load %l1%L$r10cs+cb"
+#Row2 "Disk %dm $R10dr+dw"
+#Row3 "Net %nm $R10nr+nw"
+#Row4 "ISDN %im $r10ii+io"
+
Row1 "Load %l1%L$r10cs+cb"
-Row2 "Disk %dm $R10dr+dw"
-Row3 "Net %nm $R10nr+nw"
-Row4 "ISDN %im $r10ii+io"
+Row2 "Temp %s2\337$r10s1+s2"
+Row3 "Disk %dm $R10dr+dw"
+Row4 "Net %nm $R10nr+nw"
#Row1 "$u3l1$u3cb$u3cs $u3mu$u3ma$u3ms $u3dr$u3dw $u3nr$u3nw $u3ii$u3io"
#Row2 " "
@@ -23,8 +28,16 @@ Tack 400
Tau 500
Overload 2.0
-Sensor1 /proc/sys/dev/sensors/w83781d-isa-0290/temp2
+Sensor1 /proc/sys/dev/sensors/w83781d-isa-0290/temp1
Sensor1_min 30
Sensor1_max 50
+Sensor2 /proc/sys/dev/sensors/w83781d-isa-0290/temp2
+Sensor2_min 30
+Sensor2_max 50
+
+Sensor3 /proc/sys/dev/sensors/w83781d-isa-0290/temp3
+Sensor3_min 30
+Sensor3_max 50
+
Fifo /var/run/lcd4linux
diff --git a/parser.c b/parser.c
index 1a287e2..2c7ac66 100644
--- a/parser.c
+++ b/parser.c
@@ -1,4 +1,4 @@
-/* $Id: parser.c,v 1.2 2000/03/17 09:21:42 reinelt Exp $
+/* $Id: parser.c,v 1.3 2000/03/18 10:31:06 reinelt Exp $
*
* row definition parser
*
@@ -20,6 +20,13 @@
*
*
* $Log: parser.c,v $
+ * Revision 1.3 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.2 2000/03/17 09:21:42 reinelt
*
* various memory statistics added
@@ -35,9 +42,11 @@
/*
* exported functions:
*
- * char *parse (char *string, int supported_bars)
+ * char *parse (char *string, int supported_bars, int usage[])
* converts a row definition from the config file
* into the internal form using tokens
+ * sets the array usage[token] to usage count
+ *
*/
#include <stdlib.h>
@@ -51,54 +60,54 @@
typedef struct {
char *symbol;
TOKEN token;
+ CLASS class;
int bar;
} SYMTAB;
-static SYMTAB Symtab[] = {{ "%", T_PERCENT, 0 },
- { "$", T_DOLLAR, 0 },
- { "o", T_OS, 0 },
- { "v", T_RELEASE, 0 },
- { "p", T_CPU, 0 },
- { "r", T_RAM, 0 },
- { "mt", T_MEM_TOTAL, 1 },
- { "mu", T_MEM_USED, 1 },
- { "mf", T_MEM_FREE, 1 },
- { "ms", T_MEM_SHARED, 1 },
- { "mb", T_MEM_BUFFER, 1 },
- { "mc", T_MEM_CACHE, 1 },
- { "ma", T_MEM_APP, 1 },
- { "l1", T_LOAD_1, 1 },
- { "l2", T_LOAD_2, 1 },
- { "l3", T_LOAD_3, 1 },
- { "L", T_OVERLOAD, 0 },
- { "cu", T_CPU_USER, 1 },
- { "cn", T_CPU_NICE, 1 },
- { "cs", T_CPU_SYSTEM, 1 },
- { "cb", T_CPU_BUSY, 1 },
- { "ci", T_CPU_IDLE, 1 },
- { "dr", T_DISK_READ, 1 },
- { "dw", T_DISK_WRITE, 1 },
- { "dt", T_DISK_TOTAL, 1 },
- { "dm", T_DISK_MAX, 1 },
- { "nr", T_NET_RX, 1 },
- { "nw", T_NET_TX, 1 },
- { "nt", T_NET_TOTAL, 1 },
- { "nm", T_NET_MAX, 1 },
- { "ii", T_ISDN_IN, 1 },
- { "io", T_ISDN_OUT, 1 },
- { "it", T_ISDN_TOTAL, 1 },
- { "im", T_ISDN_MAX, 1 },
- { "s1", T_SENSOR_1, 1 },
- { "s1", T_SENSOR_2, 1 },
- { "s2", T_SENSOR_3, 1 },
- { "s3", T_SENSOR_4, 1 },
- { "s4", T_SENSOR_5, 1 },
- { "s5", T_SENSOR_6, 1 },
- { "s6", T_SENSOR_7, 1 },
- { "s7", T_SENSOR_8, 1 },
- { "s8", T_SENSOR_9, 1 },
- { "", -1 }};
-
+static SYMTAB Symtab[] = {{ "%", T_PERCENT, C_GENERIC, 0 },
+ { "$", T_DOLLAR, C_GENERIC, 0 },
+ { "o", T_OS, C_GENERIC, 0 },
+ { "v", T_RELEASE, C_GENERIC, 0 },
+ { "p", T_CPU, C_GENERIC, 0 },
+ { "r", T_RAM, C_GENERIC, 0 },
+ { "mt", T_MEM_TOTAL, C_MEM, 1 },
+ { "mu", T_MEM_USED, C_MEM, 1 },
+ { "mf", T_MEM_FREE, C_MEM, 1 },
+ { "ms", T_MEM_SHARED, C_MEM, 1 },
+ { "mb", T_MEM_BUFFER, C_MEM, 1 },
+ { "mc", T_MEM_CACHE, C_MEM, 1 },
+ { "ma", T_MEM_APP, C_MEM, 1 },
+ { "l1", T_LOAD_1, C_LOAD, 1 },
+ { "l2", T_LOAD_2, C_LOAD, 1 },
+ { "l3", T_LOAD_3, C_LOAD, 1 },
+ { "L", T_OVERLOAD, C_LOAD, 0 },
+ { "cu", T_CPU_USER, C_CPU, 1 },
+ { "cn", T_CPU_NICE, C_CPU, 1 },
+ { "cs", T_CPU_SYSTEM, C_CPU, 1 },
+ { "cb", T_CPU_BUSY, C_CPU, 1 },
+ { "ci", T_CPU_IDLE, C_CPU, 1 },
+ { "dr", T_DISK_READ, C_DISK, 1 },
+ { "dw", T_DISK_WRITE, C_DISK, 1 },
+ { "dt", T_DISK_TOTAL, C_DISK, 1 },
+ { "dm", T_DISK_MAX, C_DISK, 1 },
+ { "nr", T_NET_RX, C_NET, 1 },
+ { "nw", T_NET_TX, C_NET, 1 },
+ { "nt", T_NET_TOTAL, C_NET, 1 },
+ { "nm", T_NET_MAX, C_NET, 1 },
+ { "ii", T_ISDN_IN, C_ISDN, 1 },
+ { "io", T_ISDN_OUT, C_ISDN, 1 },
+ { "it", T_ISDN_TOTAL, C_ISDN, 1 },
+ { "im", T_ISDN_MAX, C_ISDN, 1 },
+ { "s1", T_SENSOR_1, C_SENSOR, 1 },
+ { "s2", T_SENSOR_2, C_SENSOR, 1 },
+ { "s3", T_SENSOR_3, C_SENSOR, 1 },
+ { "s4", T_SENSOR_4, C_SENSOR, 1 },
+ { "s5", T_SENSOR_5, C_SENSOR, 1 },
+ { "s6", T_SENSOR_6, C_SENSOR, 1 },
+ { "s7", T_SENSOR_7, C_SENSOR, 1 },
+ { "s8", T_SENSOR_8, C_SENSOR, 1 },
+ { "s9", T_SENSOR_9, C_SENSOR, 1 },
+ { "", -1, 0 }};
static int bar_type (char tag)
{
@@ -116,7 +125,7 @@ static int bar_type (char tag)
}
}
-static TOKEN get_token (char *s, char **p, int bar)
+static TOKEN get_token (char *s, char **p, int bar, int usage[])
{
int i;
for (i=0; Symtab[i].token!=-1; i++) {
@@ -124,24 +133,27 @@ static TOKEN get_token (char *s, char **p, int bar)
if (bar && !Symtab[i].bar) continue;
if (strncmp(Symtab[i].symbol, s, l)==0) {
*p=s+l;
+ usage[Symtab[i].token]++;
+ usage[Symtab[i].class]++;
return Symtab[i].token;
}
}
return -1;
}
-char *parse (char *string, int supported_bars)
+char *parse (char *string, int supported_bars, int usage[])
{
static char buffer[256];
char *s=string;
char *p=buffer;
- int token, token2, type, len;
+ TOKEN token, token2;
+ int type, len;
do {
switch (*s) {
case '%':
- if ((token=get_token (++s, &s, 0))==-1) {
+ if ((token=get_token (++s, &s, 0, usage))==-1) {
fprintf (stderr, "WARNING: unknown token <%%%c> in <%s>\n", *s, string);
} else {
*p++='%';
@@ -165,7 +177,7 @@ char *parse (char *string, int supported_bars)
fprintf (stderr, "WARNING: invalid bar length in <%s>\n", string);
break;
}
- if ((token=get_token (s, &s, 0))==-1) {
+ if ((token=get_token (s, &s, 0, usage))==-1) {
fprintf (stderr, "WARNING: unknown token <$%c> in <%s>\n", *s, string);
break;
}
@@ -179,7 +191,7 @@ char *parse (char *string, int supported_bars)
fprintf (stderr, "WARNING: driver does not support double bars\n");
break;
}
- if ((token2=get_token (s+1, &s, 0))==-1) {
+ if ((token2=get_token (s+1, &s, 0, usage))==-1) {
fprintf (stderr, "WARNING: unknown token <$%c> in <%s>\n", *s, string);
break;
}
@@ -202,7 +214,7 @@ char *parse (char *string, int supported_bars)
fprintf (stderr, "WARNING: illegal '\\' in <%s>\n", string);
} else {
*p++=c;
- s+=n-1;
+ s+=n+1;
}
}
break;
@@ -216,4 +228,3 @@ char *parse (char *string, int supported_bars)
*p='\0';
return buffer;
}
-
diff --git a/parser.h b/parser.h
index fbef9f9..8f42218 100644
--- a/parser.h
+++ b/parser.h
@@ -1,4 +1,4 @@
-/* $Id: parser.h,v 1.2 2000/03/17 09:21:42 reinelt Exp $
+/* $Id: parser.h,v 1.3 2000/03/18 10:31:06 reinelt Exp $
*
* row definition parser
*
@@ -20,6 +20,13 @@
*
*
* $Log: parser.h,v $
+ * Revision 1.3 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.2 2000/03/17 09:21:42 reinelt
*
* various memory statistics added
@@ -45,9 +52,13 @@ typedef enum {
T_NET_RX, T_NET_TX, T_NET_TOTAL, T_NET_MAX,
T_ISDN_IN, T_ISDN_OUT, T_ISDN_TOTAL, T_ISDN_MAX,
T_SENSOR_1, T_SENSOR_2, T_SENSOR_3, T_SENSOR_4, T_SENSOR_5,
- T_SENSOR_6, T_SENSOR_7, T_SENSOR_8, T_SENSOR_9,
+ T_SENSOR_6, T_SENSOR_7, T_SENSOR_8, T_SENSOR_9
} TOKEN;
-char *parse (char *string, int supported_bars);
+typedef enum {
+ C_GENERIC, C_MEM, C_LOAD, C_CPU, C_DISK, C_NET, C_ISDN, C_SENSOR
+} CLASS;
+
+char *parse (char *string, int supported_bars, int usage[]);
#endif