Browse Source

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

Wictor Lund 3 years ago
parent
commit
082b3a258b
56 changed files with 255 additions and 130 deletions
  1. 31 1
      symon/CHANGELOG
  2. 0 0
      symon/INSTALL
  3. 0 0
      symon/Makefile
  4. 2 2
      symon/Makefile.inc
  5. 0 0
      symon/TODO
  6. 0 0
      symon/client/SymuxClient.pm
  7. 0 0
      symon/client/getsymonitem.pl
  8. 0 0
      symon/lib/Makefile
  9. 6 4
      symon/lib/data.c
  10. 0 0
      symon/lib/data.h
  11. 0 0
      symon/lib/error.c
  12. 0 0
      symon/lib/error.h
  13. 0 0
      symon/lib/lex.c
  14. 0 0
      symon/lib/lex.h
  15. 0 0
      symon/lib/net.c
  16. 0 0
      symon/lib/net.h
  17. 0 0
      symon/lib/xmalloc.c
  18. 0 0
      symon/lib/xmalloc.h
  19. 1 1
      symon/platform/FreeBSD/sm_mbuf.c
  20. 21 10
      symon/platform/Linux/platform.h
  21. 21 17
      symon/platform/Linux/sm_cpu.c
  22. 10 0
      symon/platform/NetBSD/conf.sh
  23. 2 1
      symon/platform/NetBSD/platform.h
  24. 61 2
      symon/platform/NetBSD/sm_io.c
  25. 0 0
      symon/platform/NetBSD/sm_mem.c
  26. 0 0
      symon/platform/NetBSD/sm_pf.c
  27. 6 1
      symon/platform/NetBSD/sm_pfq.c
  28. 4 11
      symon/platform/OpenBSD/platform.h
  29. 57 59
      symon/platform/OpenBSD/sm_cpu.c
  30. 0 0
      symon/platform/OpenBSD/sm_debug.c
  31. 2 4
      symon/platform/OpenBSD/sm_if.c
  32. 0 0
      symon/platform/OpenBSD/sm_io.c
  33. 0 0
      symon/platform/OpenBSD/sm_mbuf.c
  34. 0 0
      symon/platform/OpenBSD/sm_mem.c
  35. 0 0
      symon/platform/OpenBSD/sm_pf.c
  36. 0 0
      symon/platform/OpenBSD/sm_proc.c
  37. 0 0
      symon/platform/OpenBSD/sm_sensor.c
  38. 0 0
      symon/symon/Makefile
  39. 5 2
      symon/symon/readconf.c
  40. 0 0
      symon/symon/readconf.h
  41. 0 0
      symon/symon/symon.8
  42. 4 4
      symon/symon/symon.c
  43. 0 0
      symon/symon/symon.h
  44. 0 0
      symon/symon/symonnet.c
  45. 0 0
      symon/symon/symonnet.h
  46. 0 0
      symon/symux/Makefile
  47. 16 4
      symon/symux/c_smrrds.sh
  48. 0 0
      symon/symux/readconf.c
  49. 0 0
      symon/symux/readconf.h
  50. 0 0
      symon/symux/share.c
  51. 0 0
      symon/symux/share.h
  52. 0 0
      symon/symux/symux.8
  53. 6 7
      symon/symux/symux.c
  54. 0 0
      symon/symux/symux.h
  55. 0 0
      symon/symux/symuxnet.c
  56. 0 0
      symon/symux/symuxnet.h

+ 31 - 1
symon/CHANGELOG

