Pārlūkot izejas kodu

Add ./tarball_archive/symon-2.79.tar.gz

Wictor Lund 3 gadi atpakaļ
vecāks
revīzija
9436a33349

+ 31 - 1
symon/CHANGELOG

@@ -1,3 +1,33 @@
+07/04/2008 - 2.79
+
+   - Top makefile will not compile symux - and not need librrd - if SYMON_ONLY
+     is set.
+
+   - platform/*BSD/sm_mem: pages are now shifted up on int64 instead of
+     int. (Volodymyr Kostyrko)
+
+   - platform/FreeBSD/sm_mem: hw.physmem - free is now used as the real memory
+     used value. This unbreaks the graphs for FreeBSD 6.3+. Note that real
+     memory used in this way means all wired, active, inactive and cached
+     memory, as well as gaps in the memory stats that are used by the kernel
+     itself.
+
+   - platform/Linux/Makefile.inc: removed easy override to TSORT/LORDER on
+     Linux. (Volodymyr Kostyrko)
+
+   - platform/Linux/Makefile.inc: more sensible defaults for owner, group and
+     install directories.
+
+   - platform/Linux/sm_io.c: count only read/write operations in io, not merged
+     reads and writes. This way io/s show actuator movements, instead of
+     movements + cache hits. (Yeb Havinga)
+
+   - Updated INSTALL about chrooted timezone gotchas. (Cory Waddingham)
+
+   - Added a cpuiow probe that counts iowait ticks on Linux. (Yeb Havinga)
+
+   - platform/Linux/sm_cpu now also parses /proc/stat without steal entry.
+
 06/01/2008 - 2.78
 06/01/2008 - 2.78
 
 
    - lib/sylimits.h: DFNAMESIZE bumped from 16 to 64 chars
    - lib/sylimits.h: DFNAMESIZE bumped from 16 to 64 chars
@@ -548,4 +578,4 @@
 29/09/2001 - Lexer had trouble dealing with ip-addresses. Cleaned up the number
 29/09/2001 - Lexer had trouble dealing with ip-addresses. Cleaned up the number
              parsing code and removed a second comment reader.
              parsing code and removed a second comment reader.
 
 
-$Id: CHANGELOG,v 1.76 2008/01/06 14:25:44 dijkstra Exp $
+$Id: CHANGELOG,v 1.87 2008/04/07 06:01:05 dijkstra Exp $

+ 20 - 1
symon/HACKERS

@@ -1,4 +1,23 @@
-$Id: HACKERS,v 1.2 2005/10/16 15:26:47 dijkstra Exp $
+$Id: HACKERS,v 1.3 2008/01/30 12:06:49 dijkstra Exp $
+
+Adding a probe for a new platform
+---------------------------------
+
+Look at similar probes for other platforms and work out what each value
+means. Ensure that your probe conveys the same semantics, this allows ppl that
+want to monitor several different platform simultaneously to compare probe
+measurements.
+
+Places to touch:
+
+- platform/<os>/sm_<name>.c: your probe
+
+- platform/<os>/cons.sh: your checks for system dependencies. Make sure you
+  check for features, not versions here.
+
+- platform/<os>/platform.h: stream_parg holds stream instance state data that
+  is platform specific.
+
 
 
 Adding a new probe
 Adding a new probe
 ------------------
 ------------------

+ 23 - 3
symon/INSTALL

@@ -19,9 +19,12 @@ FreeBSD:  - no privs: all
           - rw on /dev/pf for pf and pfq
           - rw on /dev/pf for pf and pfq
 
 
 Linux:    - r on /proc/net/dev: if
 Linux:    - r on /proc/net/dev: if
-          - r on /proc/stat: cpu
+          - r on /proc/stat: cpu, cpuiow
           - r on /proc/meminfo: mem
           - r on /proc/meminfo: mem
 
 
+all:
+          - r on <chroot>/etc/localtime for proper timezone logging
+
 Real quick on OpenBSD
 Real quick on OpenBSD
 =====================
 =====================
 (cd /usr/ports/net/rrdtool && make install) &&
 (cd /usr/ports/net/rrdtool && make install) &&
@@ -59,7 +62,20 @@ Less quick, but all OSes
      + SHRDIR = Where are the example configurations to be installed. Defaults
      + SHRDIR = Where are the example configurations to be installed. Defaults
                 to 'share/symon'.
                 to 'share/symon'.
 
 
-     + RRDDIR = $RRDDIR/include should yield rrd.h.
+     + RRDDIR = $RRDDIR/include should yield rrd.h. Define SYMON_ONLY in the
+                environment or on the make command line to render this mute.
+
+     + INSTALLUSER / GROUPDIR / GROUPFILE = user and groups that install should
+                use.
+
+  Note that:
+
+     + you can define SYMON_ONLY if you do not want to compile symux / do not
+       have rrdtool installed.
+
+     + symon/platform/<os>/Makefile.inc is read before Makefile.inc; define
+       your vars in the environment, or in Makefile.inc with != to force
+       overwriting the defaults.
 
 
    BSDs: Run make && make install
    BSDs: Run make && make install
   Linux: Run pmake && pmake install
   Linux: Run pmake && pmake install
@@ -74,6 +90,10 @@ Less quick, but all OSes
   syweb expects an '.../machine/*.rrd' style directory structure somewhere
   syweb expects an '.../machine/*.rrd' style directory structure somewhere
   under /var/www.
   under /var/www.
 
 
+- Ensure that /etc/localtime is accessible by symon/symux. Failing this you
+  will get log messages in GMT. Note that etc is <chroot>/etc when symon
+  chroots.
+
 - Both symon and symux will daemonize if started normally. Start them with
 - Both symon and symux will daemonize if started normally. Start them with
   debugging on initially to iron out any configuration problems:
   debugging on initially to iron out any configuration problems:
 
 
@@ -106,5 +126,5 @@ for FreeBSD, NetBSD and Linux.
 
 
 Willem Dijkstra - wpd@xs4all.nl
 Willem Dijkstra - wpd@xs4all.nl
 
 
-$Id: INSTALL,v 1.21 2006/12/19 22:37:11 dijkstra Exp $
+$Id: INSTALL,v 1.23 2008/02/21 09:37:38 dijkstra Exp $
 
 

+ 5 - 1
symon/Makefile

@@ -1,6 +1,10 @@
-# $Id: Makefile,v 1.14 2004/08/07 12:21:36 dijkstra Exp $
+# $Id: Makefile,v 1.15 2008/01/30 13:19:40 dijkstra Exp $
 
 
+.ifdef SYMON_ONLY
+SUBDIR= lib symon
+.else
 SUBDIR=	lib symon symux client
 SUBDIR=	lib symon symux client
+.endif
 
 
 .include "Makefile.inc"
 .include "Makefile.inc"
 
 

+ 6 - 4
symon/Makefile.inc

@@ -1,7 +1,6 @@
-# $Id: Makefile.inc,v 1.39 2007/12/12 12:16:16 dijkstra Exp $
+# $Id: Makefile.inc,v 1.41 2008/01/30 13:19:40 dijkstra Exp $
 
 
-V=2.78
-OS!=uname -s
+V=2.79
 
 
 AR?=	ar
 AR?=	ar
 CC?=	cc
 CC?=	cc
@@ -23,12 +22,15 @@ BINDIR?=libexec
 MANDIR?=man
 MANDIR?=man
 SHRDIR?=share/symon
 SHRDIR?=share/symon
 EXADIR?=share/examples/symon
 EXADIR?=share/examples/symon
-WEBDIR?=${SHRDIR}/web
 CLIENTDIR?=${SHRDIR}/client
 CLIENTDIR?=${SHRDIR}/client
 
 
 PREFIX?=/usr/local
 PREFIX?=/usr/local
 SYSCONFDIR?=/etc
 SYSCONFDIR?=/etc
 
 
+INSTALLUSER?=root
+INSTALLGROUPDIR?=bin
+INSTALLGROUPFILE?=wheel
+
 .SUFFIXES: .c .o .8 .cat8 .pm .cat3p
 .SUFFIXES: .c .o .8 .cat8 .pm .cat3p
 
 
 .c.o:
 .c.o:

+ 4 - 2
symon/TODO

@@ -9,11 +9,13 @@ TODO:
   should only read. clients should check incoming data for sanity.)
   should only read. clients should check incoming data for sanity.)
 
 
 - check for availability of rrd before compilation
 - check for availability of rrd before compilation
-- make user/group part of makefile.inc
+- upgrade percentages to a symon wide util; it is included seperately in all
+  cpu probes now.
+- same for pagetob and friends
 
 
 == longer term
 == longer term
 - change rrd to accommodate batch updates
 - change rrd to accommodate batch updates
 - write a muxer that supports unix pipes
 - write a muxer that supports unix pipes
 - test framework
 - test framework
 
 
-$Id: TODO,v 1.30 2007/11/29 13:59:03 dijkstra Exp $
+$Id: TODO,v 1.32 2008/02/20 08:17:17 dijkstra Exp $

+ 7 - 5
symon/client/Makefile

@@ -1,4 +1,6 @@
-# $Id: Makefile,v 1.2 2003/12/20 16:30:44 dijkstra Exp $
+# $Id: Makefile,v 1.3 2008/01/30 13:19:40 dijkstra Exp $
+OS!=uname -s
+.include "../platform/${OS}/Makefile.inc"
 .include "../Makefile.inc"
 .include "../Makefile.inc"
 
 
 all: SymuxClient.cat3p
 all: SymuxClient.cat3p
@@ -7,7 +9,7 @@ clean:
 	rm -f SymuxClient.cat3p
 	rm -f SymuxClient.cat3p
 
 
 install: SymuxClient.pm SymuxClient.cat3p getsymonitem.pl
 install: SymuxClient.pm SymuxClient.cat3p getsymonitem.pl
-	${INSTALL} -d -m 555 -g www -o www ${PREFIX}/${CLIENTDIR}
-	${INSTALL} -c -m 555 -g bin   -o root getsymonitem.pl      ${PREFIX}/${CLIENTDIR}
-	${INSTALL} -c -m 444 -g wheel -o root SymuxClient.pm       ${PREFIX}/${CLIENTDIR}
-	${INSTALL} -c -m 444 -g wheel -o root SymuxClient.cat3p    ${PREFIX}/${CLIENTDIR}/SymuxClient.0
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${CLIENTDIR}
+	${INSTALL} -c -m 555 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} getsymonitem.pl      ${PREFIX}/${CLIENTDIR}/
+	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} SymuxClient.pm       ${PREFIX}/${CLIENTDIR}/
+	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} SymuxClient.cat3p    ${PREFIX}/${CLIENTDIR}/SymuxClient.0

+ 3 - 2
symon/client/SymuxClient.pm

@@ -1,6 +1,6 @@
-# $Id: SymuxClient.pm,v 1.13 2007/02/11 20:07:31 dijkstra Exp $
+# $Id: SymuxClient.pm,v 1.14 2008/01/30 13:19:40 dijkstra Exp $
 #
 #
-# Copyright (c) 2001-2007 Willem Dijkstra
+# Copyright (c) 2001-2008 Willem Dijkstra
 # All rights reserved.
 # All rights reserved.
 #
 #
 # Redistribution and use in source and binary forms, with or without
 # Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,7 @@ use IO::Socket;
 
 
 my $streamitem =
 my $streamitem =
     {cpu    => {user => 1, nice => 2, system => 3, interrupt => 4, idle => 5},
     {cpu    => {user => 1, nice => 2, system => 3, interrupt => 4, idle => 5},
+     cpuiow => {user => 1, nice => 2, system => 3, interrupt => 4, idle => 5, iowait => 6},
      mem    => {real_active => 1, real_total => 2, free => 3, swap_used => 4,
      mem    => {real_active => 1, real_total => 2, free => 3, swap_used => 4,
 	        swap_total =>5},
 	        swap_total =>5},
      if     => {packets_in => 1, packets_out => 2, bytes_in => 3, bytes_out => 4,
      if     => {packets_in => 1, packets_out => 2, bytes_in => 3, bytes_out => 4,

+ 3 - 2
symon/lib/Makefile

@@ -1,6 +1,7 @@
-# $Id: Makefile,v 1.13 2005/10/16 15:26:51 dijkstra Exp $
-.include "../Makefile.inc"
+# $Id: Makefile,v 1.14 2008/01/30 13:19:40 dijkstra Exp $
+OS!=uname -s
 .include "../platform/${OS}/Makefile.inc"
 .include "../platform/${OS}/Makefile.inc"
+.include "../Makefile.inc"
 
 
 SRCS=   error.c lex.c xmalloc.c net.c data.c
 SRCS=   error.c lex.c xmalloc.c net.c data.c
 OBJS+=	${SRCS:R:S/$/.o/g}
 OBJS+=	${SRCS:R:S/$/.o/g}

+ 4 - 2
symon/lib/data.c

@@ -1,7 +1,7 @@
-/* $Id: data.c,v 1.35 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: data.c,v 1.36 2008/01/30 12:06:49 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * The crc routine is by Rob Warnock <rpw3@sgi.com>, from the
  * The crc routine is by Rob Warnock <rpw3@sgi.com>, from the
@@ -111,6 +111,7 @@ struct {
     { MT_DF, "LLLLLLL" },
     { MT_DF, "LLLLLLL" },
     { MT_MEM2, "LLLLL" },
     { MT_MEM2, "LLLLL" },
     { MT_IF2, "LLLLLLLLLL" },
     { MT_IF2, "LLLLLLLLLL" },
+    { MT_CPUIOW, "cccccc" },
     { MT_TEST, "LLLLDDDDllllssssccccbbbb" },
     { MT_TEST, "LLLLDDDDllllssssccccbbbb" },
     { MT_EOT, "" }
     { MT_EOT, "" }
 };
 };
@@ -133,6 +134,7 @@ struct {
     { MT_DF, LXT_DF },
     { MT_DF, LXT_DF },
     { MT_MEM2, LXT_MEM },
     { MT_MEM2, LXT_MEM },
     { MT_IF2, LXT_IF },
     { MT_IF2, LXT_IF },
+    { MT_CPUIOW, LXT_CPUIOW },
     { MT_EOT, LXT_BADTOKEN }
     { MT_EOT, LXT_BADTOKEN }
 };
 };
 /* parallel crc32 table */
 /* parallel crc32 table */

