Sfoglia il codice sorgente

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

Wictor Lund 3 anni fa
parent
commit
b693c3d3ea

+ 21 - 2
symon/CHANGELOG

@@ -1,4 +1,23 @@
-13/06/2004 - 2.67
+14/01/2005 - 2.68
+
+   - NetBSD/sm_debug.c now has proper sysctl mib values
+
+   - if and pf probes for FreeBSD 5.3 (Fredrik Söderblom)
+
+   - mbuf interface change for FreeBSD 5.3 (Stefan T. Peters)
+
+   - Spelling errors in INSTALL/symon.8/symux.8 (Jan Sepp)
+
+   - platform/*BSD/sm_proc transferred cpucpt as uint16 instead of double
+     (Jamie Herre)
+
+   - states_entries is a GAUGE, not a ABSOLUTE (Lars Hansson, Marco Pfatschbacher)
+
+   - NetBSD/plaform.h -> platform.h (Joel Andersson)
+
+   - tsort and lorder are not needed on Linux. (Mark Enzinas)
+
+09/08/2004 - 2.67
 
 
    - Matthew Gream contributed the port and probes to NetBSD and FreeBSD.
    - Matthew Gream contributed the port and probes to NetBSD and FreeBSD.
      Probes for FreeBSD: cpu, debug, mbuf, mem and proc.  Probes for NetBSD:
      Probes for FreeBSD: cpu, debug, mbuf, mem and proc.  Probes for NetBSD:
@@ -357,4 +376,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.35 2004/08/09 06:26:17 dijkstra Exp $
+$Id: CHANGELOG,v 1.39 2005/02/04 09:49:26 dijkstra Exp $

+ 9 - 6
symon/INSTALL

@@ -1,12 +1,12 @@
 Installation notes
 Installation notes
 ==================
 ==================
 
 
-Priviledges
-===========
+Privileges
+==========
 symux needs read and write access to its rrdfiles.
 symux needs read and write access to its rrdfiles.
 
 
 symon needs to interface with your kernel. Depending on your host system this
 symon needs to interface with your kernel. Depending on your host system this
-leads to different priviledge requirements:
+leads to different privilege requirements:
 
 
 OpenBSD:  - sysctl: cpu, debug, if, io, mbuf, mem, proc, sensor
 OpenBSD:  - sysctl: cpu, debug, if, io, mbuf, mem, proc, sensor
           - rw on /dev/pf for pf
           - rw on /dev/pf for pf
@@ -21,10 +21,13 @@ Linux:    - r on /proc/net/dev: if
 
 
 Real quick on OpenBSD
 Real quick on OpenBSD
 =====================
 =====================
-make && make install && vi /etc/symux.conf /etc/symon.conf &&
+(cd /usr/ports/net/rrdtool && make install) &&
+	make &&
+	make install &&
+	vi /etc/symux.conf /etc/symon.conf &&
 	~symon/symux/c_smrrds.sh all &&
 	~symon/symux/c_smrrds.sh all &&
 	/usr/local/libexec/symux &&
 	/usr/local/libexec/symux &&
-	useradd _symon
+	useradd -d /var/empty -L daemon -c 'symon Account' -s /sbin/nologin _symon
 	/usr/local/libexec/symon
 	/usr/local/libexec/symon
 
 
 or grab the port and do
 or grab the port and do
@@ -99,5 +102,5 @@ rudimentary support for FreeBSD, NetBSD and Linux.
 
 
 Willem Dijkstra - wpd@xs4all.nl
 Willem Dijkstra - wpd@xs4all.nl
 
 
-$Id: INSTALL,v 1.14 2004/08/08 19:56:03 dijkstra Exp $
+$Id: INSTALL,v 1.16 2005/01/14 16:15:21 dijkstra Exp $
 
 

+ 3 - 2
symon/Makefile.inc

@@ -1,6 +1,6 @@
-# $Id: Makefile.inc,v 1.26 2004/08/09 06:26:17 dijkstra Exp $
+# $Id: Makefile.inc,v 1.28 2005/02/04 09:49:26 dijkstra Exp $
 
 
-V=2.67
+V=2.68
 OS!=uname -s
 OS!=uname -s
 
 
 AR=	ar
 AR=	ar
@@ -12,6 +12,7 @@ CFLAGS+=-Wall
 .endif
 .endif
 INSTALL=install
 INSTALL=install
 LORDER=	lorder
 LORDER=	lorder
+TSORT=  tsort
 NROFF=	nroff
 NROFF=	nroff
 RANLIB= ranlib
 RANLIB= ranlib
 STRIP=  strip
 STRIP=  strip

+ 3 - 2
symon/lib/Makefile

@@ -1,5 +1,6 @@
-# $Id: Makefile,v 1.11 2004/08/07 14:48:06 dijkstra Exp $
+# $Id: Makefile,v 1.12 2004/09/25 10:21:56 dijkstra Exp $
 .include "../Makefile.inc"
 .include "../Makefile.inc"
+.include "../platform/${OS}/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}
@@ -12,7 +13,7 @@ ${OBJS}: conf.h ../Makefile.inc
 libsymon.a: ${OBJS}
 libsymon.a: ${OBJS}
 	@echo building standard symon library
 	@echo building standard symon library
 	@rm -f libsymon.a
 	@rm -f libsymon.a
-	@${AR} cq libsymon.a `${LORDER} ${OBJS} | tsort`
+	@${AR} cq libsymon.a `${LORDER} ${OBJS} | ${TSORT}`
 	${RANLIB} libsymon.a
 	${RANLIB} libsymon.a
 
 
 conf.h:  Makefile ../Makefile.inc
 conf.h:  Makefile ../Makefile.inc

+ 1 - 0
symon/platform/FreeBSD/Makefile.inc

@@ -0,0 +1 @@
+# $Id: Makefile.inc,v 1.1 2004/09/25 10:21:56 dijkstra Exp $

+ 13 - 0
symon/platform/FreeBSD/conf.sh

@@ -0,0 +1,13 @@
+case `grep -c "m_drops" /usr/include/sys/mbuf.h` in
+1)	echo "#define HAS_MBUF_MDROPS	1" ;;
+0)	echo "#undef HAS_MBUF_MDROPS" ;;
+esac;
+case `grep -c "sf_allocfail" /usr/include/sys/mbuf.h` in
+1)	echo "#define HAS_MBUF_SFALLOCFAIL	1" ;;
+0)	echo "#undef HAS_MBUF_SFALLOCFAIL" ;;
+esac;
+if [ -f /usr/include/net/pfvar.h ]; then
+    echo "#define HAS_PFVAR_H	1"
+else
+    echo "#undef HAS_PFVAR_H"
+fi

+ 140 - 0
symon/platform/FreeBSD/sm_if.c

@@ -0,0 +1,140 @@
+/* $Id: sm_if.c,v 1.1 2005/01/14 16:12:55 dijkstra Exp $ */
+
+/*
+ * Copyright (c) 2005 Fredrik Soderblom
+ * 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.
+ *
+ */
+
+/*
+ * Get current interface statistics from kernel and return them in symon_buf as
+ *
+ * ipackets : opackets : ibytes : obytes : imcasts : omcasts : ierrors :
+ * oerrors : colls : drops
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+
+#include <net/if.h>
+#include <net/if_mib.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <string.h>
+
+#include "error.h"
+#include "symon.h"
+
+/* Globals for this module start with if_ */
+static int if_s = -1;
+/* Prepare if module for first use */
+void
+init_if(char *s)
+{
+    if (if_s == -1)
+	if ((if_s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+	    fatal("%s:%d: socket failed, %.200",
+		  __FILE__, __LINE__, strerror(errno));
+
+    info("started module if(%.200s)", s);
+}
+
+int
+get_ifcount(void)
+{
+    int name[5], count;
+    size_t len;
+  
+    name[0] = CTL_NET;
+    name[1] = PF_LINK;
+    name[2] = NETLINK_GENERIC;
+    name[3] = IFMIB_SYSTEM;
+    name[4] = IFMIB_IFCOUNT;
+
+    len = sizeof(int);
+
+    if (sysctl(name, 5, &count, &len, NULL, 0) != -1)
+        return(count);
+    else
+        return(-1);
+}
+
+int
+get_ifmib_general(int row, struct ifmibdata *ifmd)
+{
+    int name[6];
+    size_t len;
+
+    name[0] = CTL_NET;
+    name[1] = PF_LINK;
+    name[2] = NETLINK_GENERIC;
+    name[3] = IFMIB_IFDATA;
+    name[4] = row;
+    name[5] = IFDATA_GENERAL;
+
+    len = sizeof(*ifmd);
+
+    return sysctl(name, 6, ifmd, &len, (void *)0, 0);
+}
+
+/* Get interface statistics */
+void
+gets_if()
+{
+}
+int
+get_if(char *symon_buf, int maxlen, char *interface)
+{
+    int i;
+    struct ifmibdata ifmd;
+    struct if_data ifdata;
+    int ifcount = get_ifcount();
+
+    for (i = 1; i <= ifcount; i++) {
+        get_ifmib_general(i, &ifmd);
+        if (!strcmp(ifmd.ifmd_name, interface))
+            break;
+    }
+
+    ifdata = ifmd.ifmd_data;
+    return snpack(symon_buf, maxlen, interface, MT_IF,
+		  ifdata.ifi_ipackets,
+		  ifdata.ifi_opackets,
+		  ifdata.ifi_ibytes,
+		  ifdata.ifi_obytes,
+		  ifdata.ifi_imcasts,
+		  ifdata.ifi_omcasts,
+		  ifdata.ifi_ierrors,
+		  ifdata.ifi_oerrors,
+		  ifdata.ifi_collisions,
+		  ifdata.ifi_iqdrops);
+}

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

@@ -1,4 +1,4 @@
-/* $Id: sm_mbuf.c,v 1.1 2004/08/07 12:21:36 dijkstra Exp $ */
+/* $Id: sm_mbuf.c,v 1.3 2005/01/15 17:31:11 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2004 Matthew Gream
  * Copyright (c) 2004 Matthew Gream
@@ -155,8 +155,19 @@ get_mbuf(char *symon_buf, int maxlen, char *arg)
 #endif
 #endif
     stats[10] = totmem;
     stats[10] = totmem;
     stats[11] = totpct;
     stats[11] = totpct;
+
+#ifdef HAS_MBUF_SFALLOCFAIL
+    stats[12] = mbstat.sf_allocfail;
+    stats[13] = mbstat.sf_allocwait;
+#else
+#ifdef HAS_MBUF_MDROPS
     stats[12] = mbstat.m_drops;
     stats[12] = mbstat.m_drops;
     stats[13] = mbstat.m_wait;
     stats[13] = mbstat.m_wait;
+#else
+    stats[12] = 0;
+    stats[13] = 0;
+#endif
+#endif
     stats[14] = mbstat.m_drain;
     stats[14] = mbstat.m_drain;
 
 
     return snpack(symon_buf, maxlen, arg, MT_MBUF,
     return snpack(symon_buf, maxlen, arg, MT_MBUF,

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

@@ -1,4 +1,4 @@
-/* $Id: sm_mem.c,v 1.1 2004/08/07 12:21:36 dijkstra Exp $ */
+/* $Id: sm_mem.c,v 1.2 2005/01/15 17:31:11 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2004      Matthew Gream
  * Copyright (c) 2004      Matthew Gream
@@ -116,7 +116,7 @@ get_mem(char *symon_buf, int maxlen, char *s)
     me_stats[2] = pagetob(me_vmtotal.t_free);
     me_stats[2] = pagetob(me_vmtotal.t_free);
 
 
     vmnswp_siz = sizeof (int);
     vmnswp_siz = sizeof (int);
-    if (sysctl(me_vmnswp_mib_nam, me_vmnswp_mib_len, &vmnswp_dat, &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 nswapdev failed", __FILE__, __LINE__);
 	return 0;
 	return 0;
     }
     }
@@ -127,7 +127,7 @@ get_mem(char *symon_buf, int maxlen, char *s)
 	struct xswdev vmiswp_dat;
 	struct xswdev vmiswp_dat;
 	int vmiswp_siz;
 	int vmiswp_siz;
 	me_vmiswp_mib_nam[me_vmiswp_mib_len] = i;
 	me_vmiswp_mib_nam[me_vmiswp_mib_len] = i;
-	if (sysctl(me_vmiswp_mib_nam, me_vmiswp_mib_len + 1, &vmiswp_dat, &vmiswp_siz, NULL, 0) < 0)
+	if (sysctl(me_vmiswp_mib_nam, me_vmiswp_mib_len + 1, &vmiswp_dat, (void *)&vmiswp_siz, NULL, 0) < 0)
 		continue;
 		continue;
 	me_stats[3] += (vmiswp_dat.xsw_used * DEV_BSIZE);
 	me_stats[3] += (vmiswp_dat.xsw_used * DEV_BSIZE);
 	me_stats[4] += (vmiswp_dat.xsw_nblks * DEV_BSIZE);
 	me_stats[4] += (vmiswp_dat.xsw_nblks * DEV_BSIZE);

+ 148 - 0
symon/platform/FreeBSD/sm_pf.c

@@ -0,0 +1,148 @@
+/* $Id: sm_pf.c,v 1.2 2005/01/15 17:31:11 dijkstra Exp $ */
+
+/*
+ * Copyright (c) 2002 Daniel Hartmeier
+ * 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.
+ *
+ */
+
+/*
+ * Get current pf statistics and return them in symon_buf as
+ *
+ *   bytes_v4_in : bytes_v4_out : bytes_v6_in : bytes_v6_out :
+ *   packets_v4_in_pass : * packets_v4_in_drop : packets_v4_out_pass :
+ *   packets_v4_out_drop : * packets_v6_in_pass : packets_v6_in_drop :
+ *   packets_v6_out_pass : * packets_v6_out_drop : states_entries :
+ *   states_searches : states_inserts : * states_removals : counters_match :
+ *   counters_badoffset : counters_fragment : * counters_short :
+ *   counters_normalize : counters_memory
+ *
+ */
+
+#include "conf.h"
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <net/if.h>
+#ifdef HAS_PFVAR_H
+#include <net/pfvar.h>
+#endif
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "error.h"
+#include "symon.h"
+
+#ifndef HAS_PFVAR_H
+void
+privinit_pf()
+{
+}
+void
+init_pf(char *s)
+{
+    fatal("pf support not available");
+}
+int
+get_pf(char *symon_buf, int maxlen, char *s)
+{
+    fatal("pf support not available");
+    return 0;
+}
+
+#else
+
+/* Globals for this module start with pf_ */
+int pf_dev = -1;
+/* Priviledged init, called before priviledges are dropped */
+void
+privinit_pf()
+{
+    if ((pf_dev = open("/dev/pf", O_RDONLY)) == -1)
+	warning("could not open \"/dev/pf\", %.200s", strerror(errno));
+}
+/* Prepare if module for first use */
+void
+init_pf(char *s)
+{
+    if (pf_dev == -1)
+	privinit_pf();
+
+    info("started module pf(%.200s)", s);
+}
+/* Get pf statistics */
+int
+get_pf(char *symon_buf, int maxlen, char *arg)
+{
+    struct pf_status s;
+    u_int64_t n;
+
+    if (pf_dev == -1) {
+	warning("pf(%.200s) failed (dev == -1)", arg);
+	return 0;
+    }
+
+    if (ioctl(pf_dev, DIOCGETSTATUS, &s)) {
+	warning("pf(%.200s) failed (ioctl error)", arg);
+	return 0;
+    }
+
+    if (!s.running)
+	return 0;
+
+    n = s.states;
+    return snpack(symon_buf, maxlen, arg, MT_PF,
+		  s.bcounters[0][0],
+		  s.bcounters[0][1],
+		  s.bcounters[1][0],
+		  s.bcounters[1][1],
+		  s.pcounters[0][0][PF_PASS],
+		  s.pcounters[0][0][PF_DROP],
+		  s.pcounters[0][1][PF_PASS],
+		  s.pcounters[0][1][PF_DROP],
+		  s.pcounters[1][0][PF_PASS],
+		  s.pcounters[1][0][PF_DROP],
+		  s.pcounters[1][1][PF_PASS],
+		  s.pcounters[1][1][PF_DROP],
+		  n,
+		  s.fcounters[0],
+		  s.fcounters[1],
+		  s.fcounters[2],
+		  s.counters[0],
+		  s.counters[1],
+		  s.counters[2],
+		  s.counters[3],
+		  s.counters[4],
+		  s.counters[5]
+	);
+}
+
+#endif

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

@@ -1,4 +1,4 @@
-/* $Id: sm_proc.c,v 1.1 2004/08/07 12:21:36 dijkstra Exp $ */
+/* $Id: sm_proc.c,v 1.2 2005/01/14 16:13:38 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2004      Matthew Gream
  * Copyright (c) 2004      Matthew Gream
@@ -149,7 +149,7 @@ get_proc(char *symon_buf, int maxlen, char *process)
     u_quad_t  cpu_sticks =0;
     u_quad_t  cpu_sticks =0;
     u_int32_t cpu_secs = 0;
     u_int32_t cpu_secs = 0;
     double    cpu_pct = 0;
     double    cpu_pct = 0;
-    u_int16_t cpu_pcti = 0;
+    double    cpu_pcti = 0;
     u_int32_t mem_procsize = 0;
     u_int32_t mem_procsize = 0;
     u_int32_t mem_rss = 0;
     u_int32_t mem_rss = 0;
     int n = 0;
     int n = 0;
@@ -165,7 +165,7 @@ get_proc(char *symon_buf, int maxlen, char *process)
 #endif
 #endif
 	     /* cpu time - percentage since last measurement */
 	     /* cpu time - percentage since last measurement */
 	     cpu_pct = pctdouble(pp->ki_pctcpu) * 100.0;
 	     cpu_pct = pctdouble(pp->ki_pctcpu) * 100.0;
-	     cpu_pcti += cpu_pct * 10;
+	     cpu_pcti += cpu_pct;
 	     /* memory size - shared pages are counted multiple times */
 	     /* memory size - shared pages are counted multiple times */
 	     mem_procsize += pagetob(pp->ki_tsize + /* text pages */
 	     mem_procsize += pagetob(pp->ki_tsize + /* text pages */
 				     pp->ki_dsize + /* data */
 				     pp->ki_dsize + /* data */

+ 4 - 0
symon/platform/Linux/Makefile.inc

@@ -0,0 +1,4 @@
+# $Id: Makefile.inc,v 1.1 2004/09/25 10:21:56 dijkstra Exp $
+
+LORDER=echo
+TSORT= echo

+ 1 - 0
symon/platform/NetBSD/Makefile.inc

@@ -0,0 +1 @@
+# $Id: Makefile.inc,v 1.1 2004/09/25 10:21:56 dijkstra Exp $

+ 1 - 1
symon/platform/NetBSD/plaform.h → symon/platform/NetBSD/platform.h

@@ -1,4 +1,4 @@
-/* $Id: plaform.h,v 1.1 2004/08/07 12:21:36 dijkstra Exp $ */
+/* $Id: platform.h,v 1.1 2004/11/21 10:26:55 dijkstra Exp $ */
 
 
 #ifndef _CONF_NETBSD_H
 #ifndef _CONF_NETBSD_H
 #define _CONF_NETBSD_H
 #define _CONF_NETBSD_H

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

@@ -1,4 +1,4 @@
-/* $Id: sm_debug.c,v 1.1 2004/08/07 12:21:36 dijkstra Exp $ */
+/* $Id: sm_debug.c,v 1.2 2005/02/04 09:49:26 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2004      Matthew Gream
  * Copyright (c) 2004      Matthew Gream
@@ -46,10 +46,10 @@
 #include "error.h"
 #include "error.h"
 #include "symon.h"
 #include "symon.h"
 
 
-#define SYMON_MAXDEBUGID      20/* = CTL_DEBUG_MAXID; depends lib/data.h */
+#define SYMON_MAXDEBUGID      20 /* = CTL_DEBUG_MAXID; depends lib/data.h */
 
 
 /* Globals for this module start with db_ */
 /* Globals for this module start with db_ */
-static int db_mib[] = { SM_DEBUG_MIB_VARS };
+static int db_mib[] = { CTL_DEBUG, 0, CTL_DEBUG_VALUE };
 static int db_v[SYMON_MAXDEBUGID];
 static int db_v[SYMON_MAXDEBUGID];
 /* Prepare if module for first use */
 /* Prepare if module for first use */
 void
 void

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

@@ -1,4 +1,4 @@
-/* $Id: sm_proc.c,v 1.1 2004/08/07 12:21:36 dijkstra Exp $ */
+/* $Id: sm_proc.c,v 1.2 2005/01/14 16:13:38 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2004      Matthew Gream
  * Copyright (c) 2004      Matthew Gream
@@ -150,7 +150,7 @@ get_proc(char *symon_buf, int maxlen, char *process)
     u_quad_t  cpu_sticks =0;
     u_quad_t  cpu_sticks =0;
     u_int32_t cpu_secs = 0;
     u_int32_t cpu_secs = 0;
     double    cpu_pct = 0;
     double    cpu_pct = 0;
-    u_int16_t cpu_pcti = 0;
+    double    cpu_pcti = 0;
     u_int32_t mem_procsize = 0;
     u_int32_t mem_procsize = 0;
     u_int32_t mem_rss = 0;
     u_int32_t mem_rss = 0;
     int n = 0;
     int n = 0;
@@ -163,7 +163,7 @@ get_proc(char *symon_buf, int maxlen, char *process)
 	     cpu_iticks += pp->kp_proc.p_iticks;  /* int  */
 	     cpu_iticks += pp->kp_proc.p_iticks;  /* int  */
 	     /* cpu time - percentage since last measurement */
 	     /* cpu time - percentage since last measurement */
 	     cpu_pct = pctdouble(pp->kp_proc.p_pctcpu) * 100.0;
 	     cpu_pct = pctdouble(pp->kp_proc.p_pctcpu) * 100.0;
-	     cpu_pcti += cpu_pct * 10;
+	     cpu_pcti += cpu_pct;
 	     /* memory size - shared pages are counted multiple times */
 	     /* memory size - shared pages are counted multiple times */
 	     mem_procsize += pagetob(pp->kp_eproc.e_vm.vm_tsize + /* text pages */
 	     mem_procsize += pagetob(pp->kp_eproc.e_vm.vm_tsize + /* text pages */
 				     pp->kp_eproc.e_vm.vm_dsize + /* data */
 				     pp->kp_eproc.e_vm.vm_dsize + /* data */

+ 1 - 0
symon/platform/OpenBSD/Makefile.inc

@@ -0,0 +1 @@
+# $Id: Makefile.inc,v 1.1 2004/09/25 10:21:56 dijkstra Exp $

+ 6 - 1
symon/platform/OpenBSD/conf.sh

@@ -9,4 +9,9 @@ esac;
 case `grep -csq "ds_rxfer" /usr/include/sys/disk.h` in
 case `grep -csq "ds_rxfer" /usr/include/sys/disk.h` in
 1)	echo "#define HAS_IO2	1" ;;
 1)	echo "#define HAS_IO2	1" ;;
 0)	echo "#undef HAS_IO2" ;;
 0)	echo "#undef HAS_IO2" ;;
-esac
+esac;
+if [ -f /usr/include/net/pfvar.h ]; then
+    echo "#define HAS_PFVAR_H	1"
+else
+    echo "#undef HAS_PFVAR_H"
+fi

+ 5 - 4
symon/platform/OpenBSD/sm_pf.c

@@ -1,4 +1,4 @@
-/* $Id: sm_pf.c,v 1.8 2004/08/07 12:21:36 dijkstra Exp $ */
+/* $Id: sm_pf.c,v 1.9 2005/01/15 17:31:11 dijkstra Exp $ */
 
 
 /*
 /*
  * Copyright (c) 2002 Daniel Hartmeier
  * Copyright (c) 2002 Daniel Hartmeier
@@ -43,13 +43,15 @@
  *
  *
  */
  */
 
 
+#include "conf.h"
+
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/socket.h>
 
 
 #include <netinet/in.h>
 #include <netinet/in.h>
 #include <net/if.h>
 #include <net/if.h>
-#ifndef SM_PF_UNSUPPORTED
+#ifdef HAS_PFVAR_H
 #include <net/pfvar.h>
 #include <net/pfvar.h>
 #endif
 #endif
 #include <errno.h>
 #include <errno.h>
@@ -59,8 +61,7 @@
 #include "error.h"
 #include "error.h"
 #include "symon.h"
 #include "symon.h"
 
 
-#ifdef SM_PF_UNSUPPORTED
-
+#ifndef HAS_PFVAR_H
 void
 void
 privinit_pf()
 privinit_pf()
 {
 {

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

@@ -1,7 +1,7 @@
-/* $Id: sm_proc.c,v 1.4 2004/02/26 22:48:08 dijkstra Exp $ */
+/* $Id: sm_proc.c,v 1.5 2005/01/14 16:13:38 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2004 Willem Dijkstra
+ * Copyright (c) 2001-2005 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
@@ -148,7 +148,7 @@ get_proc(char *symon_buf, int maxlen, char *process)
     u_quad_t  cpu_sticks =0;
     u_quad_t  cpu_sticks =0;
     u_int32_t cpu_secs = 0;
     u_int32_t cpu_secs = 0;
     double    cpu_pct = 0;
     double    cpu_pct = 0;
-    u_int16_t cpu_pcti = 0;
+    double    cpu_pcti = 0;
     u_int32_t mem_procsize = 0;
     u_int32_t mem_procsize = 0;
     u_int32_t mem_rss = 0;
     u_int32_t mem_rss = 0;
     int n = 0;
     int n = 0;
@@ -161,7 +161,7 @@ get_proc(char *symon_buf, int maxlen, char *process)
 	     cpu_iticks += pp->kp_proc.p_iticks;  /* int  */
 	     cpu_iticks += pp->kp_proc.p_iticks;  /* int  */
 	     /* cpu time - percentage since last measurement */
 	     /* cpu time - percentage since last measurement */
 	     cpu_pct = pctdouble(pp->kp_proc.p_pctcpu) * 100.0;
 	     cpu_pct = pctdouble(pp->kp_proc.p_pctcpu) * 100.0;
-	     cpu_pcti += cpu_pct * 10;
+	     cpu_pcti += cpu_pct;
 	     /* memory size - shared pages are counted multiple times */
 	     /* memory size - shared pages are counted multiple times */
 	     mem_procsize += pagetob(pp->kp_eproc.e_vm.vm_tsize + /* text pages */
 	     mem_procsize += pagetob(pp->kp_eproc.e_vm.vm_tsize + /* text pages */
 				     pp->kp_eproc.e_vm.vm_dsize + /* data */
 				     pp->kp_eproc.e_vm.vm_dsize + /* data */

+ 1 - 1
symon/symon/symon.8

@@ -59,7 +59,7 @@ instances in a LAN.
 .Lp
 .Lp
 By default,
 By default,
 .Nm
 .Nm
-will drop priviledges and chroot(2) to home of
+will drop privileges and chroot(2) to home of
 .Ar "_symon".
 .Ar "_symon".
 This behaviour is not strictly needed for the cpu, mem, mbuf, disk debug and
 This behaviour is not strictly needed for the cpu, mem, mbuf, disk debug and
 interface probes as these will work even when
 interface probes as these will work even when

+ 3 - 3
symon/symon/symon.h

@@ -1,7 +1,7 @@
-/* $Id: symon.h,v 1.31 2004/08/08 17:21:18 dijkstra Exp $ */
+/* $Id: symon.h,v 1.32 2005/01/15 17:31:11 dijkstra Exp $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2004 Willem Dijkstra
+ * Copyright (c) 2001-2005 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
@@ -39,7 +39,7 @@
 #define SYMON_PID_FILE "/var/run/symon.pid"
 #define SYMON_PID_FILE "/var/run/symon.pid"
 #define SYMON_DEFAULT_INTERVAL 5	/* measurement interval */
 #define SYMON_DEFAULT_INTERVAL 5	/* measurement interval */
 #define SYMON_WARN_SENDERR 50	        /* warn every x errors */
 #define SYMON_WARN_SENDERR 50	        /* warn every x errors */
-#define SYMON_MAX_DOBJECTS 2000	        /* max dynamic allocation; local limit per
+#define SYMON_MAX_DOBJECTS 10000	/* max dynamic allocation; local limit per
 					 * measurement module */
 					 * measurement module */
 #define SYMON_MAX_OBJSIZE (_POSIX2_LINE_MAX)
 #define SYMON_MAX_OBJSIZE (_POSIX2_LINE_MAX)
 #define SYMON_SENSORMASK 0xFF           /* sensors 0-255 are allowed */
 #define SYMON_SENSORMASK 0xFF           /* sensors 0-255 are allowed */

+ 3 - 3
symon/symux/c_smrrds.sh

@@ -1,5 +1,5 @@
 #!/bin/sh
 #!/bin/sh
-# $Id: c_smrrds.sh,v 1.26 2004/02/26 22:48:08 dijkstra Exp $
+# $Id: c_smrrds.sh,v 1.28 2005/02/04 09:49:26 dijkstra Exp $
 
 
 #
 #
 # Copyright (c) 2001-2004 Willem Dijkstra
 # Copyright (c) 2001-2004 Willem Dijkstra
@@ -122,7 +122,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: $0 [oneday] [interval <seconds>] all | cpu0 | mem |
+Usage: `basename $0` [oneday] [interval <seconds>] all | cpu0 | mem |
 		   pf | mbuf | debug | proc_<process> |
 		   pf | mbuf | debug | proc_<process> |
 		   <if> | <io> | sensor[0-25]
 		   <if> | <io> | sensor[0-25]
 
 
@@ -262,7 +262,7 @@ pf.rrd)
 	DS:packets_v4_out_pass:DERIVE:$INTERVAL:0:U DS:packets_v4_out_drop:DERIVE:$INTERVAL:0:U \
 	DS:packets_v4_out_pass:DERIVE:$INTERVAL:0:U DS:packets_v4_out_drop:DERIVE:$INTERVAL:0:U \
 	DS:packets_v6_in_pass:DERIVE:$INTERVAL:0:U DS:packets_v6_in_drop:DERIVE:$INTERVAL:0:U \
 	DS:packets_v6_in_pass:DERIVE:$INTERVAL:0:U DS:packets_v6_in_drop:DERIVE:$INTERVAL:0:U \
 	DS:packets_v6_out_pass:DERIVE:$INTERVAL:0:U DS:packets_v6_out_drop:DERIVE:$INTERVAL:0:U \
 	DS:packets_v6_out_pass:DERIVE:$INTERVAL:0:U DS:packets_v6_out_drop:DERIVE:$INTERVAL:0:U \
-	DS:states_entries:ABSOLUTE:$INTERVAL:0:U \
+	DS:states_entries:GAUGE:$INTERVAL:0:U \
 	DS:states_searches:DERIVE:$INTERVAL:0:U \
 	DS:states_searches:DERIVE:$INTERVAL:0:U \
 	DS:states_inserts:DERIVE:$INTERVAL:0:U \
 	DS:states_inserts:DERIVE:$INTERVAL:0:U \
 	DS:states_removals:DERIVE:$INTERVAL:0:U \
 	DS:states_removals:DERIVE:$INTERVAL:0:U \

+ 1 - 1
symon/symux/symux.8

@@ -65,7 +65,7 @@ on a tcp port and receive incoming
 transmissions decoded into ascii.
 transmissions decoded into ascii.
 .Lp
 .Lp
 .Nm
 .Nm
-needs no specific priviledges besides being able to open it's ports and
+needs no specific privileges besides being able to open it's ports and
 the rrd files. It should be run as
 the rrd files. It should be run as
 .Ar "nobody" .
 .Ar "nobody" .
 .Lp
 .Lp