@@ -1,3 +1,33 @@
+05/07/2007 - 2.76
+
+   - symux/readconf.c resolve from host, but discard result. (Henning Brauer)
+
+   - symux/symux.c -f used strncpy wrong and broke when using gcc4
+     (Mechiel Lukkien)
+
+   - platform/Linux/sm_cpu now uses iowait + hardirq + softirq + steal as its
+     cpu "interrupt". My feeling is that this is the most accurate
+     representation of what the values mean for the *BSDs.
+
+   - platform/NetBSD/sm_io uses new iostat_sysctl of NetBSD4
+
+   - platform/NetBSD/sm_pfq uses NetBSD3/4 altq stat names.
+
+   - symux/c_smrrds.sh now searches for rrdtool and symux in {$RRDTOOL,
+     $SYMUX}, $PATH and in the installation dirs. (Benoit Garcia)
+
+   - platform/OpenBSD/sm_if removed obselete netipx includes
+     (Christian Weisgerber)
+
+   - Daemon needs to be able to bind /dev/null - drop privileges after daemon
+     call (Markus Friedl).
+
+   - data.c/free_muxlist closed fd 0 at HUP. This makes symux unresponsive on
+     OpenBSD and makes it stop on FreeBSD. (Marco Pfatschbacher).
+
+   - platform/OpenBSD/sm_cpu fixed to call CPTIME2 only for machines with more
+     than one cpu. (Henning Brauer)
+
 13/02/2007 - 2.75
 
    - OpenBSD sensors missed includes (Constantine A. Murenin)
@@ -481,4 +511,4 @@
 29/09/2001 - Lexer had trouble dealing with ip-addresses. Cleaned up the number
              parsing code and removed a second comment reader.
 
-$Id: CHANGELOG,v 1.58 2007/02/11 20:12:15 dijkstra Exp $
+$Id: CHANGELOG,v 1.66 2007/07/09 11:46:00 dijkstra Exp $

+ 0 - 0
symon/INSTALL


+ 0 - 0
symon/Makefile


+ 2 - 2
symon/Makefile.inc

@@ -1,6 +1,6 @@
-# $Id: Makefile.inc,v 1.34 2007/02/11 20:07:31 dijkstra Exp $
+# $Id: Makefile.inc,v 1.36 2007/07/05 12:16:07 dijkstra Exp $
 
-V=2.75
+V=2.76
 OS!=uname -s
 
 AR?=	ar

+ 0 - 0
symon/TODO


+ 0 - 0
symon/client/SymuxClient.pm


+ 0 - 0
symon/client/getsymonitem.pl


+ 0 - 0
symon/lib/Makefile


+ 6 - 4
symon/lib/data.c

@@ -1,7 +1,7 @@
-/* $Id: data.c,v 1.31 2007/02/11 20:07:31 dijkstra Exp $ */
+/* $Id: data.c,v 1.32 2007/04/20 18:53:22 dijkstra Exp $ */
 
 /*
- * Copyright (c) 2001-2005 Willem Dijkstra
+ * Copyright (c) 2001-2007 Willem Dijkstra
  * All rights reserved.
  *
  * The crc routine is by Rob Warnock <rpw3@sgi.com>, from the
@@ -861,9 +861,11 @@ free_muxlist(struct muxlist * mul)
             xfree(p->addr);
         if (p->port != NULL)
             xfree(p->port);
+        if (p->clientsocket)
+		close(p->clientsocket);
+        if (p->symuxsocket)
+		close(p->symuxsocket);
 
-        close(p->clientsocket);
-        close(p->symuxsocket);
         for (i = 0; i < AF_MAX; i++)
             if (p->symonsocket[i])
                 close(p->symonsocket[i]);

+ 0 - 0
symon/lib/data.h


+ 0 - 0
symon/lib/error.c


+ 0 - 0
symon/lib/error.h


+ 0 - 0
symon/lib/lex.c


+ 0 - 0
symon/lib/lex.h


+ 0 - 0
symon/lib/net.c


+ 0 - 0
symon/lib/net.h


+ 0 - 0
symon/lib/xmalloc.c


+ 0 - 0
symon/lib/xmalloc.h


+ 1 - 1
symon/platform/FreeBSD/sm_mbuf.c

@@ -1,4 +1,4 @@
-/* $Id: sm_mbuf.c,v 1.6 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_mbuf.c,v 1.7 2007/04/20 18:53:24 dijkstra Exp $ */
 
 /*
  * Copyright (c) 2004 Matthew Gream

+ 21 - 10
symon/platform/Linux/platform.h

@@ -1,4 +1,4 @@
-/* $Id: platform.h,v 1.4 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: platform.h,v 1.7 2007/07/09 13:19:46 dijkstra Exp $ */
 
 #ifndef _CONF_LINUX_H
 #define _CONF_LINUX_H