+ 18 - 5
symon/lib/data.h

@@ -1,7 +1,7 @@
-/* $Id: data.h,v 1.32 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: data.h,v 1.33 2008/01/30 12:06:49 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -141,7 +141,11 @@ SLIST_HEAD(muxlist, mux);
 #define PS2STR_PRETTY 0
 #define PS2STR_PRETTY 0
 #define PS2STR_RRD    1
 #define PS2STR_RRD    1
 
 
-/* Stream types */
+/* Stream types
+ *
+ * Add new items at the bottom to preserve compatibility with older symon
+ * instances
+ */
 #define MT_IO1    0
 #define MT_IO1    0
 #define MT_CPU    1
 #define MT_CPU    1
 #define MT_MEM1   2
 #define MT_MEM1   2
@@ -156,8 +160,9 @@ SLIST_HEAD(muxlist, mux);
 #define MT_DF     11
 #define MT_DF     11
 #define MT_MEM2   12
 #define MT_MEM2   12
 #define MT_IF2    13
 #define MT_IF2    13
-#define MT_TEST   14
-#define MT_EOT    15
+#define MT_CPUIOW 14
+#define MT_TEST   15
+#define MT_EOT    16
 
 
 /*
 /*
  * Unpacking of incoming packets is done via a packedstream structure. This
  * Unpacking of incoming packets is done via a packedstream structure. This
@@ -316,6 +321,14 @@ struct packedstream {
             u_int64_t mcolls;
             u_int64_t mcolls;
             u_int64_t mdrops;
             u_int64_t mdrops;
         }      ps_if2;
         }      ps_if2;
+        struct {
+            u_int16_t muser;
+            u_int16_t mnice;
+            u_int16_t msystem;
+            u_int16_t minterrupt;
+            u_int16_t midle;
+            u_int16_t miowait;
+        }      ps_cpuiow;
     }     data;
     }     data;
 };
 };
 
 

+ 3 - 2
symon/lib/lex.c

@@ -1,7 +1,7 @@
-/* $Id: lex.c,v 1.29 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: lex.c,v 1.30 2008/01/30 12:06:50 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -70,6 +70,7 @@ static struct {
     { ",", LXT_COMMA },
     { ",", LXT_COMMA },
     { "accept", LXT_ACCEPT },
     { "accept", LXT_ACCEPT },
     { "cpu", LXT_CPU },
     { "cpu", LXT_CPU },
+    { "cpuiow", LXT_CPUIOW },
     { "datadir", LXT_DATADIR },
     { "datadir", LXT_DATADIR },
     { "debug", LXT_DEBUG },
     { "debug", LXT_DEBUG },
     { "df", LXT_DF },
     { "df", LXT_DF },

+ 31 - 30
symon/lib/lex.h

@@ -1,7 +1,7 @@
-/* $Id: lex.h,v 1.25 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: lex.h,v 1.26 2008/01/30 12:06:50 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -49,34 +49,35 @@
 #define LXT_CLOSE      3
 #define LXT_CLOSE      3
 #define LXT_COMMA      4
 #define LXT_COMMA      4
 #define LXT_CPU        5
 #define LXT_CPU        5
-#define LXT_DATADIR    6
-#define LXT_DEBUG      7
-#define LXT_DF         8
-#define LXT_END        9
-#define LXT_EVERY     10
-#define LXT_FROM      11
-#define LXT_IF        12
-#define LXT_IF1       13
-#define LXT_IN        14
-#define LXT_IO        15
-#define LXT_IO1       16
-#define LXT_MBUF      17
-#define LXT_MEM       18
-#define LXT_MEM1      19
-#define LXT_MONITOR   20
-#define LXT_MUX       21
-#define LXT_OPEN      22
-#define LXT_PF        23
-#define LXT_PFQ       24
-#define LXT_PORT      25
-#define LXT_PROC      26
-#define LXT_SECOND    27
-#define LXT_SECONDS   28
-#define LXT_SENSOR    29
-#define LXT_SOURCE    30
-#define LXT_STREAM    31
-#define LXT_TO        32
-#define LXT_WRITE     33
+#define LXT_CPUIOW     6
+#define LXT_DATADIR    7
+#define LXT_DEBUG      8
+#define LXT_DF         9
+#define LXT_END       10
+#define LXT_EVERY     11
+#define LXT_FROM      12
+#define LXT_IF        13
+#define LXT_IF1       14
+#define LXT_IN        15
+#define LXT_IO        16
+#define LXT_IO1       17
+#define LXT_MBUF      18
+#define LXT_MEM       19
+#define LXT_MEM1      20
+#define LXT_MONITOR   21
+#define LXT_MUX       22
+#define LXT_OPEN      23
+#define LXT_PF        24
+#define LXT_PFQ       25
+#define LXT_PORT      26
+#define LXT_PROC      27
+#define LXT_SECOND    28
+#define LXT_SECONDS   29
+#define LXT_SENSOR    30
+#define LXT_SOURCE    31
+#define LXT_STREAM    32
+#define LXT_TO        33
+#define LXT_WRITE     34
 
 
 struct lex {
 struct lex {
     char *buffer;               /* current line(s) */
     char *buffer;               /* current line(s) */

