add iface screen to lcdproc; change option -d back to -f

This commit is contained in:
marschap
2006-04-27 20:17:47 +00:00
parent d4a3e7444d
commit 582d3ed4bb
5 changed files with 45 additions and 10 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ sysconf_DATA = lcdproc.conf
bin_PROGRAMS = lcdproc bin_PROGRAMS = lcdproc
lcdproc_SOURCES = main.c main.h mode.c mode.h batt.c batt.h chrono.c chrono.h cpu.c cpu.h cpu_smp.c cpu_smp.h disk.c disk.h load.c load.h mem.c mem.h machine.h machine_Linux.c machine_OpenBSD.c machine_FreeBSD.c machine_NetBSD.c machine_Darwin.c machine_SunOS.c util.c util.h lcdproc_SOURCES = main.c main.h mode.c mode.h batt.c batt.h chrono.c chrono.h cpu.c cpu.h cpu_smp.c cpu_smp.h disk.c disk.h load.c load.h mem.c mem.h machine.h machine_Linux.c machine_OpenBSD.c machine_FreeBSD.c machine_NetBSD.c machine_Darwin.c machine_SunOS.c util.c util.h iface.c iface.h
lcdproc_LDADD = @ldap_libs@ ../../shared/libLCDstuff.a lcdproc_LDADD = @ldap_libs@ ../../shared/libLCDstuff.a
+27
View File
@@ -30,6 +30,33 @@ OnTime=1
OffTime=2 OffTime=2
ShowInvisible=false ShowInvisible=false
[Iface]
# Show screen
Active=True
# Show stats for Interface0
Interface0=eth0
# Interface0 alias name to display
Alias0=LAN
# Show stats for Interface1
#Interface1=eth1
# Interface1 alias name to display
#Alias1=WAN
# Show stats for Interface2
#Interface2=eth2
# Interface2 alias name to display
#Alias2=MGMT
# for more than 3 interfaces change iface.h and rebuild
# Units to display byte, bit or packet
unit=bit
# add screen with transferred traffic
#transfer=TRUE
[Memory] [Memory]
# Show screen # Show screen
Active=True Active=True
+12 -8
View File
@@ -32,6 +32,7 @@
#include "load.h" #include "load.h"
#include "mem.h" #include "mem.h"
#include "machine.h" #include "machine.h"
#include "iface.h"
// TODO: Commenting... Everything! // TODO: Commenting... Everything!
@@ -82,6 +83,7 @@ mode sequence[] =
// flags default ACTIVE will run by default // flags default ACTIVE will run by default
// longname which on off inv timer flags // longname which on off inv timer flags
{ "CPU", 'C', 1, 2, 0, 0xffff, ACTIVE, cpu_screen }, // [C]PU { "CPU", 'C', 1, 2, 0, 0xffff, ACTIVE, cpu_screen }, // [C]PU
{ "Iface", 'I', 1, 2, 0, 0xffff, 0, iface_screen }, // [I]face
{ "Memory", 'M', 4, 16, 0, 0xffff, ACTIVE, mem_screen }, // [M]emory { "Memory", 'M', 4, 16, 0, 0xffff, ACTIVE, mem_screen }, // [M]emory
{ "Load", 'L', 64, 128, 1, 0xffff, ACTIVE, xload_screen }, // [L]oad (load histogram) { "Load", 'L', 64, 128, 1, 0xffff, ACTIVE, xload_screen }, // [L]oad (load histogram)
{ "TimeDate", 'T', 4, 64, 0, 0xffff, ACTIVE, time_screen }, // [T]ime/Date { "TimeDate", 'T', 4, 64, 0, 0xffff, ACTIVE, time_screen }, // [T]ime/Date
@@ -105,7 +107,7 @@ static int islow = -1;
char * progname = "lcdproc"; char * progname = "lcdproc";
char * server = NULL; char * server = NULL;
int port = LCDPORT; int port = LCDPORT;
int daemonize = UNSET_INT; int foreground = UNSET_INT;
static int report_level = UNSET_INT; static int report_level = UNSET_INT;
static int report_dest = UNSET_INT; static int report_dest = UNSET_INT;
char configfile[256]; /* a lot of space in the executable. */ char configfile[256]; /* a lot of space in the executable. */
@@ -217,7 +219,7 @@ main(int argc, char **argv)
lcd_cellwid = 5; lcd_cellwid = 5;
lcd_cellhgt = 8; lcd_cellhgt = 8;
if (daemonize) { if (foreground == 0) {
if (daemon(1,0) != 0) { if (daemon(1,0) != 0) {
fprintf(stderr, "Error: daemonize failed"); fprintf(stderr, "Error: daemonize failed");
return(EXIT_FAILURE); return(EXIT_FAILURE);
@@ -247,7 +249,7 @@ process_command_line(int argc, char **argv)
opterr = 0; opterr = 0;
/* get options */ /* get options */
while ((c = getopt( argc, argv, "s:p:e:c:dhv")) > 0) { while ((c = getopt( argc, argv, "s:p:e:c:fhv")) > 0) {
switch (c) { switch (c) {
// c is for config file // c is for config file
case 'c': case 'c':
@@ -272,8 +274,8 @@ process_command_line(int argc, char **argv)
case 'e': case 'e':
islow = atoi(optarg); islow = atoi(optarg);
break; break;
case 'd': case 'f':
daemonize = TRUE; foreground = TRUE;
break; break;
case 'h': case 'h':
HelpScreen(EXIT_SUCCESS); HelpScreen(EXIT_SUCCESS);
@@ -341,8 +343,8 @@ process_configfile(char *configfile)
report_dest = RPT_DEST_STDERR; report_dest = RPT_DEST_STDERR;
} }
} }
if (daemonize == UNSET_INT) { if (foreground == UNSET_INT) {
daemonize = config_get_bool(progname, "Daemonize", 0, 1); foreground = config_get_bool(progname, "Foreground", 0, 0);
} }
if (islow < 0) { if (islow < 0) {
islow = config_get_int(progname, "delay", 0, -1); islow = config_get_int(progname, "delay", 0, -1);
@@ -374,7 +376,7 @@ HelpScreen (int exit_state)
" where <options> are\n" " where <options> are\n"
" -s <host> connect to LCDd daemon on <host>\n" " -s <host> connect to LCDd daemon on <host>\n"
" -p <port> connect to LCDd daemon using <port>\n" " -p <port> connect to LCDd daemon using <port>\n"
" -d daemonize\n" " -f run in foreground\n"
" -e <delay> slow down initial announcement of modes (in 1/100s)\n" " -e <delay> slow down initial announcement of modes (in 1/100s)\n"
" -c <config> use a configuration file other than %s\n" " -c <config> use a configuration file other than %s\n"
" -h show this help screen\n" " -h show this help screen\n"
@@ -387,6 +389,7 @@ HelpScreen (int exit_state)
" M Memory memory & swap usage\n" " M Memory memory & swap usage\n"
" S ProcSize biggest processes size\n" " S ProcSize biggest processes size\n"
" D Disk disk usage\n" " D Disk disk usage\n"
" I Iface network interface usage\n"
" B Battery battery status\n" " B Battery battery status\n"
" T TimeDate time & date information\n" " T TimeDate time & date information\n"
" O OldTime old time screen\n" " O OldTime old time screen\n"
@@ -415,6 +418,7 @@ exit_program(int val)
exit(val); exit(val);
} }
#define LCDPROC_MENUS
#ifdef LCDPROC_MENUS #ifdef LCDPROC_MENUS
int int
menus_init () menus_init ()
+2
View File
@@ -61,6 +61,8 @@ const char *get_hostname();
const char *get_sysname(); const char *get_sysname();
const char *get_sysrelease(); const char *get_sysrelease();
extern char configfile[];
#ifndef min #ifndef min
# define min(a,b) (((a) < (b)) ? (a) : (b)) # define min(a,b) (((a) < (b)) ? (a) : (b))
#endif #endif
+3 -1
View File
@@ -255,7 +255,9 @@ mem_top_screen (int rep, int display, int *flags_ptr)
// frame from (2nd line, left) to (last line, right) // frame from (2nd line, left) to (last line, right)
sock_send_string(sock, "widget_add S f frame\n"); sock_send_string(sock, "widget_add S f frame\n");
sprintf(buffer, "widget_set S f 1 2 %i %i %i 5 v %i\n", sprintf(buffer, "widget_set S f 1 2 %i %i %i 5 v %i\n",
lcd_wid, lcd_hgt, lcd_wid, ((lcd_hgt >= 4) ? 8 : 12)); lcd_wid, lcd_hgt, lcd_wid,
// scroll rate: 1 line every X ticks (= 1/8 sec)
((lcd_hgt >= 4) ? 8 : 12));
sock_send_string(sock, buffer); sock_send_string(sock, buffer);
// frame contents // frame contents