@@ -19,18 +19,29 @@ union semun {
         int val;
 };
 
-#define CPUSTATES 4
-#define CP_USER 0
-#define CP_NICE 1
-#define CP_SYS  2
-#define CP_IDLE 3
+#ifdef LONG_LONG_MAX
+#define QUAD_MAX LONG_LONG_MAX
+#endif
+#ifndef QUAD_MAX
+#define QUAD_MAX     (0x7fffffffffffffffLL)
+#endif
+
+#define CPUSTATES    8
+#define CP_USER      0
+#define CP_NICE      1
+#define CP_SYS       2
+#define CP_IDLE      3
+#define CP_IOWAIT    4
+#define CP_HARDIRQ   5
+#define CP_SOFTIRQ   6
+#define CP_STEAL     7
 
 union stream_parg {
     struct {
-        long time[CPUSTATES];
-        long old[CPUSTATES];
-        long diff[CPUSTATES];
-        int states[CPUSTATES];
+        int64_t time[CPUSTATES];
+        int64_t old[CPUSTATES];
+        int64_t diff[CPUSTATES];
+        int64_t states[CPUSTATES];
         char name[6];
     } cp;
 };

+ 21 - 17
symon/platform/Linux/sm_cpu.c

@@ -1,11 +1,11 @@
-/* $Id: sm_cpu.c,v 1.5 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_cpu.c,v 1.7 2007/07/09 12:54:18 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-2005 Willem Dijkstra
+ * Copyright (c) 2001-2007 Willem Dijkstra
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -69,7 +69,7 @@
 #include "xmalloc.h"
 
 __BEGIN_DECLS
-int percentages(int, int *, long *, long *, long *);
+int percentages(int, int64_t *, int64_t *, int64_t *, int64_t *);
 __END_DECLS
 
 /* Globals for this module all start with cp_ */
@@ -85,13 +85,10 @@ static int cp_maxsize = 0;
  *      useful on BSD mchines for calculating cpu state percentages.
  */
 int