+ 6 - 5
symon/platform/FreeBSD/Makefile.inc

@@ -1,5 +1,6 @@
-# $Id: Makefile.inc,v 1.5 2007/11/29 13:59:16 dijkstra Exp $
-SYMON_LIBS=-lkvm -ldevstat
-SYMUX_LIBS=-lm
-SYSCONFDIR=${PREFIX}/etc
-BINDIR=bin
+# $Id: Makefile.inc,v 1.6 2008/01/30 13:19:40 dijkstra Exp $
+SYMON_LIBS?=-lkvm -ldevstat
+SYMUX_LIBS?=-lm
+
+SYSCONFDIR?=${PREFIX}/etc
+BINDIR?=bin

+ 32 - 10
symon/platform/FreeBSD/sm_mem.c

@@ -1,7 +1,8 @@
-/* $Id: sm_mem.c,v 1.11 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: sm_mem.c,v 1.14 2008/03/21 13:22:03 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2004-2007      Matthew Gream
+ * Copyright (c) 2004      Matthew Gream
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -53,12 +54,16 @@
 #include "symon.h"
 #include "symon.h"
 #include "xmalloc.h"
 #include "xmalloc.h"
 
 
-#define pagetob(size) ((size) << me_pageshift)
+#define pagetob(size) (((u_int64_t)size) << me_pageshift)
 
 
 /* Globals for this module all start with me_ */
 /* Globals for this module all start with me_ */
 static u_int64_t me_pagesize;
 static u_int64_t me_pagesize;
 static u_int64_t me_pageshift;
 static u_int64_t me_pageshift;
 
 
+static char me_physmem_mib_str[] = "hw.physmem";
+static int me_physmem_mib_nam[CTL_MAXNAME];
+static size_t me_physmem_mib_len = 0;
+
 static char me_vmnswp_mib_str[] = "vm.nswapdev";
 static char me_vmnswp_mib_str[] = "vm.nswapdev";
 static int me_vmnswp_mib_nam[CTL_MAXNAME];
 static int me_vmnswp_mib_nam[CTL_MAXNAME];
 static size_t me_vmnswp_mib_len = 0;
 static size_t me_vmnswp_mib_len = 0;
@@ -83,15 +88,21 @@ init_mem(struct stream *st)
         me_pagesize >>= 1;
         me_pagesize >>= 1;
     }
     }
 
 
+    me_physmem_mib_len = CTL_MAXNAME;
+    if (sysctlnametomib(me_physmem_mib_str, me_physmem_mib_nam, &me_physmem_mib_len) < 0) {
+        warning("sysctlnametomib for %.200s failed", me_physmem_mib_str);
+        me_physmem_mib_len = 0;
+    }
+
     me_vmnswp_mib_len = CTL_MAXNAME;
     me_vmnswp_mib_len = CTL_MAXNAME;
     if (sysctlnametomib(me_vmnswp_mib_str, me_vmnswp_mib_nam, &me_vmnswp_mib_len) < 0) {
     if (sysctlnametomib(me_vmnswp_mib_str, me_vmnswp_mib_nam, &me_vmnswp_mib_len) < 0) {
-        warning("sysctlnametomib for nswapdev failed");
+        warning("sysctlnametomib for %.200s failed", me_vmnswp_mib_str);
         me_vmnswp_mib_len = 0;
         me_vmnswp_mib_len = 0;
     }
     }
 
 
     me_vmiswp_mib_len = CTL_MAXNAME;
     me_vmiswp_mib_len = CTL_MAXNAME;
     if (sysctlnametomib(me_vmiswp_mib_str, me_vmiswp_mib_nam, &me_vmiswp_mib_len) < 0) {
     if (sysctlnametomib(me_vmiswp_mib_str, me_vmiswp_mib_nam, &me_vmiswp_mib_len) < 0) {
-        warning("sysctlnametomib for swap_info failed");
+        warning("sysctlnametomib for %.200s failed", me_vmiswp_mib_str);
         me_vmiswp_mib_len = 0;
         me_vmiswp_mib_len = 0;
     }
     }
 
 
