diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2000-05-21 06:20:35 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2000-05-21 06:20:35 +0000 |
commit | 2c5d16713862968233858a2430deb67fd485078a (patch) | |
tree | fb12e6c8544f51e3a8837813c0bccc4443f755c1 | |
parent | 4b2b6ee2f0eed08a6e9117d343360e778734f26e (diff) | |
download | lcd4linux-2c5d16713862968233858a2430deb67fd485078a.tar.gz |
[lcd4linux @ 2000-05-21 06:20:35 by reinelt]
added ppp throughput
token is '%t[iomt]' at the moment, but this will change in the near future
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@57 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r-- | README.Drivers | 11 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 28 | ||||
-rw-r--r-- | parser.c | 19 | ||||
-rw-r--r-- | parser.h | 12 | ||||
-rw-r--r-- | processor.c | 55 | ||||
-rw-r--r-- | system.c | 50 | ||||
-rw-r--r-- | system.h | 8 |
7 files changed, 148 insertions, 35 deletions
diff --git a/README.Drivers b/README.Drivers index c8163a5..1e8ce49 100644 --- a/README.Drivers +++ b/README.Drivers @@ -1,5 +1,5 @@ # -# $Id: README.Drivers,v 1.2 2000/03/26 18:46:28 reinelt Exp $ +# $Id: README.Drivers,v 1.3 2000/05/21 06:20:35 reinelt Exp $ # How to write new display drivers for lcd4linux @@ -23,7 +23,14 @@ this guidelines: * create a LCD table at the bottom of your driver, and fill it with the appropriate values. Take care that you specify the correct bar capabilities - of your display or driver! + of your display or driver: + + BAR_L: horizontal bars headed left + BAR_R: horizontal bars headed right + BAR_H2: driver supports horizontal dual-bars + BAR_U: vertical bars bottom-up + BAR_D: vertical bars top-down + BAR_V2: driver supports vertical dual-bars * edit display.c and create a reference to your LCD table: diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 79f1d76..87400b6 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -1,7 +1,7 @@ -#Display LCD2041 -#Port /dev/ttyS2 -#Speed 19200 -#Contrast 160 +Display LCD2041 +Port /dev/ttyS2 +Speed 19200 +Contrast 160 #Display HD44780 #Port 0x378 @@ -12,14 +12,14 @@ #Port /dev/ttyS2 #Type 20x4 -Display PalmPilot -Port /dev/ttyS2 -Speed 4800 -size 20x4 -font 6x8 -pixel 1+0 -gap 0x0 -border 2 +#Display PalmPilot +#Port /dev/ttyS2 +#Speed 4800 +#size 20x4 +#font 6x8 +#pixel 1+0 +#gap 0x0 +#border 2 #Display PPM #size 20x4 @@ -49,9 +49,11 @@ border 2 Row1 "Load %l1%L$r10cs+cb" Row2 "Disk %dm $R10dr+dw" Row3 "Net %nm $R10nr+nw" -Row4 "ISDN %im $r10ii+io" +#Row4 "ISDN %im $r10ii+io" Row5 "Temp %s2°$r10s1+s2" +Row4 "DSL %tm $r10ti+to" + #Row1 "$u3l1$u3cb$u3cs $u3mu$u3ma$u3ms $u3dr$u3dw $u3nr$u3nw $u3ii$u3io" #Row2 " " #Row3 " " @@ -1,4 +1,4 @@ -/* $Id: parser.c,v 1.5 2000/03/24 11:36:56 reinelt Exp $ +/* $Id: parser.c,v 1.6 2000/05/21 06:20:35 reinelt Exp $ * * row definition parser * @@ -20,6 +20,11 @@ * * * $Log: parser.c,v $ + * Revision 1.6 2000/05/21 06:20:35 reinelt + * + * added ppp throughput + * token is '%t[iomt]' at the moment, but this will change in the near future + * * Revision 1.5 2000/03/24 11:36:56 reinelt * * new syntax for raster configuration @@ -101,14 +106,18 @@ static SYMTAB Symtab[] = {{ "%", T_PERCENT, C_GENERIC, 0 }, { "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 }, + { "nr", T_ETH_RX, C_ETH, 1 }, + { "nw", T_ETH_TX, C_ETH, 1 }, + { "nt", T_ETH_TOTAL, C_ETH, 1 }, + { "nm", T_ETH_MAX, C_ETH, 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 }, + { "ti", T_PPP_RX, C_PPP, 1 }, + { "to", T_PPP_TX, C_PPP, 1 }, + { "tt", T_PPP_TOTAL, C_PPP, 1 }, + { "tm", T_PPP_MAX, C_PPP, 1 }, { "s1", T_SENSOR_1, C_SENSOR, 1 }, { "s2", T_SENSOR_2, C_SENSOR, 1 }, { "s3", T_SENSOR_3, C_SENSOR, 1 }, @@ -1,4 +1,4 @@ -/* $Id: parser.h,v 1.4 2000/03/19 08:41:28 reinelt Exp $ +/* $Id: parser.h,v 1.5 2000/05/21 06:20:35 reinelt Exp $ * * row definition parser * @@ -20,6 +20,11 @@ * * * $Log: parser.h,v $ + * Revision 1.5 2000/05/21 06:20:35 reinelt + * + * added ppp throughput + * token is '%t[iomt]' at the moment, but this will change in the near future + * * Revision 1.4 2000/03/19 08:41:28 reinelt * * documentation available! README, README.MatrixOrbital, README.Drivers @@ -54,14 +59,15 @@ typedef enum { T_LOAD_1, T_LOAD_2, T_LOAD_3, T_OVERLOAD, T_CPU_USER, T_CPU_NICE, T_CPU_SYSTEM, T_CPU_BUSY, T_CPU_IDLE, T_DISK_READ, T_DISK_WRITE, T_DISK_TOTAL, T_DISK_MAX, - T_NET_RX, T_NET_TX, T_NET_TOTAL, T_NET_MAX, + T_ETH_RX, T_ETH_TX, T_ETH_TOTAL, T_ETH_MAX, + T_PPP_RX, T_PPP_TX, T_PPP_TOTAL, T_PPP_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 } TOKEN; typedef enum { - C_GENERIC, C_MEM, C_LOAD, C_CPU, C_DISK, C_NET, C_ISDN, C_SENSOR + C_GENERIC, C_MEM, C_LOAD, C_CPU, C_DISK, C_ETH, C_PPP, C_ISDN, C_SENSOR } CLASS; char *parse (char *string, int supported_bars, int usage[]); diff --git a/processor.c b/processor.c index 6a4b715..f77aa3d 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.5 2000/04/15 11:56:35 reinelt Exp $ +/* $Id: processor.c,v 1.6 2000/05/21 06:20:35 reinelt Exp $ * * main data processing * @@ -20,6 +20,11 @@ * * * $Log: processor.c,v $ + * Revision 1.6 2000/05/21 06:20:35 reinelt + * + * added ppp throughput + * token is '%t[iomt]' at the moment, but this will change in the near future + * * Revision 1.5 2000/04/15 11:56:35 reinelt * * more debug messages @@ -84,6 +89,7 @@ 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 { int rx, tx, total, max, peak; } ppp; struct { double val, min, max; } sensor[SENSORS]; @@ -133,13 +139,13 @@ static double query (int token) case T_DISK_MAX: return disk.max; - case T_NET_RX: + case T_ETH_RX: return net.rx; - case T_NET_TX: + case T_ETH_TX: return net.tx; - case T_NET_TOTAL: + case T_ETH_TOTAL: return net.total; - case T_NET_MAX: + case T_ETH_MAX: return net.max; case T_ISDN_IN: @@ -151,6 +157,15 @@ static double query (int token) case T_ISDN_MAX: return isdn.max; + case T_PPP_RX: + return ppp.rx; + case T_PPP_TX: + return ppp.tx; + case T_PPP_TOTAL: + return ppp.total; + case T_PPP_MAX: + return ppp.max; + case T_SENSOR_1: case T_SENSOR_2: case T_SENSOR_3: @@ -193,11 +208,11 @@ static double query_bar (int token) case T_DISK_TOTAL: return value/disk.peak/2.0; - case T_NET_RX: - case T_NET_TX: - case T_NET_MAX: + case T_ETH_RX: + case T_ETH_TX: + case T_ETH_MAX: return value/net.peak; - case T_NET_TOTAL: + case T_ETH_TOTAL: return value/net.peak/2.0; case T_ISDN_IN: @@ -207,6 +222,13 @@ static double query_bar (int token) case T_ISDN_TOTAL: return value/isdn.peak/2.0; + case T_PPP_RX: + case T_PPP_TX: + case T_PPP_MAX: + return value/ppp.peak; + case T_PPP_TOTAL: + return value/ppp.peak/2.0; + case T_SENSOR_1: case T_SENSOR_2: case T_SENSOR_3: @@ -294,6 +316,12 @@ static void print_token (int token, char **p) else *p+=sprintf (*p, "----"); break; + case T_PPP_RX: + case T_PPP_TX: + case T_PPP_MAX: + case T_PPP_TOTAL: + *p+=sprintf (*p, "%5.0f", query(token)); + break; default: *p+=sprintf (*p, "%4.0f", query(token)); } @@ -324,7 +352,7 @@ static void collect_data (void) if (disk.max>disk.peak) disk.peak=disk.max; } - if (token_usage[C_NET]) { + if (token_usage[C_ETH]) { Net (&net.rx, &net.tx); net.total=net.rx+net.tx; net.max=net.rx>net.tx?net.rx:net.tx; @@ -338,6 +366,13 @@ static void collect_data (void) if (isdn.max>isdn.peak) isdn.peak=isdn.max; } + if (token_usage[C_PPP]) { + PPP (0, &ppp.rx, &ppp.tx); + ppp.total=ppp.rx+ppp.tx; + ppp.max=ppp.rx>ppp.tx?ppp.rx:ppp.tx; + if (ppp.max>ppp.peak) ppp.peak=ppp.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); @@ -1,4 +1,4 @@ -/* $Id: system.c,v 1.11 2000/04/15 11:56:35 reinelt Exp $ +/* $Id: system.c,v 1.12 2000/05/21 06:20:35 reinelt Exp $ * * system status retreivement * @@ -20,6 +20,11 @@ * * * $Log: system.c,v $ + * Revision 1.12 2000/05/21 06:20:35 reinelt + * + * added ppp throughput + * token is '%t[iomt]' at the moment, but this will change in the near future + * * Revision 1.11 2000/04/15 11:56:35 reinelt * * more debug messages @@ -110,6 +115,10 @@ * sets number of packets received and transmitted * returns 0 if ok, -1 on error * + * int PPP (int unit, int *rx, int *tx); + * sets number of packets received and transmitted + * returns 0 if ok, -1 on error + * * int Sensor (int index, double *val, double *min, double *max) * sets the current value of the index'th sensor and * the minimum and maximum values from the config file @@ -129,6 +138,9 @@ #include <sys/types.h> #include <sys/utsname.h> #include <sys/param.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <net/if_ppp.h> #include "debug.h" #include "cfg.h" @@ -548,6 +560,42 @@ int Net (int *rx, int *tx) return 0; } +int PPP (int unit, int *rx, int *tx) +{ + static int fd=-2; + struct ifpppstatsreq req; + char buffer[16]; + + *rx=0; + *tx=0; + + if (fd==-1) return -1; + + if (fd==-2) { + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd==-1) { + perror ("socket() failed"); + return -1; + } + debug ("socket()=%d\n", fd); + } + + memset (&req, 0, sizeof (req)); + req.stats_ptr = (caddr_t) &req.stats; + snprintf (req.ifr__name, sizeof(req.ifr__name), "ppp%d", unit); + + if (ioctl(fd, SIOCGPPPSTATS, &req) < 0) + return 0; + + snprintf (buffer, sizeof(buffer), "ppp%d_rx", unit); + *rx=smooth(buffer, 500, req.stats.p.ppp_ibytes); + + snprintf (buffer, sizeof(buffer), "ppp%d_tx", unit); + *tx=smooth(buffer, 500, req.stats.p.ppp_obytes); + + return 0; +} + int Sensor (int index, double *val, double *min, double *max) { char buffer[32]; @@ -1,4 +1,4 @@ -/* $Id: system.h,v 1.6 2000/04/13 06:09:52 reinelt Exp $ +/* $Id: system.h,v 1.7 2000/05/21 06:20:35 reinelt Exp $ * * system status retreivement * @@ -20,6 +20,11 @@ * * * $Log: system.h,v $ + * Revision 1.7 2000/05/21 06:20:35 reinelt + * + * added ppp throughput + * token is '%t[iomt]' at the moment, but this will change in the near future + * * Revision 1.6 2000/04/13 06:09:52 reinelt * * added BogoMips() to system.c (not used by now, maybe sometimes we can @@ -61,6 +66,7 @@ int Load (double *load1, double *load2, double *load3); int Busy (double *user, double *nice, double *system, double *idle); int Disk (int *r, int *w); int Net (int *rx, int *tx); +int PPP (int unit, int *rx, int *tx); int Sensor (int index, double *val, double *min, double *max); #endif |