-percentages(int cnt, int *out, register long *new, register long *old, long *diffs)
+percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_t *diffs)
 {
-    register int i;
-    register long change;
-    register long total_change;
-    register long *dp;
-    long half_total;
+    int64_t change, total_change, *dp, half_total;
+    int i;
 
     /* initialization */
     total_change = 0;
@@ -101,7 +98,7 @@ percentages(int cnt, int *out, register long *new, register long *old, long *dif
     for (i = 0; i < cnt; i++) {
         if ((change = *new - *old) < 0) {
             /* this only happens when the counter wraps */
-            change = ((unsigned int) *new - (unsigned int) *old);
+            change = (QUAD_MAX - *old) + *new;
         }
         total_change += (*dp++ = change);
         *old++ = *new++;
@@ -117,7 +114,7 @@ percentages(int cnt, int *out, register long *new, register long *old, long *dif
         *out++ = ((*diffs++ * 1000 + half_total) / total_change);
 
     /* return the total in case the caller wants to use it */
-    return total_change;
+    return (total_change);
 }
 
 void
@@ -188,11 +185,15 @@ get_cpu(char *symon_buf, int maxlen, struct stream *st)
     }
 
     line += strlen(st->parg.cp.name);
-    if (4 > sscanf(line, "%lu %lu %lu %lu\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])) {
+    if (CPUSTATES > sscanf(line, "%llu %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],
+                           &st->parg.cp.time[CP_STEAL])) {
         warning("could not parse cpu statistics for %.200s", &st->parg.cp.name);
         return 0;
     }
@@ -204,6 +205,9 @@ get_cpu(char *symon_buf, int maxlen, struct stream *st)
                   (double) (st->parg.cp.states[CP_USER] / 10.0),
                   (double) (st->parg.cp.states[CP_NICE] / 10.0),
                   (double) (st->parg.cp.states[CP_SYS] / 10.0),
-                  (double) (0),
+                  (double) (st->parg.cp.states[CP_IOWAIT] +
+                            st->parg.cp.states[CP_HARDIRQ] +
+                            st->parg.cp.states[CP_SOFTIRQ] +
+                            st->parg.cp.states[CP_STEAL]) / 10.0,
                   (double) (st->parg.cp.states[CP_IDLE] / 10.0));
 }

+ 10 - 0
symon/platform/NetBSD/conf.sh

@@ -3,3 +3,13 @@ if [ -f /usr/include/net/pfvar.h ]; then
 else
     echo "#undef HAS_PFVAR_H"
 fi
+if grep -q "priq_basic_class_stats" /usr/include/altq/altq_priq.h; then
+    echo "#define HAS_ALTQ_BASIC_STATS	1"
+else
+    echo "#undef HAS_ALTQ_BASIC_STATS"
+fi
+if grep -q HW_IOSTATS /usr/include/sys/sysctl.h; then
+    echo "#define HAS_HW_IOSTATS	1"
+else
+    echo "#undef HAS_HW_IOSTATS"
+fi

+ 2 - 1
symon/platform/NetBSD/platform.h

@@ -1,4 +1,4 @@
-/* $Id: platform.h,v 1.5 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: platform.h,v 1.6 2007/07/05 13:14:05 dijkstra Exp $ */
 
 #ifndef _CONF_NETBSD_H
 #define _CONF_NETBSD_H
@@ -7,6 +7,7 @@
 
 #include <sys/queue.h>
 #include <sys/sched.h>
+#include <sys/types.h>
 
 #include <net/if.h>
 

+ 61 - 2
symon/platform/NetBSD/sm_io.c

@@ -1,6 +1,7 @@
-/* $Id: sm_io.c,v 1.4 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_io.c,v 1.5 2007/07/05 13:33:26 dijkstra Exp $ */
 
 /*
+ * Copyright (c) 2007      Willem Dijkstra
  * Copyright (c) 2004      Matthew Gream
  * All rights reserved.
  *
@@ -37,10 +38,16 @@
  * total nr of transfers : total seeks : total bytes transferred
  */
 
+#include "conf.h"
+
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <sys/disk.h>
 
+#ifdef HAS_HW_IOSTATS
+#include <sys/iostat.h>
+#endif
+
 #include <limits.h>
 #include <string.h>
 #include <stdlib.h>
@@ -50,10 +57,11 @@
 #include "xmalloc.h"
 
 /* Globals for this module start with io_ */
-static struct disk_sysctl *io_dkstats = NULL;
 static int io_dks = 0;
 static int io_maxdks = 0;
 
+#ifndef HAS_HW_IOSTATS
+static struct disk_sysctl *io_dkstats = NULL;
 void
 gets_io()
 {
@@ -90,7 +98,46 @@ gets_io()
               __FILE__, __LINE__);
     }
 }