@@ -103,24 +114,35 @@ gets_mem()
 {
 {
 #ifdef HAS_XSWDEV
 #ifdef HAS_XSWDEV
     int i;
     int i;
-    int vmnswp_dat, vmnswp_siz;
+    u_int vmnswp_dat;
+    size_t vmnswp_siz;
 #endif
 #endif
+    u_long physmem_dat;
+    size_t physmem_siz;
+
+    bzero(&me_vmtotal, sizeof(me_vmtotal));
 
 
     if (sysctl(me_vm_mib, 2, &me_vmtotal, &me_vmsize, NULL, 0) < 0) {
     if (sysctl(me_vm_mib, 2, &me_vmtotal, &me_vmsize, NULL, 0) < 0) {
         warning("%s:%d: sysctl failed", __FILE__, __LINE__);
         warning("%s:%d: sysctl failed", __FILE__, __LINE__);
-        bzero(&me_vmtotal, sizeof(me_vmtotal));
+        return;
+    }
+
+    physmem_siz = sizeof(u_long);
+    if (sysctl(me_physmem_mib_nam, me_physmem_mib_len, &physmem_dat, (void *)&physmem_siz, NULL, 0) < 0) {
+        warning("%s:%d: sysctl %.200s failed", __FILE__, __LINE__, me_physmem_mib_str);
+        return;
     }
     }
 
 
     /* convert memory stats to Kbytes */
     /* convert memory stats to Kbytes */
     me_stats[0] = pagetob(me_vmtotal.t_arm);
     me_stats[0] = pagetob(me_vmtotal.t_arm);
-    me_stats[1] = pagetob(me_vmtotal.t_rm);
+    me_stats[1] = ((u_int64_t) physmem_dat) - pagetob(me_vmtotal.t_free);
     me_stats[2] = pagetob(me_vmtotal.t_free);
     me_stats[2] = pagetob(me_vmtotal.t_free);
     me_stats[3] = me_stats[4] = 0;
     me_stats[3] = me_stats[4] = 0;
 
 
 #ifdef HAS_XSWDEV
 #ifdef HAS_XSWDEV
-    vmnswp_siz = sizeof (int);
+    vmnswp_siz = sizeof(int);
     if (sysctl(me_vmnswp_mib_nam, me_vmnswp_mib_len, &vmnswp_dat, (void *)&vmnswp_siz, NULL, 0) < 0) {
     if (sysctl(me_vmnswp_mib_nam, me_vmnswp_mib_len, &vmnswp_dat, (void *)&vmnswp_siz, NULL, 0) < 0) {
-        warning("%s:%d: sysctl nswapdev failed", __FILE__, __LINE__);
+        warning("%s:%d: sysctl %.200s failed", __FILE__, __LINE__, me_vmnswp_mib_str);
         vmnswp_dat = 0;
         vmnswp_dat = 0;
     }
     }
     for (i = 0; i < vmnswp_dat; i++) {
     for (i = 0; i < vmnswp_dat; i++) {

+ 3 - 2
symon/platform/FreeBSD/sm_proc.c

@@ -1,7 +1,8 @@
-/* $Id: sm_proc.c,v 1.8 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_proc.c,v 1.9 2008/02/20 08:17:19 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2004      Matthew Gream
  * Copyright (c) 2004      Matthew Gream
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -54,7 +55,7 @@
 #include "symon.h"
 #include "symon.h"
 #include "xmalloc.h"
 #include "xmalloc.h"
 
 
-#define pagetob(size) ((size) << proc_pageshift)
+#define pagetob(size) (((u_int32_t)size) << proc_pageshift)
 
 
 /* Globals for this module start with proc_ */
 /* Globals for this module start with proc_ */
 static struct kinfo_proc *proc_ps = NULL;
 static struct kinfo_proc *proc_ps = NULL;

+ 11 - 2
symon/platform/Linux/Makefile.inc

@@ -1,3 +1,12 @@
-# $Id: Makefile.inc,v 1.3 2006/12/19 22:31:41 dijkstra Exp $
+# $Id: Makefile.inc,v 1.5 2008/02/21 09:37:47 dijkstra Exp $
+
+# LORDER and TSORT are non-functional and not needed on Linux. Tinker with
+# these at your own peril.
 LORDER=echo
 LORDER=echo
-TSORT= cat
+TSORT=cat
+
+BINDIR?=bin
+
+INSTALLUSER?=root
+INSTALLGROUPFILE?=bin
+INSTALLGROUPDIR?=bin

+ 13 - 5
symon/platform/Linux/platform.h

@@ -1,8 +1,9 @@
-/* $Id: platform.h,v 1.8 2007/07/16 07:37:11 dijkstra Exp $ */
+/* $Id: platform.h,v 1.10 2008/04/06 13:02:12 dijkstra Exp $ */
 
 
 #ifndef _CONF_LINUX_H
 #ifndef _CONF_LINUX_H
 #define _CONF_LINUX_H
 #define _CONF_LINUX_H
 
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <grp.h>
 #include <grp.h>
 
 
@@ -40,12 +41,19 @@ union semun {
 
 
 union stream_parg {
 union stream_parg {
     struct {
     struct {
-        int64_t time[CPUSTATES];
-        int64_t old[CPUSTATES];
-        int64_t diff[CPUSTATES];
-        int64_t states[CPUSTATES];
+        u_int64_t time[CPUSTATES];
+        u_int64_t old[CPUSTATES];
+        u_int64_t diff[CPUSTATES];
+        u_int64_t states[CPUSTATES];
         char name[6];
         char name[6];
     } cp;
     } cp;
+    struct {
+        u_int64_t time[CPUSTATES];
+        u_int64_t old[CPUSTATES];
+        u_int64_t diff[CPUSTATES];
+        u_int64_t states[CPUSTATES];
+        char name[6];
+    } cpw;
     struct {
     struct {
         char mountpath[MAX_PATH_LEN];
         char mountpath[MAX_PATH_LEN];
     } df;
     } df;

+ 15 - 4
symon/platform/Linux/sm_cpu.c

@@ -1,11 +1,11 @@
-/* $Id: sm_cpu.c,v 1.7 2007/07/09 12:54:18 dijkstra Exp $ */
+/* $Id: sm_cpu.c,v 1.9 2008/01/30 12:06:50 dijkstra Exp $ */
 
 
 /* The author of this code is Willem Dijkstra (wpd@xs4all.nl).
 /* The author of this code is Willem Dijkstra (wpd@xs4all.nl).
  *
  *
  * The percentages function was written by William LeFebvre and is part
  * The percentages function was written by William LeFebvre and is part
  * of the 'top' utility. His copyright statement is below.
  * of the 'top' utility. His copyright statement is below.
  *
  *
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -69,7 +69,7 @@
 #include "xmalloc.h"
 #include "xmalloc.h"
 
 
 __BEGIN_DECLS
 __BEGIN_DECLS
-int percentages(int, int64_t *, int64_t *, int64_t *, int64_t *);
+static int percentages(int, int64_t *, int64_t *, int64_t *, int64_t *);
 __END_DECLS
 __END_DECLS
 
 
 /* Globals for this module all start with cp_ */
 /* Globals for this module all start with cp_ */
@@ -84,7 +84,7 @@ static int cp_maxsize = 0;
  *      The routine assumes modulo arithmetic.  This function is especially
  *      The routine assumes modulo arithmetic.  This function is especially
  *      useful on BSD mchines for calculating cpu state percentages.
  *      useful on BSD mchines for calculating cpu state percentages.
  */
  */
-int
+static int
 percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_t *diffs)
 percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_t *diffs)
 {
 {
     int64_t change, total_change, *dp, half_total;
     int64_t change, total_change, *dp, half_total;
@@ -194,8 +194,19 @@ get_cpu(char *symon_buf, int maxlen, struct stream *st)
                            &st->parg.cp.time[CP_HARDIRQ],
                            &st->parg.cp.time[CP_HARDIRQ],
                            &st->parg.cp.time[CP_SOFTIRQ],
                            &st->parg.cp.time[CP_SOFTIRQ],
                            &st->parg.cp.time[CP_STEAL])) {
                            &st->parg.cp.time[CP_STEAL])) {
+      /* /proc/stat might not support steal */
+      st->parg.cp.time[CP_STEAL] = 0;
+      if ((CPUSTATES - 1) > sscanf(line, "%llu %llu %llu %llu %llu %llu %llu\n",
+				   &st->parg.cp.time[CP_USER],
+				   &st->parg.cp.time[CP_NICE],
+				   &st->parg.cp.time[CP_SYS],
+				   &st->parg.cp.time[CP_IDLE],
+				   &st->parg.cp.time[CP_IOWAIT],
+				   &st->parg.cp.time[CP_HARDIRQ],
+				   &st->parg.cp.time[CP_SOFTIRQ])) {
         warning("could not parse cpu statistics for %.200s", &st->parg.cp.name);
         warning("could not parse cpu statistics for %.200s", &st->parg.cp.name);
         return 0;
         return 0;
+      }
     }
     }
 
 
     percentages(CPUSTATES, st->parg.cp.states, st->parg.cp.time,
     percentages(CPUSTATES, st->parg.cp.states, st->parg.cp.time,

+ 224 - 0
symon/platform/Linux/sm_cpuiow.c

@@ -0,0 +1,224 @@
+/* $Id: sm_cpuiow.c,v 1.2 2008/01/30 14:29:31 dijkstra Exp $ */
+
+/* The author of this code is Willem Dijkstra (wpd@xs4all.nl).
+ *
+ * The percentages function was written by William LeFebvre and is part
+ * of the 'top' utility. His copyright statement is below.
+ *
+ * Copyright (c) 2001-2008 Willem Dijkstra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    - Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    - Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*
+ *  Top users/processes display for Unix
+ *  Version 3
+ *
+ *  This program may be freely redistributed,
+ *  but this entire comment MUST remain intact.
+ *
+ *  Copyright (c) 1984, 1989, William LeFebvre, Rice University
+ *  Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University
+ */
+
+/*
+ * Get current cpu statistics in percentages (total of all counts = 100.0)
+ * and returns them in symon_buf as
+ *
+ * user : nice : system : interrupt : idle : iowait
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+
+#include "conf.h"
+#include "error.h"
+#include "symon.h"
+#include "xmalloc.h"
+
+__BEGIN_DECLS
+static int percentages(int, int64_t *, int64_t *, int64_t *, int64_t *);
+__END_DECLS
+
+/* Globals for this module all start with cpw_ */
+static void *cpw_buf = NULL;
+static int cpw_size = 0;
+static int cpw_maxsize = 0;
+/*
+ *  percentages(cnt, out, new, old, diffs) - calculate percentage change
+ *      between array "old" and "new", putting the percentages i "out".
+ *      "cnt" is size of each array and "diffs" is used for scratch space.
+ *      The array "old" is updated on each call.
+ *      The routine assumes modulo arithmetic.  This function is especially
+ *      useful on BSD mchines for calculating cpu state percentages.
+ */
+static int
+percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_t *diffs)
+{
+    int64_t change, total_change, *dp, half_total;
+    int i;
+
+    /* initialization */
+    total_change = 0;
+    dp = diffs;
+
+    /* calculate changes for each state and the overall change */
+    for (i = 0; i < cnt; i++) {
+        if ((change = *new - *old) < 0) {
+            /* this only happens when the counter wraps */
+            change = (QUAD_MAX - *old) + *new;
+        }
+        total_change += (*dp++ = change);
+        *old++ = *new++;
+    }
+
+    /* avoid divide by zero potential */
+    if (total_change == 0)
+        total_change = 1;
+
+    /* calculate percentages based on overall change, rounding up */
+    half_total = total_change / 2l;
+    for (i = 0; i < cnt; i++)
+        *out++ = ((*diffs++ * 1000 + half_total) / total_change);
+
+    /* return the total in case the caller wants to use it */
+    return (total_change);
+}
+
+void
+init_cpuiow(struct stream *st)
+{
+    char buf[SYMON_MAX_OBJSIZE];
+
+    if (cpw_buf == NULL) {
+        cpw_maxsize = SYMON_MAX_OBJSIZE;
+        cpw_buf = xmalloc(cpw_maxsize);
+    }
+
+    if (st->arg != NULL && isdigit(*st->arg)) {
+        snprintf(st->parg.cpw.name, sizeof(st->parg.cpw.name), "cpu%s", st->arg);
+    } else {
+        snprintf(st->parg.cpw.name, sizeof(st->parg.cpw.name), "cpu");
+    }
+
+    gets_cpuiow();
+    get_cpuiow(buf, sizeof(buf), st);
+
+    info("started module cpuiow(%.200s)", st->arg);
+}
+
+void
+gets_cpuiow()
+{
+    int fd;
+
+    if ((fd = open("/proc/stat", O_RDONLY)) < 0) {
+        warning("cannot access /proc/stat: %.200s", strerror(errno));
+        return;
+    }
+
+    bzero(cpw_buf, cpw_maxsize);
+    cpw_size = read(fd, cpw_buf, cpw_maxsize);
+    close(fd);
+
+    if (cpw_size == cpw_maxsize) {
+        /* buffer is too small to hold all interface data */
+        cpw_maxsize += SYMON_MAX_OBJSIZE;
+        if (cpw_maxsize > SYMON_MAX_OBJSIZE * SYMON_MAX_DOBJECTS) {
+            fatal("%s:%d: dynamic object limit (%d) exceeded for cp data",
+                  __FILE__, __LINE__, SYMON_MAX_OBJSIZE * SYMON_MAX_DOBJECTS);
+        }
+        cpw_buf = xrealloc(cpw_buf, cpw_maxsize);
+        gets_cpuiow();
+        return;
+    }
+
+    if (cpw_size == -1) {
+        warning("could not read if statistics from /proc/stat: %.200s", strerror(errno));
+    }
+}
+
+int
+get_cpuiow(char *symon_buf, int maxlen, struct stream *st)
+{
+    char *line;
+
+    if (cpw_size <= 0) {
+        return 0;
+    }
+
+    if ((line = strstr(cpw_buf, st->parg.cpw.name)) == NULL) {
+        warning("could not find %s", st->parg.cpw.name);
+        return 0;
+    }
+
+    line += strlen(st->parg.cpw.name);
+    if (CPUSTATES > sscanf(line, "%llu %llu %llu %llu %llu %llu %llu %llu\n",
+                           &st->parg.cpw.time[CP_USER],
+                           &st->parg.cpw.time[CP_NICE],
+                           &st->parg.cpw.time[CP_SYS],
+                           &st->parg.cpw.time[CP_IDLE],
+                           &st->parg.cpw.time[CP_IOWAIT],
+                           &st->parg.cpw.time[CP_HARDIRQ],
+                           &st->parg.cpw.time[CP_SOFTIRQ],
+                           &st->parg.cpw.time[CP_STEAL])) {
+        /* /proc/stat might not support steal */
+        st->parg.cpw.time[CP_STEAL] = 0;
+        if ((CPUSTATES - 1) > sscanf(line, "%llu %llu %llu %llu %llu %llu %llu\n",
+                                     &st->parg.cpw.time[CP_USER],
+                                     &st->parg.cpw.time[CP_NICE],
+                                     &st->parg.cpw.time[CP_SYS],
+                                     &st->parg.cpw.time[CP_IDLE],
+                                     &st->parg.cpw.time[CP_IOWAIT],
+                                     &st->parg.cpw.time[CP_HARDIRQ],
+                                     &st->parg.cpw.time[CP_SOFTIRQ])) {
+            warning("could not parse cpu statistics for %.200s", &st->parg.cpw.name);
+            return 0;
+        }
+    }
+
+    percentages(CPUSTATES, st->parg.cpw.states, st->parg.cpw.time,
+                st->parg.cpw.old, st->parg.cpw.diff);
+
+    return snpack(symon_buf, maxlen, st->arg, MT_CPUIOW,
+                  (double) (st->parg.cpw.states[CP_USER] / 10.0),
+                  (double) (st->parg.cpw.states[CP_NICE] / 10.0),
+                  (double) (st->parg.cpw.states[CP_SYS] / 10.0),
+                  (double) (st->parg.cpw.states[CP_HARDIRQ] +
+                            st->parg.cpw.states[CP_SOFTIRQ] +
+                            st->parg.cpw.states[CP_STEAL]) / 10.0,
+                  (double) (st->parg.cpw.states[CP_IDLE] / 10.0),
+                  (double) (st->parg.cpw.states[CP_IOWAIT] / 10.0));
+}

+ 17 - 17
symon/platform/Linux/sm_io.c

@@ -1,4 +1,4 @@
-/* $Id: sm_io.c,v 1.2 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_io.c,v 1.3 2008/04/06 13:02:12 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2006 Willem Dijkstra
  * Copyright (c) 2001-2006 Willem Dijkstra
@@ -57,17 +57,17 @@ static int io_size = 0;
 static int io_maxsize = 0;
 static int io_maxsize = 0;
 struct io_device_stats
 struct io_device_stats
 {
 {
-    uint64_t read_issued;
-    uint64_t read_merged;
-    uint64_t read_sectors;
-    uint64_t read_milliseconds;
-    uint64_t write_issued;
-    uint64_t write_merged;
-    uint64_t write_sectors;
-    uint64_t write_milliseconds;
-    uint64_t progress_ios;
-    uint64_t progress_milliseconds;
-    uint64_t progress_weight;
+    u_int64_t read_issued;
+    u_int64_t read_merged;
+    u_int64_t read_sectors;
+    u_int64_t read_milliseconds;
+    u_int64_t write_issued;
+    u_int64_t write_merged;
+    u_int64_t write_sectors;
+    u_int64_t write_milliseconds;
+    u_int64_t progress_ios;
+    u_int64_t progress_milliseconds;
+    u_int64_t progress_weight;
 };
 };
 #ifdef HAS_PROC_DISKSTATS
 #ifdef HAS_PROC_DISKSTATS
 char *io_filename = "/proc/diskstats";
 char *io_filename = "/proc/diskstats";
@@ -159,11 +159,11 @@ get_io(char *symon_buf, int maxlen, struct stream *st)
 #endif
 #endif
 
 
     return snpack(symon_buf, maxlen, st->arg, MT_IO2,
     return snpack(symon_buf, maxlen, st->arg, MT_IO2,
-                  (stats.read_issued + stats.read_merged),
-                  (stats.write_issued + stats.write_merged),
-                  (uint64_t) 0,
-                  (uint64_t)(stats.read_sectors * DEV_BSIZE),
-                  (uint64_t)(stats.write_sectors * DEV_BSIZE));
+                  stats.read_issued,
+                  stats.write_issued,
+                  (u_int64_t) 0,
+                  (u_int64_t)(stats.read_sectors * DEV_BSIZE),
+                  (u_int64_t)(stats.write_sectors * DEV_BSIZE));
 }
 }
 #else
 #else
 void
 void

+ 4 - 4
symon/platform/Linux/sm_mem.c

@@ -1,4 +1,4 @@
-/* $Id: sm_mem.c,v 1.6 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: sm_mem.c,v 1.7 2008/01/30 14:29:31 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2005-2007 Harm Schotanus
  * Copyright (c) 2005-2007 Harm Schotanus
@@ -94,10 +94,10 @@ gets_mem()
    }
    }
 }
 }
 
 
-long
+u_int64_t
 mem_getitem(char *name)
 mem_getitem(char *name)
 {
 {
-    long stat;
+    u_int64_t stat;
     char *line;
     char *line;
 
 
     if (me_size <= 0) {
     if (me_size <= 0) {
@@ -110,7 +110,7 @@ mem_getitem(char *name)
     }
     }
 
 
     line += strlen(name);
     line += strlen(name);
-    if (1 < sscanf(line, ": %lu Kb", &stat)) {
+    if (1 < sscanf(line, ": %llu Kb", &stat)) {
         warning("could not parse memory statistics");
         warning("could not parse memory statistics");
         return 0;
         return 0;
     } else {
     } else {

+ 2 - 2
symon/platform/NetBSD/Makefile.inc

@@ -1,2 +1,2 @@
-# $Id: Makefile.inc,v 1.4 2006/12/19 22:31:42 dijkstra Exp $
-RRDDIR=/usr/pkg
+# $Id: Makefile.inc,v 1.5 2008/01/30 13:19:40 dijkstra Exp $
+RRDDIR?=/usr/pkg

+ 3 - 3
symon/platform/NetBSD/sm_mem.c

@@ -1,7 +1,7 @@
-/* $Id: sm_mem.c,v 1.3 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: sm_mem.c,v 1.4 2008/02/20 08:17:25 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@
 #include "symon.h"
 #include "symon.h"
 #include "xmalloc.h"
 #include "xmalloc.h"
 
 
-#define pagetob(size) ((size) << me_pageshift)
+#define pagetob(size) (((u_int64_t)size) << me_pageshift)
 
 
 /* Globals for this module all start with me_ */
 /* Globals for this module all start with me_ */
 static u_int64_t me_pageshift;
 static u_int64_t me_pageshift;

+ 3 - 3
symon/platform/NetBSD/sm_proc.c

@@ -1,8 +1,8 @@
-/* $Id: sm_proc.c,v 1.5 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_proc.c,v 1.6 2008/02/20 08:17:25 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2004      Matthew Gream
  * Copyright (c) 2004      Matthew Gream
- * Copyright (c) 2001-2005 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,7 @@
 #include "symon.h"
 #include "symon.h"
 #include "xmalloc.h"
 #include "xmalloc.h"
 
 
-#define pagetob(size) ((size) << proc_pageshift)
+#define pagetob(size) (((u_int32_t)size) << proc_pageshift)
 
 
 /* Globals for this module start with proc_ */
 /* Globals for this module start with proc_ */
 static struct kinfo_proc *proc_ps = NULL;
 static struct kinfo_proc *proc_ps = NULL;

+ 3 - 3
symon/platform/OpenBSD/Makefile.inc

@@ -1,3 +1,3 @@
-# $Id: Makefile.inc,v 1.4 2006/12/19 22:31:44 dijkstra Exp $
-SYMUX_LIBS=-L/usr/X11R6/lib -lfontconfig
-MANDIR=man
+# $Id: Makefile.inc,v 1.5 2008/01/30 13:19:40 dijkstra Exp $
+SYMUX_LIBS?=-L/usr/X11R6/lib -lfontconfig
+MANDIR?=man

+ 3 - 3
symon/platform/OpenBSD/sm_mem.c

@@ -1,7 +1,7 @@
-/* $Id: sm_mem.c,v 1.22 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: sm_mem.c,v 1.23 2008/02/20 08:17:25 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@
 #include "symon.h"
 #include "symon.h"
 #include "xmalloc.h"
 #include "xmalloc.h"
 
 
-#define pagetob(size) ((size) << me_pageshift)
+#define pagetob(size) (((u_int64_t)size) << me_pageshift)
 
 
 /* Globals for this module all start with me_ */
 /* Globals for this module all start with me_ */
 static u_int64_t me_pageshift;
 static u_int64_t me_pageshift;

+ 3 - 3
symon/platform/OpenBSD/sm_proc.c

@@ -1,7 +1,7 @@
-/* $Id: sm_proc.c,v 1.8 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_proc.c,v 1.9 2008/02/20 08:17:25 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2005 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,7 @@
 #include "symon.h"
 #include "symon.h"
 #include "xmalloc.h"
 #include "xmalloc.h"
 
 
-#define pagetob(size) ((size) << proc_pageshift)
+#define pagetob(size) (((u_int32_t)size) << proc_pageshift)
 
 
 /* Globals for this module start with proc_ */
 /* Globals for this module start with proc_ */
 static struct kinfo_proc *proc_ps = NULL;
 static struct kinfo_proc *proc_ps = NULL;

+ 26 - 0
symon/platform/stub/sm_cpuiow.c

@@ -0,0 +1,26 @@
+/* $Id: sm_cpuiow.c,v 1.1 2008/01/30 12:06:50 dijkstra Exp $ */
+
+#include <stdlib.h>
+
+#include "sylimits.h"
+#include "data.h"
+#include "error.h"
+
+void
+init_cpuiow(struct stream *st)
+{
+    fatal("cpuiow module not available");
+}
+void
+gets_cpuiow()
+{
+    fatal("cpuiow module not available");
+}
+int
+get_cpuiow(char *symon_buf, int maxlen, struct stream *st)
+{
+    fatal("cpuiow module not available");
+
+    /* NOT REACHED */
+    return 0;
+}

+ 10 - 8
symon/symon/Makefile

@@ -1,6 +1,7 @@
-# $Id: Makefile,v 1.40 2006/12/19 22:31:47 dijkstra Exp $
-.include "../Makefile.inc"
+# $Id: Makefile,v 1.41 2008/01/30 13:19:40 dijkstra Exp $
+OS!=uname -s
 .include "../platform/${OS}/Makefile.inc"
 .include "../platform/${OS}/Makefile.inc"
+.include "../Makefile.inc"
 
 
 LIBS+=	${SYMON_LIBS} -L../lib -lsymon
 LIBS+=	${SYMON_LIBS} -L../lib -lsymon
 MODS!=	( for g in ../platform/stub/sm_*.c; do \
 MODS!=	( for g in ../platform/stub/sm_*.c; do \
@@ -27,12 +28,13 @@ clean:
 	rm -f conf.h symon symon.cat8 symon.core ${OBJS}
 	rm -f conf.h symon symon.cat8 symon.core ${OBJS}
 
 
 install: symon symon.8 symon.conf
 install: symon symon.8 symon.conf
-	${INSTALL} -c -m 555  -g wheel -o root symon      ${PREFIX}/${BINDIR}
-	${INSTALL} -c -m 444  -g wheel -o root symon.8 ${PREFIX}/${MANDIR}/man8/symon.8
-	${INSTALL} -d -m 555  -g bin   -o root ${PREFIX}/${SHRDIR}
-	${INSTALL} -c -m 555  -g wheel -o root c_config.sh ${PREFIX}/${SHRDIR}
-	${INSTALL} -d -m 555  -g bin   -o root ${PREFIX}/${EXADIR}
-	${INSTALL} -c -m 444  -g bin   -o root symon.conf ${PREFIX}/${EXADIR}
+	${INSTALL} -c -m 555 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symon      ${PREFIX}/${BINDIR}/
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${MANDIR}/man8
+	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symon.8 ${PREFIX}/${MANDIR}/man8/symon.8
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${SHRDIR}
+	${INSTALL} -c -m 555 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} c_config.sh ${PREFIX}/${SHRDIR}/
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${EXADIR}
+	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symon.conf ${PREFIX}/${EXADIR}/
 
 
 conf.h:  Makefile ../Makefile.inc
 conf.h:  Makefile ../Makefile.inc
 	@echo Generating $@ on ${OS}
 	@echo Generating $@ on ${OS}

+ 13 - 11
symon/symon/readconf.c

@@ -1,7 +1,7 @@
-/* $Id: readconf.c,v 1.28 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: readconf.c,v 1.29 2008/01/30 12:06:50 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2005 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@ __END_DECLS
 
 
 const char *default_symux_port = SYMUX_PORT;
 const char *default_symux_port = SYMUX_PORT;
 
 
-/* <hostname> (port|:|,| ) <number> */
+/* parse "(ip4addr | ip6addr | hostname) [['port' | ',' ] portnumber]" */
 int
 int
 read_host_port(struct muxlist * mul, struct mux * mux, struct lex * l)
 read_host_port(struct muxlist * mul, struct mux * mux, struct lex * l)
 {
 {
@@ -89,7 +89,7 @@ read_host_port(struct muxlist * mul, struct mux * mux, struct lex * l)
 
 
     return 1;
     return 1;
 }
 }
-/* parse "<cpu(arg)|df(arg)|mem|if(arg)|io(arg)|debug|pf|pfq(arg)|proc(arg)>", end condition == "}" */
+/* parse "resource version ['(' argument ')']", end condition == '}' */
 int
 int
 read_symon_args(struct mux * mux, struct lex * l)
 read_symon_args(struct mux * mux, struct lex * l)
 {
 {
@@ -101,17 +101,18 @@ read_symon_args(struct mux * mux, struct lex * l)
         while (lex_nexttoken(l) && l->op != LXT_END) {
         while (lex_nexttoken(l) && l->op != LXT_END) {
         switch (l->op) {
         switch (l->op) {
         case LXT_CPU:
         case LXT_CPU:
+        case LXT_CPUIOW:
+        case LXT_DEBUG:
         case LXT_DF:
         case LXT_DF:
-        case LXT_IF:
         case LXT_IF1:
         case LXT_IF1:
-        case LXT_IO:
+        case LXT_IF:
         case LXT_IO1:
         case LXT_IO1:
-        case LXT_MEM:
+        case LXT_IO:
+        case LXT_MBUF:
         case LXT_MEM1:
         case LXT_MEM1:
+        case LXT_MEM:
         case LXT_PF:
         case LXT_PF:
         case LXT_PFQ:
         case LXT_PFQ:
-        case LXT_MBUF:
-        case LXT_DEBUG:
         case LXT_PROC:
         case LXT_PROC:
         case LXT_SENSOR:
         case LXT_SENSOR:
             st = token2type(l->op);
             st = token2type(l->op);
@@ -152,7 +153,7 @@ read_symon_args(struct mux * mux, struct lex * l)
         case LXT_COMMA:
         case LXT_COMMA:
             break;
             break;
         default:
         default:
-            parse_error(l, "{cpu|df|if|if1|io|io1|mem|mem1|pf|pfq|mbuf|debug|proc|sensor}");
+            parse_error(l, "{cpu|cpuiow|df|if|if1|io|io1|mem|mem1|pf|pfq|mbuf|debug|proc|sensor}");
             return 0;
             return 0;
             break;
             break;
         }
         }
@@ -161,7 +162,8 @@ read_symon_args(struct mux * mux, struct lex * l)
     return 1;
     return 1;
 }
 }
 
 
-/* parse monitor <args> stream [from <host>] [to] <host>:<port> */
+/* parse "'monitor' '{' resources '}' ['every' time ] 'stream' ['from' host]
+ * ['to'] host [port]" */
 int
 int
 read_monitor(struct muxlist * mul, struct lex * l)
 read_monitor(struct muxlist * mul, struct lex * l)
 {
 {

+ 8 - 6
symon/symon/symon.8

@@ -1,6 +1,6 @@
 .\"  -*- nroff -*-
 .\"  -*- nroff -*-
 .\"
 .\"
-.\" Copyright (c) 2001-2007 Willem Dijkstra
+.\" Copyright (c) 2001-2008 Willem Dijkstra
 .\" All rights reserved.
 .\" All rights reserved.
 .\"
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd December 11, 2007
+.Dd January 30, 2008
 .Dt SYMON 8
 .Dt SYMON 8
 .Os
 .Os
 .Sh NAME
 .Sh NAME
@@ -105,10 +105,12 @@ newlines and text behind '#' are ignored. The format in BNF:
 .nf
 .nf
 monitor-rule = "monitor" "{" resources "}" [every]
 monitor-rule = "monitor" "{" resources "}" [every]
                "stream" ["from" host] ["to"] host [ port ]
                "stream" ["from" host] ["to"] host [ port ]
-resources    = resource ["(" argument ")"] [ ","|" " resources ]
-argument     = number | interfacename | diskname
-resource     = "cpu" | "mem" | "if" | "io" | "pf" | "pfq" |
-               "debug" | "proc" | "mbuf" | "sensor" | "df"
+resources    = resource [ version ] ["(" argument ")"]
+               [ ","|" " resources ]
+resource     = "cpu" | "cpuiow" | "debug" | "df" | "if" | "io"
+               "mbuf" | "mem" | "pf" | "pfq" | "proc" | "sensor"
+version      = number
+argument     = number | name
 every        = "every" time
 every        = "every" time
 time         = "second" | number "seconds"
 time         = "second" | number "seconds"
 host         = ip4addr | ip6addr | hostname
 host         = ip4addr | ip6addr | hostname

+ 6 - 2
symon/symon/symon.c

@@ -1,7 +1,7 @@
-/* $Id: symon.c,v 1.50 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: symon.c,v 1.53 2008/02/12 12:43:04 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -84,6 +84,7 @@ struct funcmap streamfunc[] = {
     {MT_DF, 0, NULL, init_df, gets_df, get_df},
     {MT_DF, 0, NULL, init_df, gets_df, get_df},
     {MT_MEM2, 0, NULL, init_mem, gets_mem, get_mem},
     {MT_MEM2, 0, NULL, init_mem, gets_mem, get_mem},
     {MT_IF2, 0, NULL, init_if, gets_if, get_if},
     {MT_IF2, 0, NULL, init_if, gets_if, get_if},
+    {MT_CPUIOW, 0, NULL, init_cpuiow, gets_cpuiow, get_cpuiow},
     {MT_EOT, 0, NULL, NULL, NULL}
     {MT_EOT, 0, NULL, NULL, NULL}
 };
 };
 
 
@@ -249,6 +250,9 @@ main(int argc, char *argv[])
 
 
     drop_privileges(flag_unsecure);
     drop_privileges(flag_unsecure);
 
 
+    /* TODO: howto log using active timezone, which may be unavailable in
+     * chroot */
+
     info("symon version %s", SYMON_VERSION);
     info("symon version %s", SYMON_VERSION);
 
 
     if (flag_debug == 1)
     if (flag_debug == 1)

+ 6 - 1
symon/symon/symon.h

@@ -1,4 +1,4 @@
-/* $Id: symon.h,v 1.36 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: symon.h,v 1.37 2008/01/30 12:06:50 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2005 Willem Dijkstra
  * Copyright (c) 2001-2005 Willem Dijkstra
@@ -66,6 +66,11 @@ extern void init_cpu(struct stream *);
 extern void gets_cpu();
 extern void gets_cpu();
 extern int get_cpu(char *, int, struct stream *);
 extern int get_cpu(char *, int, struct stream *);
 
 
+/* sm_cpuiow.c */
+extern void init_cpuiow(struct stream *);
+extern void gets_cpuiow();
+extern int get_cpuiow(char *, int, struct stream *);
+
 /* sm_mem.c */
 /* sm_mem.c */
 extern void init_mem(struct stream *);
 extern void init_mem(struct stream *);
 extern void gets_mem();
 extern void gets_mem();

+ 10 - 8
symon/symux/Makefile

@@ -1,6 +1,7 @@
-# $Id: Makefile,v 1.24 2006/12/19 22:30:47 dijkstra Exp $
-.include "../Makefile.inc"
+# $Id: Makefile,v 1.25 2008/01/30 13:19:40 dijkstra Exp $
+OS!=uname -s
 .include "../platform/${OS}/Makefile.inc"
 .include "../platform/${OS}/Makefile.inc"
+.include "../Makefile.inc"
 
 
 SRCS=	symux.c readconf.c symuxnet.c share.c
 SRCS=	symux.c readconf.c symuxnet.c share.c
 OBJS+=	${SRCS:R:S/$/.o/g}
 OBJS+=	${SRCS:R:S/$/.o/g}
@@ -19,12 +20,13 @@ clean:
 	rm -f conf.h symux symux.cat8 symux.core ${OBJS}
 	rm -f conf.h symux symux.cat8 symux.core ${OBJS}
 
 
 install: symux symux.8 c_smrrds.sh symux.conf
 install: symux symux.8 c_smrrds.sh symux.conf
-	${INSTALL} -c -m 555 -g bin   -o root symux	   ${PREFIX}/${BINDIR}
-	${INSTALL} -c -m 444 -g wheel -o root symux.8	   ${PREFIX}/${MANDIR}/man8/symux.8
-	${INSTALL} -d -m 555 -g bin   -o root ${PREFIX}/${SHRDIR}
-	${INSTALL} -c -m 544 -g bin   -o root c_smrrds.sh  ${PREFIX}/${SHRDIR}
-	${INSTALL} -d -m 555 -g bin   -o root ${PREFIX}/${EXADIR}
-	${INSTALL} -c -m 444 -g bin   -o root symux.conf   ${PREFIX}/${EXADIR}
+	${INSTALL} -c -m 555 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symux	   ${PREFIX}/${BINDIR}/
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${MANDIR}/man8
+	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symux.8	   ${PREFIX}/${MANDIR}/man8/symux.8
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${SHRDIR}
+	${INSTALL} -c -m 544 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} c_smrrds.sh  ${PREFIX}/${SHRDIR}/
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${EXADIR}
+	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symux.conf   ${PREFIX}/${EXADIR}/
 
 
 cleanipc:
 cleanipc:
 	ipcs | egrep "^m" | awk '{print $$2}' | xargs -n1 ipcrm -m &
 	ipcs | egrep "^m" | awk '{print $$2}' | xargs -n1 ipcrm -m &

+ 26 - 3
symon/symux/c_smrrds.sh

@@ -1,5 +1,5 @@
 #!/bin/sh
 #!/bin/sh
-# $Id: c_smrrds.sh,v 1.39 2007/12/12 12:16:16 dijkstra Exp $
+# $Id: c_smrrds.sh,v 1.40 2008/01/30 12:06:50 dijkstra Exp $
 
 
 #
 #
 # Copyright (c) 2001-2006 Willem Dijkstra
 # Copyright (c) 2001-2006 Willem Dijkstra
@@ -72,6 +72,10 @@ find_exec() {
 }
 }
 # find rrdtool
 # find rrdtool
 RRDTOOL=`find_exec "$RRDTOOL" /usr/local/bin rrdtool`
 RRDTOOL=`find_exec "$RRDTOOL" /usr/local/bin rrdtool`
+if [ ! -x "$RRDTOOL" ]; then
+    echo "Cannot find rrdtool - add it to \$PATH or \$RRDTOOL"
+    exit 1;
+fi
 # get arguments
 # get arguments
 select_interval=""
 select_interval=""
 for i
 for i
@@ -110,7 +114,7 @@ if [ X"$1$2$3$4$5$6$7$8$9" = "X" ]; then
     cat <<EOF
     cat <<EOF
 Create rrd files for symux.
 Create rrd files for symux.
 
 
-Usage: `basename $0` [oneday] [interval <seconds>] [all] \
+Usage: `basename $0` [oneday] [interval <seconds>] [all] \\
 		     <rrd files>
 		     <rrd files>
 
 
 Where:
 Where:
@@ -119,6 +123,10 @@ seconds      = modify rrds for non standard monitoring interval
 all          = run symux -l to determine current configured rrd
 all          = run symux -l to determine current configured rrd
 	       files
 	       files
 <rrd files>  = files ending in rrd that follow symux naming
 <rrd files>  = files ending in rrd that follow symux naming
+
+If rrdtool or symux are not installed in default locations try
+setting \$PATH or \$RRDTOOL, \$SYMUX.
+
 EOF
 EOF
     exit 1;
     exit 1;
 fi
 fi
@@ -137,7 +145,11 @@ j=`basename $i`
 case $j in
 case $j in
 
 
 all)
 all)
-    SYMUX=`find_exec "$SYMUX" /usr/libexec:/usr/local/libexec symux`
+    SYMUX=`find_exec "$SYMUX" /usr/libexec:/usr/local/libexec:/usr/local/bin:/usr/local/sbin symux`
+    if [ ! -x "$SYMUX" ]; then
+        echo "Cannot find symux - add it to \$PATH or \$SYMUX"
+        exit 1;
+    fi
     sh $this interval $INTERVAL child $config `$SYMUX -l`
     sh $this interval $INTERVAL child $config `$SYMUX -l`
     ;;
     ;;
 
 
@@ -151,6 +163,17 @@ cpu[0-9].rrd)
 	DS:idle:GAUGE:$INTERVAL:0:100
 	DS:idle:GAUGE:$INTERVAL:0:100
     ;;
     ;;
 
 
+cpuiow[0-9].rrd)
+    # Build cpuiow file
+    create_rrd $i \
+	DS:user:GAUGE:$INTERVAL:0:100 \
+	DS:nice:GAUGE:$INTERVAL:0:100 \
+	DS:system:GAUGE:$INTERVAL:0:100 \
+	DS:interrupt:GAUGE:$INTERVAL:0:100 \
+	DS:idle:GAUGE:$INTERVAL:0:100 \
+	DS:iowait:GAUGE:$INTERVAL:0:100
+    ;;
+
 df_*.rrd)
 df_*.rrd)
     # Build df file
     # Build df file
     create_rrd $i \
     create_rrd $i \

+ 23 - 17
symon/symux/readconf.c

@@ -1,7 +1,7 @@
-/* $Id: readconf.c,v 1.34 2007/12/11 14:17:59 dijkstra Exp $ */
+/* $Id: readconf.c,v 1.35 2008/01/30 12:06:50 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2007 Willem Dijkstra
+ * Copyright (c) 2001-2008 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -67,6 +67,10 @@ insert_filename(char *path, int maxlen, int type, char *args)
         ts = "cpu";
         ts = "cpu";
         ta = args;
         ta = args;
         break;
         break;
+    case MT_CPUIOW:
+        ts = "cpuiow";
+        ta = args;
+        break;
     case MT_DF:
     case MT_DF:
         ts = "df_";
         ts = "df_";
         ta = args;
         ta = args;
@@ -135,7 +139,7 @@ insert_filename(char *path, int maxlen, int type, char *args)
     xfree(fta);
     xfree(fta);
     return result;
     return result;
 }
 }
-/* mux <host> (port|,| ) <number> */
+/* parse "'mux' (ip4addr | ip6addr | hostname) [['port' | ',' portnumber]" */
 int
 int
 read_mux(struct muxlist * mul, struct lex * l)
 read_mux(struct muxlist * mul, struct lex * l)
 {
 {
@@ -179,7 +183,7 @@ read_mux(struct muxlist * mul, struct lex * l)
 
 
     return 1;
     return 1;
 }
 }
-/* source <host> { accept ... | write ... | datadir ... } */
+/* parse "'source' host '{' accept-stmst [write-stmts] [datadir-stmts] '}'" */
 int
 int
 read_source(struct sourcelist * sol, struct lex * l, int filecheck)
 read_source(struct sourcelist * sol, struct lex * l, int filecheck)
 {
 {
@@ -212,17 +216,18 @@ read_source(struct sourcelist * sol, struct lex * l, int filecheck)
             while (lex_nexttoken(l) && l->op != LXT_END) {
             while (lex_nexttoken(l) && l->op != LXT_END) {
                 switch (l->op) {
                 switch (l->op) {
                 case LXT_CPU:
                 case LXT_CPU:
+                case LXT_CPUIOW:
+                case LXT_DEBUG:
                 case LXT_DF:
                 case LXT_DF:
-                case LXT_IF:
                 case LXT_IF1:
                 case LXT_IF1:
-                case LXT_IO:
+                case LXT_IF:
                 case LXT_IO1:
                 case LXT_IO1:
-                case LXT_MEM:
+                case LXT_IO:
+                case LXT_MBUF:
                 case LXT_MEM1:
                 case LXT_MEM1:
+                case LXT_MEM:
                 case LXT_PF:
                 case LXT_PF:
                 case LXT_PFQ:
                 case LXT_PFQ:
-                case LXT_MBUF:
-                case LXT_DEBUG:
                 case LXT_PROC:
                 case LXT_PROC:
                 case LXT_SENSOR:
                 case LXT_SENSOR:
                     st = token2type(l->op);
                     st = token2type(l->op);
@@ -262,7 +267,7 @@ read_source(struct sourcelist * sol, struct lex * l, int filecheck)
                         return 0;
                         return 0;
                     }
                     }
 
 
-                    break;      /* LXT_CPU/IF/IF1/IO/IO1/MEM/MEM1/PF/MBUF/DEBUG/PROC */
+                    break;      /* LXT_resource */
                 case LXT_COMMA:
                 case LXT_COMMA:
                     break;
                     break;
                 default:
                 default:
@@ -354,17 +359,18 @@ read_source(struct sourcelist * sol, struct lex * l, int filecheck)
             lex_nexttoken(l);
             lex_nexttoken(l);
             switch (l->op) {
             switch (l->op) {
             case LXT_CPU:
             case LXT_CPU:
+            case LXT_CPUIOW:
+            case LXT_DEBUG:
             case LXT_DF:
             case LXT_DF:
-            case LXT_IF:
             case LXT_IF1:
             case LXT_IF1:
-            case LXT_IO:
+            case LXT_IF:
             case LXT_IO1:
             case LXT_IO1:
-            case LXT_MEM:
+            case LXT_IO:
+            case LXT_MBUF:
             case LXT_MEM1:
             case LXT_MEM1:
+            case LXT_MEM:
             case LXT_PF:
             case LXT_PF:
             case LXT_PFQ:
             case LXT_PFQ:
-            case LXT_MBUF:
-            case LXT_DEBUG:
             case LXT_PROC:
             case LXT_PROC:
             case LXT_SENSOR:
             case LXT_SENSOR:
                 st = token2type(l->op);
                 st = token2type(l->op);
@@ -426,9 +432,9 @@ read_source(struct sourcelist * sol, struct lex * l, int filecheck)
                         stream->file = xstrdup(l->token);
                         stream->file = xstrdup(l->token);
                     }
                     }
                 }
                 }
-                break;          /* LXT_CPU/IF/IF1/IO/IO1/MEM/MEM1/PF/PFQ/MBUF/DEBUG/PROC/SENSOR */
+                break;          /* LXT_resource */
             default:
             default:
-                parse_error(l, "{cpu|if|io|mem|pf|mbuf|debug|proc|sensor}");
+                parse_error(l, "{cpu|cpuiow|df|if|if1|io|io1|mem|mem1|pf|pfq|mbuf|debug|proc|sensor}");
                 return 0;
                 return 0;
                 break;
                 break;
             }
             }

+ 10 - 6
symon/symux/symux.8

@@ -1,6 +1,6 @@
 .\"  -*- nroff -*-
 .\"  -*- nroff -*-
 .\"
 .\"
-.\" Copyright (c) 2001-2007 Willem Dijkstra
+.\" Copyright (c) 2001-2008 Willem Dijkstra
 .\" All rights reserved.
 .\" All rights reserved.
 .\"
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd December 11, 2007
+.Dd January 30, 2008
 .Dt SYMUX 8
 .Dt SYMUX 8
 .Os
 .Os
 .Sh NAME
 .Sh NAME
@@ -115,11 +115,11 @@ source-stmt  = "source" host "{"
                [ datadir-stmt ] "}"
                [ datadir-stmt ] "}"
 accept-stmts = accept-stmt [accept-stmts]
 accept-stmts = accept-stmt [accept-stmts]
 accept-stmt  = "accept" "{" resources "}"
 accept-stmt  = "accept" "{" resources "}"
-resources    = resource version ["(" argument ")"]
+resources    = resource [ version ] ["(" argument ")"]
                [ ","|" " resources ]
                [ ","|" " resources ]
-resource     = "cpu" | "mem" | "if" | "io" | "pf" | "pfq" |
-               "debug" | "proc" | "mbuf" | "sensor" | "df"
-version      = "" | number
+resource     = "cpu" | "cpuiow" | "debug" | "df" | "if" | "io"
+               "mbuf" | "mem" | "pf" | "pfq" | "proc" | "sensor"
+version      = number
 argument     = number | interfacename | diskname
 argument     = number | interfacename | diskname
 datadir-stmt = "datadir" dirname
 datadir-stmt = "datadir" dirname
 write-stmts  = write-stmt [write-stmts]
 write-stmts  = write-stmt [write-stmts]
@@ -218,6 +218,9 @@ Data formats:
 .It cpu
 .It cpu
 Time spent in ( user, nice, system, interrupt, idle ). Total time is 100, data
 Time spent in ( user, nice, system, interrupt, idle ). Total time is 100, data
 is offered with precision 2.
 is offered with precision 2.
+.It cpuiow
+Time spent in ( user, nice, system, interrupt, idle, iowait ). Total time is
+100, data is offered with precision 2.
 .It debug
 .It debug
 Kernel variables debug0 to debug19. ( debug0 : ... : debug19 ). Values are 32
 Kernel variables debug0 to debug19. ( debug0 : ... : debug19 ). Values are 32
 bit unsigned integers.
 bit unsigned integers.
@@ -315,6 +318,7 @@ These streams should be identified as if1(<interface>) and mem1() in
 symon versions 2.78 and up will always report if2 and mem2 statistics. The rrd
 symon versions 2.78 and up will always report if2 and mem2 statistics. The rrd
 files for the old and new probes are identical and need not be changed.
 files for the old and new probes are identical and need not be changed.
 .El
 .El
+.Pp
 .Nm
 .Nm
 will output what version of information it is offered by symon(8)s on
 will output what version of information it is offered by symon(8)s on
 the network when started with the
 the network when started with the