+#else
+static struct io_sysctl *io_dkstats = NULL;
+void
+gets_io()
+{
+    int mib[3];
+    size_t size;
 
+    /* read size */
+    mib[0] = CTL_HW;
+    mib[1] = HW_IOSTATS;
+    mib[2] = sizeof(struct io_sysctl);
+    size = 0;
+    if (sysctl(mib, 3, NULL, &size, NULL, 0) < 0) {
+        fatal("%s:%d: io can't get hw.iostats"
+              __FILE__, __LINE__);
+    }
+
+    io_dks = size / sizeof (struct io_sysctl);
+
+    /* adjust buffer if necessary */
+    if (io_dks > io_maxdks) {
+        io_maxdks = io_dks;
+
+        if (io_maxdks > SYMON_MAX_DOBJECTS) {
+            fatal("%s:%d: dynamic object limit (%d) exceeded for diskstat structures",
+                  __FILE__, __LINE__, SYMON_MAX_DOBJECTS);
+        }
+
+        io_dkstats = xrealloc(io_dkstats, io_maxdks * sizeof(struct io_sysctl));
+    }
+
+    /* read structure  */
+    size = io_maxdks * sizeof(struct io_sysctl);
+    if (sysctl(mib, 3, io_dkstats, &size, NULL, 0) < 0) {
+        fatal("%s:%d: io can't get hw.iostats"
+              __FILE__, __LINE__);
+    }
+}
+#endif
 void
 init_io(struct stream *st)
 {
@@ -102,6 +149,7 @@ get_io(char *symon_buf, int maxlen, struct stream *st)
 {
     int i;
 
+#ifndef HAS_HW_IOSTATS
     for (i = 0; i < io_maxdks; i++)
         if (strncmp(io_dkstats[i].dk_name, st->arg,
                     sizeof(io_dkstats[i].dk_name)) == 0)
@@ -111,6 +159,17 @@ get_io(char *symon_buf, int maxlen, struct stream *st)
                           io_dkstats[i].dk_seek,
                           io_dkstats[i].dk_rbytes,
                           io_dkstats[i].dk_wbytes);
+#else
+    for (i = 0; i < io_maxdks; i++)
+        if (strncmp(io_dkstats[i].name, st->arg,
+                    sizeof(io_dkstats[i].name)) == 0)
+            return snpack(symon_buf, maxlen, st->arg, MT_IO2,
+                          io_dkstats[i].rxfer,
+                          io_dkstats[i].wxfer,
+                          io_dkstats[i].seek,
+                          io_dkstats[i].rbytes,
+                          io_dkstats[i].wbytes);
+#endif
 
     return 0;
 }

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


+ 0 - 0
symon/platform/NetBSD/sm_pf.c


+ 6 - 1
symon/platform/NetBSD/sm_pfq.c

@@ -1,4 +1,4 @@
-/* $Id: sm_pfq.c,v 1.2 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_pfq.c,v 1.5 2007/07/09 12:32:16 dijkstra Exp $ */
 
 /*
  * Copyright (c) 2005 J. Martin Petersen
@@ -90,8 +90,13 @@ get_pfq(char *b, int l, struct stream *st)
 
 union class_stats {
     class_stats_t cbq;
+#ifdef HAS_ALTQ_BASIC_STATS
     struct priq_basic_class_stats priq;
     struct hfsc_basic_class_stats hfsc;
+#else
+    struct priq_classstats priq;
+    struct hfsc_classstats hfsc;
+#endif
 };
 
 /*

+ 4 - 11
symon/platform/OpenBSD/platform.h

@@ -1,4 +1,4 @@
-/* $Id: platform.h,v 1.6 2007/02/13 19:12:26 dijkstra Exp $ */
+/* $Id: platform.h,v 1.8 2007/05/12 16:46:27 dijkstra Exp $ */
 
 #ifndef _CONF_OPENBSD_H
 #define _CONF_OPENBSD_H
@@ -19,22 +19,15 @@
 #define SS_LEN(x)       ((x)->ss_len)
 
 union stream_parg {
-#ifdef HAS_KERN_CPTIME2
     struct {
-        int64_t time[CPUSTATES];
+        long time1[CPUSTATES];
+        int64_t time2[CPUSTATES];
         int64_t old[CPUSTATES];
         int64_t diff[CPUSTATES];
         int64_t states[CPUSTATES];
         int mib[3];
+        int miblen;
     } cp;
-#else
-    struct {
-        long time[CPUSTATES];
-        long old[CPUSTATES];
-        long diff[CPUSTATES];
-        int states[CPUSTATES];
-    } cp;
-#endif
     struct {
         char rawdev[SYMON_DFNAMESIZE];
     } df;

+ 57 - 59
symon/platform/OpenBSD/sm_cpu.c

@@ -1,11 +1,11 @@
-/* $Id: sm_cpu.c,v 1.23 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_cpu.c,v 1.26 2007/07/09 12:54:18 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-2005 Willem Dijkstra
+ * Copyright (c) 2001-2007 Willem Dijkstra
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -67,11 +67,6 @@
 
 #include "error.h"
 #include "symon.h"
-
-
-/* Globals for this module all start with cp_ */
-static size_t cp_size;
-
 /*
  *  percentages(cnt, out, new, old, diffs) - calculate percentage change
  *      between array "old" and "new", putting the percentages i "out".
@@ -80,84 +75,83 @@ static size_t cp_size;
  *      The routine assumes modulo arithmetic.  This function is especially
  *      useful on BSD mchines for calculating cpu state percentages.
  */
-#ifdef HAS_KERN_CPTIME2
 int
 percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_t *diffs)
 {
-        int64_t change, total_change, *dp, half_total;
-#else
-static int cp_time_mib[] = {CTL_KERN, KERN_CPTIME};
-int
-percentages(int cnt, int *out, register long *new, register long *old, long *diffs)
-{
-        long change, total_change, *dp, half_total;
-#endif
-        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 = (*new - *old);
-                }
-                total_change += (*dp++ = change);
-                *old++ = *new++;
+    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;
+    /* 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);
+    /* 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);
+    /* return the total in case the caller wants to use it */
+    return (total_change);
 }
 
 void
 init_cpu(struct stream *st)
 {
     char buf[SYMON_MAX_OBJSIZE];
-
 #ifdef HAS_KERN_CPTIME2
     const char *errstr;
     int mib[2] = {CTL_HW, HW_NCPU};
     int ncpu;
     long num;
-
     size_t size = sizeof(ncpu);
+#endif
+
+    st->parg.cp.mib[0] = CTL_KERN;
+    st->parg.cp.mib[1] = KERN_CPTIME;
+    st->parg.cp.miblen = 2;
+
+#ifdef HAS_KERN_CPTIME2
     if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) {
         warning("could not determine number of cpus: %.200s", strerror(errno));
         ncpu = 1;
     }
 
-    num = strtonum(st->arg, 0, SYMON_MAXCPUID-1, &errstr);
+    num = strtonum(st->arg, 0, SYMON_MAXCPUID - 1, &errstr);
     if (errstr != NULL) {
         fatal("cpu(%.200s) is invalid: %.200s", st->arg, errstr);
     }
 
-    st->parg.cp.mib[0] = CTL_KERN;
-    st->parg.cp.mib[1] = KERN_CPTIME2;
-    st->parg.cp.mib[2] = num;
-    if (st->parg.cp.mib[2] >= ncpu) {
-        fatal("cpu(%d) is not present", st->parg.cp.mib[2]);
+    if (ncpu > 1) {
+        st->parg.cp.mib[0] = CTL_KERN;
+        st->parg.cp.mib[1] = KERN_CPTIME2;
+        st->parg.cp.mib[2] = num;
+        st->parg.cp.miblen = 3;
+        if (st->parg.cp.mib[2] >= ncpu) {
+            fatal("cpu(%d) is not present", st->parg.cp.mib[2]);
+        }
     }
 #endif
 
-    cp_size = sizeof(st->parg.cp.time);
     /* Call get_cpu once to fill the cp_old structure */
     get_cpu(buf, sizeof(buf), st);
 
     info("started module cpu(%.200s)", st->arg);
 }
+
 void
 gets_cpu()
 {
@@ -167,22 +161,26 @@ gets_cpu()
 int
 get_cpu(char *symon_buf, int maxlen, struct stream *st)
 {
-    int total;
+    int i, total;
+    size_t len;
 
-#ifdef HAS_KERN_CPTIME2
-    if (sysctl(st->parg.cp.mib, 3, &st->parg.cp.time, &cp_size, NULL, 0) < 0) {
-        warning("%s:%d: sysctl kern.cp_time2 for cpu%d failed", __FILE__, __LINE__, st->parg.cp.mib[2]);
+    len = sizeof(st->parg.cp.time2);
+    if (sysctl(st->parg.cp.mib, st->parg.cp.miblen, &st->parg.cp.time2, &len, NULL, 0) < 0) {
+        warning("%s:%d: sysctl kern.cp_time* for cpu%d failed", __FILE__, __LINE__,
+          st->parg.cp.mib[2]);
         return 0;
     }
-#else
-    if (sysctl(cp_time_mib, 2, &st->parg.cp.time, &cp_size, NULL, 0) < 0) {
-        warning("%s:%d: sysctl kern.cp_time failed", __FILE__, __LINE__);
-        return 0;
+
+    /* sysctl will return 32 bit longs for CPTIME and 64 bit longs for CPTIME2 */
+    if (st->parg.cp.mib[1] == KERN_CPTIME) {
+        bcopy(st->parg.cp.time2, st->parg.cp.time1, sizeof(st->parg.cp.time1));
+        for (i = 0; i < CPUSTATES; i++) {
+            st->parg.cp.time2[i] = (int64_t) st->parg.cp.time1[i];
+        }
     }
-#endif
 
     /* convert cp_time counts to percentages */
-    total = percentages(CPUSTATES, st->parg.cp.states, st->parg.cp.time, st->parg.cp.old, st->parg.cp.diff);
+    total = percentages(CPUSTATES, st->parg.cp.states, st->parg.cp.time2, st->parg.cp.old, st->parg.cp.diff);
 
     return snpack(symon_buf, maxlen, st->arg, MT_CPU,
                   (double) (st->parg.cp.states[CP_USER] / 10.0),

+ 0 - 0
symon/platform/OpenBSD/sm_debug.c


+ 2 - 4
symon/platform/OpenBSD/sm_if.c

@@ -1,7 +1,7 @@
-/* $Id: sm_if.c,v 1.16 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: sm_if.c,v 1.17 2007/07/05 08:34:52 dijkstra Exp $ */
 
 /*
- * Copyright (c) 2001-2005 Willem Dijkstra
+ * Copyright (c) 2001-2007 Willem Dijkstra
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,8 +47,6 @@
 #include <net/if_types.h>
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netipx/ipx.h>
-#include <netipx/ipx_if.h>
 
 #include <errno.h>
 #include <limits.h>

+ 0 - 0
symon/platform/OpenBSD/sm_io.c


+ 0 - 0
symon/platform/OpenBSD/sm_mbuf.c


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


+ 0 - 0
symon/platform/OpenBSD/sm_pf.c


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


+ 0 - 0
symon/platform/OpenBSD/sm_sensor.c


+ 0 - 0
symon/symon/Makefile


+ 5 - 2
symon/symon/readconf.c

@@ -1,4 +1,4 @@
-/* $Id: readconf.c,v 1.25 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: readconf.c,v 1.27 2007/07/09 11:43:13 dijkstra Exp $ */
 
 /*
  * Copyright (c) 2001-2005 Willem Dijkstra
@@ -30,6 +30,8 @@
  *
  */
 
+#include <sys/types.h>
+
 #include <string.h>
 
 #include "conf.h"
@@ -201,12 +203,13 @@ read_monitor(struct muxlist * mul, struct lex * l)
 
     if (l->op == LXT_FROM) {
         lex_nexttoken(l);
+        /* check to see host is resolvable, result is discarded */
         if (!getip(l->token, AF_INET) && !getip(l->token, AF_INET6)) {
             warning("%.200s:%d: could not resolve '%.200s'",
                 l->filename, l->cline, l->token);
             return 0;
         }
-        mux->localaddr = xstrdup((const char *) &res_host);
+        mux->localaddr = xstrdup(l->token);
         lex_nexttoken(l);
     }
 

+ 0 - 0
symon/symon/readconf.h


+ 0 - 0
symon/symon/symon.8


+ 4 - 4
symon/symon/symon.c

@@ -1,7 +1,7 @@
-/* $Id: symon.c,v 1.46 2007/02/11 20:07:32 dijkstra Exp $ */
+/* $Id: symon.c,v 1.47 2007/04/20 18:53:27 dijkstra Exp $ */
 
 /*
- * Copyright (c) 2001-2005 Willem Dijkstra
+ * Copyright (c) 2001-2007 Willem Dijkstra
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -223,8 +223,6 @@ main(int argc, char *argv[])
         warning("could not open \"%.200s\", %.200s", SYMON_PID_FILE,
                 strerror(errno));
 
-    drop_privileges(flag_unsecure);
-
     if (flag_debug != 1) {
         if (daemon(0, 0) != 0)
             fatal("daemonize failed: %.200s", strerror(errno));
@@ -237,6 +235,8 @@ main(int argc, char *argv[])
         }
     }
 
+    drop_privileges(flag_unsecure);
+
     info("symon version %s", SYMON_VERSION);
 
     if (flag_debug == 1)

+ 0 - 0
symon/symon/symon.h


+ 0 - 0
symon/symon/symonnet.c


+ 0 - 0
symon/symon/symonnet.h


+ 0 - 0
symon/symux/Makefile


+ 16 - 4
symon/symux/c_smrrds.sh

@@ -1,5 +1,5 @@
 #!/bin/sh
-# $Id: c_smrrds.sh,v 1.35 2006/12/19 22:30:47 dijkstra Exp $
+# $Id: c_smrrds.sh,v 1.36 2007/07/05 12:16:07 dijkstra Exp $
 
 #
 # Copyright (c) 2001-2006 Willem Dijkstra
@@ -53,14 +53,25 @@ RRA_SETUP=${RRA_SETUP:-"
 create_rrd() {
     file=$1
     shift
-    rrdtool create $file $RRD_ARGS $* $RRA_SETUP
+    $RRDTOOL create $file $RRD_ARGS $* $RRA_SETUP
     if [ "$?" = "0" -a -f $file ]; then
 	echo "$file created"
     else
 	echo "could not create $file"
     fi
 }
-
+find_exec() {
+    alternatives=$1`echo :$PATH:$2: | sed "s@:@/$3:@g"`
+    echo $alternatives  | tr ':' '\n' | (
+        while read f; do
+            if [ -n "$f" -a -x "$f" ]; then
+                echo $f
+                return
+            fi
+        done)
+}
+# find rrdtool
+RRDTOOL=`find_exec "$RRDTOOL" /usr/local/bin rrdtool`
 # get arguments
 select_interval=""
 for i
@@ -126,7 +137,8 @@ j=`basename $i`
 case $j in
 
 all)
-    sh $this interval $INTERVAL child $config `symux -l`
+    SYMUX=`find_exec "$SYMUX" /usr/libexec:/usr/local/libexec symux`
+    sh $this interval $INTERVAL child $config `$SYMUX -l`
     ;;
 
 cpu[0-9].rrd)

+ 0 - 0
symon/symux/readconf.c


+ 0 - 0
symon/symux/readconf.h


+ 0 - 0
symon/symux/share.c


+ 0 - 0
symon/symux/share.h


+ 0 - 0
symon/symux/symux.8


+ 6 - 7
symon/symux/symux.c

@@ -1,4 +1,4 @@
-/* $Id: symux.c,v 1.38 2007/01/20 12:52:50 dijkstra Exp $ */
+/* $Id: symux.c,v 1.39 2007/07/09 11:18:01 dijkstra Exp $ */
 
 /*
  * Copyright (c) 2001-2006 Willem Dijkstra
@@ -141,19 +141,18 @@ main(int argc, char *argv[])
                 if ((cfgpath = getcwd(cfgpath, MAXPATHLEN)) == NULL)
                     fatal("could not get working directory");
 
-                maxstringlen = strlen(cfgpath) + strlen(optarg) + 1;
+                maxstringlen = strlen(cfgpath) + 1 + strlen(optarg) + 1;
                 cfgfile = xmalloc(maxstringlen);
-                strncpy(cfgfile, cfgpath, maxstringlen);
+                strncpy(cfgfile, cfgpath, maxstringlen - 1);
                 stringptr = cfgfile + strlen(cfgpath);
                 stringptr[0] = '/';
                 stringptr++;
-                strncpy(stringptr, optarg, maxstringlen - (cfgfile - stringptr));
-                cfgfile[maxstringlen] = '\0';
+                strncpy(stringptr, optarg, maxstringlen - 1 - (stringptr - cfgfile));
+                cfgfile[maxstringlen - 1] = '\0';
 
-                free(cfgpath);
+                xfree(cfgpath);
             } else
                 cfgfile = xstrdup(optarg);
-
             break;
         case 'l':
             flag_list = 1;

+ 0 - 0
symon/symux/symux.h


+ 0 - 0
symon/symux/symuxnet.c


+ 0 - 0
symon/symux/symuxnet.h