瀏覽代碼

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

Wictor Lund 3 年之前
父節點
當前提交
b849b17c70

+ 16 - 0
symon/CHANGELOG

@@ -1,3 +1,19 @@
+24/10/2014 - 2.87
+
+   - platform/FreeBSD/sm_cpu.c updated to support smp
+
+   - platform/Linux/sm_io.c read all disk info, not just first block
+
+   - client/SymuxClient.pm removed documentation errors (Jeroen Roovers)
+
+   - symon.8, mention that a windows symon client by Valeriy Leshchinskiy is
+     available on https://github.com/ValHazelwood/SymonClient
+
+   - symux/symux.8 counter name fixes (Dennis Lindahl)
+
+   - symon/c_config.sh updated. # cpus are now detected + more Linux mount
+     types supported.
+
 05/02/2013 - 2.86
 05/02/2013 - 2.86
 
 
    - platform/OpenBSD/sm_proc.c updated to new kinfo_proc interface
    - platform/OpenBSD/sm_proc.c updated to new kinfo_proc interface

+ 1 - 1
symon/Makefile.inc

@@ -1,4 +1,4 @@
-V=2.86
+V=2.87
 
 
 AR?=	ar
 AR?=	ar
 CC?=	cc
 CC?=	cc

+ 0 - 0
symon/client/SymuxClient.cat3p.tmp


+ 12 - 0
symon/client/SymuxClient.pm

@@ -267,23 +267,35 @@ Example:
 
 
 =head2 METHODS
 =head2 METHODS
 
 
+=over 4
+
 =item getitem (host, stream, item)
 =item getitem (host, stream, item)
 
 
+=back
+
 Refresh the measured data and get an item from a stream for a particular
 Refresh the measured data and get an item from a stream for a particular
 host. Note that successive calls for this function deal with successive
 host. Note that successive calls for this function deal with successive
 measurements of B<symon>. Set C<host> to '*' if data about any host is of
 measurements of B<symon>. Set C<host> to '*' if data about any host is of
 interest. Any errors are sent out on STDOUT prepended with 'error: '.
 interest. Any errors are sent out on STDOUT prepended with 'error: '.
 
 
+=over 4
+
 =item getcacheditem (host, stream, item)
 =item getcacheditem (host, stream, item)
 
 
+=back
+
 Get an item from a stream for a particular host. Returns C<undef> if no data is
 Get an item from a stream for a particular host. Returns C<undef> if no data is
 cached, or if the data cached does not match the B<host>. Can be called
 cached, or if the data cached does not match the B<host>. Can be called
 multiple times to obtain items from the same measurement. Set C<host> to '*' if
 multiple times to obtain items from the same measurement. Set C<host> to '*' if
 data about any host is of interest. Any errors are sent out on STDOUT prepended
 data about any host is of interest. Any errors are sent out on STDOUT prepended
 with 'error: '.
 with 'error: '.
 
 
+=over 4
+
 =item getsource ()
 =item getsource ()
 
 
+=back
+
 Get the symon source host of the currently cached information. Usefull to see
 Get the symon source host of the currently cached information. Usefull to see
 what host's data getcacheditem is working on.
 what host's data getcacheditem is working on.
 
 

+ 10 - 5
symon/platform/FreeBSD/conf.sh

@@ -13,17 +13,17 @@ if ! grep -q "VM_TOTAL" /usr/include/vm/vm_param.h; then
     echo "#define VM_TOTAL VM_METER"
     echo "#define VM_TOTAL VM_METER"
 fi
 fi
 if grep -q "struct xswdev" /usr/include/vm/vm_param.h; then
 if grep -q "struct xswdev" /usr/include/vm/vm_param.h; then
-    echo "#define HAS_XSWDEV	1"
+    echo "#define HAS_XSWDEV		1"
 else
 else
     echo "#undef HAS_XSWDEV"
     echo "#undef HAS_XSWDEV"
 fi
 fi
 if [ -f /usr/include/net/pfvar.h ]; then
 if [ -f /usr/include/net/pfvar.h ]; then
-    echo "#define HAS_PFVAR_H	1"
+    echo "#define HAS_PFVAR_H		1"
 else
 else
     echo "#undef HAS_PFVAR_H"
     echo "#undef HAS_PFVAR_H"
 fi
 fi
 if grep -q "ki_paddr" /usr/include/sys/user.h; then
 if grep -q "ki_paddr" /usr/include/sys/user.h; then
-    echo "#define HAS_KI_PADDR	1"
+    echo "#define HAS_KI_PADDR		1"
 else
 else
     echo "#undef HAS_KI_PADDR"
     echo "#undef HAS_KI_PADDR"
 fi
 fi
@@ -38,12 +38,17 @@ else
     echo "#undef HAS_RESOURCE_CPUSTATE"
     echo "#undef HAS_RESOURCE_CPUSTATE"
 fi
 fi
 if grep -q "IOCATAREQUEST" /usr/include/sys/ata.h; then
 if grep -q "IOCATAREQUEST" /usr/include/sys/ata.h; then
-    echo "#define HAS_IOCATAREQUEST 1"
+    echo "#define HAS_IOCATAREQUEST	1"
 else
 else
     echo "#undef HAS_IOCATAREQUEST"
     echo "#undef HAS_IOCATAREQUEST"
 fi
 fi
 if grep -q "ATA_SMART_CMD" /usr/include/sys/ata.h; then
 if grep -q "ATA_SMART_CMD" /usr/include/sys/ata.h; then
-    echo "#define HAS_ATA_SMART_CMD 1"
+    echo "#define HAS_ATA_SMART_CMD	1"
 else
 else
     echo "#undef HAS_ATA_SMART_CMD"
     echo "#undef HAS_ATA_SMART_CMD"
 fi
 fi
+if sysctl kern.cp_times >/dev/null 2>&1; then
+    echo "#define HAS_CP_TIMES		1"
+else
+    echo "#undef HAS_CP_TIMES"
+fi

+ 1 - 1
symon/platform/FreeBSD/platform.h

@@ -24,11 +24,11 @@
 
 
 union stream_parg {
 union stream_parg {
     struct {
     struct {
-        long time1[CPUSTATES];
         int64_t time2[CPUSTATES];
         int64_t time2[CPUSTATES];
         int64_t old[CPUSTATES];
         int64_t old[CPUSTATES];
         int64_t diff[CPUSTATES];
         int64_t diff[CPUSTATES];
         int64_t states[CPUSTATES];
         int64_t states[CPUSTATES];
+        uint8_t id;
     } cp;
     } cp;
     struct {
     struct {
         char rawdev[SYMON_DFNAMESIZE];
         char rawdev[SYMON_DFNAMESIZE];

+ 46 - 15
symon/platform/FreeBSD/sm_cpu.c

@@ -1,4 +1,5 @@
 /*
 /*
+ * Copyright (c) 2014      Willem Dijkstra
  * Copyright (c) 2004      Matthew Gream
  * Copyright (c) 2004      Matthew Gream
  * All rights reserved.
  * All rights reserved.
  *
  *
@@ -34,7 +35,7 @@
  *
  *
  * user : nice : system : interrupt : idle
  * user : nice : system : interrupt : idle
  *
  *
- * This code is not re-entrant and UP only.
+ * This code is not re-entrant.
  *
  *
  * This module uses the sysctl interface and can run as any user.
  * This module uses the sysctl interface and can run as any user.
  */
  */
@@ -45,28 +46,55 @@
 #include <sys/dkstat.h>
 #include <sys/dkstat.h>
 #include <sys/sysctl.h>
 #include <sys/sysctl.h>
 
 
+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
 #include "error.h"
 #include "error.h"
 #include "percentages.h"
 #include "percentages.h"
 #include "symon.h"
 #include "symon.h"
+#include "sylimits.h"
+#include "xmalloc.h"
 
 
 /* Globals for this module all start with cp_ */
 /* Globals for this module all start with cp_ */
+#ifdef HAS_CP_TIMES
+static char cp_time_mib_str[] = "kern.cp_times";
+#else
 static char cp_time_mib_str[] = "kern.cp_time";
 static char cp_time_mib_str[] = "kern.cp_time";
+#endif
 static int cp_time_mib[CTL_MAXNAME];
 static int cp_time_mib[CTL_MAXNAME];
 static size_t cp_time_len = 0;
 static size_t cp_time_len = 0;
-static size_t cp_size;
+static void *cp_buf;
+static size_t cp_size = 0;
 
 
 void
 void
 init_cpu(struct stream *st)
 init_cpu(struct stream *st)
 {
 {
     char buf[SYMON_MAX_OBJSIZE];
     char buf[SYMON_MAX_OBJSIZE];
+    const char *errstr;
+
+    if (cp_time_len == 0) {
+        cp_time_len = CTL_MAXNAME;
+        if (sysctlnametomib(cp_time_mib_str, cp_time_mib, &cp_time_len) < 0) {
+            warning("sysctlnametomib for cpu failed");
+            cp_time_len = 0;
+        }
+
+        if ((sysctl(cp_time_mib, cp_time_len, NULL, &cp_size, NULL, 0) != -1) &&
+            (errno == ENOMEM))
+            fatal("cpu(%.200s): failed to determine sysctl buffer len", st->arg);
 
 
-    cp_time_len = CTL_MAXNAME;
-    if (sysctlnametomib(cp_time_mib_str, cp_time_mib, &cp_time_len) < 0) {
-        warning("sysctlnametomib for cpu failed");
-        cp_time_len = 0;
+        if (cp_size > SYMON_MAX_OBJSIZE)
+            fatal("cpu(%.200s): sysctl buffer too large", st->arg);
+
+        cp_buf = xmalloc(cp_size);
+        gets_cpu();
     }
     }
 
 
-    cp_size = sizeof(st->parg.cp.time1);
+    st->parg.cp.id = strtonum(st->arg, 0, SYMON_MAXCPUID, &errstr);
+    if (errstr != NULL)
+        fatal("cpu(%.200s) is invalid: %.200s", st->arg, errstr);
+
     get_cpu(buf, sizeof(buf), st);
     get_cpu(buf, sizeof(buf), st);
 
 
     info("started module cpu(%.200s)", st->arg);
     info("started module cpu(%.200s)", st->arg);
@@ -75,26 +103,29 @@ init_cpu(struct stream *st)
 void
 void
 gets_cpu()
 gets_cpu()
 {
 {
-    /* EMPTY */
+    if (sysctl(cp_time_mib, cp_time_len, cp_buf, &cp_size, NULL, 0) < 0) {
+        warning("%s:%d: sysctl failed", __FILE__, __LINE__);
+        return;
+    }
 }
 }
 
 
 int
 int
 get_cpu(char *symon_buf, int maxlen, struct stream *st)
 get_cpu(char *symon_buf, int maxlen, struct stream *st)
 {
 {
     int i;
     int i;
+    long *time1;
 
 
-    if (!cp_time_len) {
+    if (!cp_time_len)
         return 0;
         return 0;
-    }
 
 
-    if (sysctl(cp_time_mib, cp_time_len, &st->parg.cp.time1, &cp_size, NULL, 0) < 0) {
-        warning("%s:%d: sysctl kern.cp_time failed", __FILE__, __LINE__);
-        return 0;
-    }
+    time1 = (long *)(cp_buf + (sizeof(long) * CPUSTATES * st->parg.cp.id));
+
+    if (((void *)time1 - cp_buf) > cp_size)
+        warning("cpu(%d): not in sysctl buffer", st->parg.cp.id);
 
 
     /* convert cp_time counts to percentages */
     /* convert cp_time counts to percentages */
     for (i = 0; i < CPUSTATES; i++)
     for (i = 0; i < CPUSTATES; i++)
-        st->parg.cp.time2[i] = (int64_t) st->parg.cp.time1[i];
+        st->parg.cp.time2[i] = (int64_t) time1[i];
 
 
     (void)percentages(CPUSTATES, st->parg.cp.states, st->parg.cp.time2, st->parg.cp.old, st->parg.cp.diff);
     (void)percentages(CPUSTATES, st->parg.cp.states, st->parg.cp.time2, st->parg.cp.old, st->parg.cp.diff);
 
 

+ 0 - 14
symon/platform/FreeBSD/sm_smart.c

@@ -230,20 +230,6 @@ get_smart(char *symon_buf, int maxlen, struct stream *st)
         (!smart_devs[st->parg.smart].failed))
         (!smart_devs[st->parg.smart].failed))
     {
     {
         smart_parse(&smart_devs[st->parg.smart].data, &sr);
         smart_parse(&smart_devs[st->parg.smart].data, &sr);
-        debug("%x %x %x %x %x %x %x %x %x %x %x %x",
-                      sr.read_error_rate,
-                      sr.reallocated_sectors,
-                      sr.spin_retries,
-                      sr.air_flow_temp,
-                      sr.temperature,
-                      sr.reallocations,
-                      sr.current_pending,
-                      sr.uncorrectables,
-                      sr.soft_read_error_rate,
-                      sr.g_sense_error_rate,
-                      sr.temperature2,
-                      sr.free_fall_protection);
-
         return snpack(symon_buf, maxlen, st->arg, MT_SMART,
         return snpack(symon_buf, maxlen, st->arg, MT_SMART,
                       sr.read_error_rate,
                       sr.read_error_rate,
                       sr.reallocated_sectors,
                       sr.reallocated_sectors,

+ 11 - 1
symon/platform/Linux/sm_io.c

@@ -118,13 +118,23 @@ void
 gets_io()
 gets_io()
 {
 {
     int fd;
     int fd;
+    int len;
+    char *p;
+
     if ((fd = open(io_filename, O_RDONLY)) < 0) {
     if ((fd = open(io_filename, O_RDONLY)) < 0) {
         warning("cannot access %.200s: %.200s", io_filename, strerror(errno));
         warning("cannot access %.200s: %.200s", io_filename, strerror(errno));
         return;
         return;
     }
     }
 
 
     bzero(io_buf, io_maxsize);
     bzero(io_buf, io_maxsize);
-    io_size = read(fd, io_buf, io_maxsize);
+
+    len = 0;
+    p = io_buf;
+    io_size = 0;
+    while ((len = read(fd, p, io_maxsize - io_size)) > 0) {
+      p += len;
+      io_size += len;
+    }
     close(fd);
     close(fd);
 
 
     if (io_size == io_maxsize) {
     if (io_size == io_maxsize) {

+ 5 - 4
symon/symon/c_config.sh

@@ -17,14 +17,17 @@ case "${OS}" in
 OpenBSD)
 OpenBSD)
 	interfaces=`netstat -ni | sed '1,1d;s/^\([a-z]*[0-9]\).*$/\1/g' | uniq`
 	interfaces=`netstat -ni | sed '1,1d;s/^\([a-z]*[0-9]\).*$/\1/g' | uniq`
 	io=`mount | sed -n '/^\/dev/ s@/dev/\([a-z]*[0-9]\).*@io(\1), @p' | sort -u | tr -d \\\n`
 	io=`mount | sed -n '/^\/dev/ s@/dev/\([a-z]*[0-9]\).*@io(\1), @p' | sort -u | tr -d \\\n`
+        cpu="cpu(0),"
 	;;
 	;;
 FreeBSD|NetBSD)
 FreeBSD|NetBSD)
 	interfaces=`ifconfig -l`
 	interfaces=`ifconfig -l`
 	io=`mount | sed -n '/^\/dev/ s@/dev/\([a-z]*[0-9]\).*@io(\1), @p' | sort -u | tr -d \\\n`
 	io=`mount | sed -n '/^\/dev/ s@/dev/\([a-z]*[0-9]\).*@io(\1), @p' | sort -u | tr -d \\\n`
+        cpu=`sysctl dev.cpu | grep '%desc' | sed -n 's/dev.cpu.\([0-9]*\).*$/cpu(\1), /p'`
 	;;
 	;;
 Linux)
 Linux)
 	interfaces=`ifconfig -a| sed -n '/^[a-z]/ s,\([a-z]*[0-9]\).*,\1,p' | sort -u`
 	interfaces=`ifconfig -a| sed -n '/^[a-z]/ s,\([a-z]*[0-9]\).*,\1,p' | sort -u`
-	io=`mount | sed -n '/^\/dev/ s@/dev/\([a-z]*[0-9]\).*@io(\1), @p' | sort -u | tr -d \\\n`
+	io=`mount | sed -n '/^\/dev/ s@/dev/\([a-z]*[0-9]\).*@io(\1), @p;s@/dev/\(x[a-z]\+[0-9]*\).*@io(\1), @p' | sort -u | tr -d \\\n`
+        cpu=`cat /proc/cpuinfo | sed -n '/^processor/ s@[^:]\+: \([0-9]\+\)@cpuiow\(\1\), @p' | sort -u | tr -d \\\n`
 	;;
 	;;
 esac;
 esac;
 for i in $interfaces; do
 for i in $interfaces; do
@@ -44,7 +47,5 @@ cat <<EOF
 # symon configuration generated by
 # symon configuration generated by
 # `basename $0` $1 $2
 # `basename $0` $1 $2
 #
 #
-monitor { $if
-	  $io
-	  cpu(0), mem } stream to $host $port
+monitor { ${if}${io}${cpu}mem } stream to $host $port
 EOF
 EOF

+ 5 - 1
symon/symon/symon.8

@@ -1,6 +1,6 @@
 .\"  -*- nroff -*-
 .\"  -*- nroff -*-
 .\"
 .\"
-.\" Copyright (c) 2001-2012 Willem Dijkstra
+.\" Copyright (c) 2001-2013 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
@@ -213,5 +213,9 @@ Port contributors: \%Marc \%Balmer, \%Tito \%Dal \%Canton, \%Matthew
 \%Gream, \%Daniel \%Hartmeier, \%Lars \%Kotthoff, \%Constantine
 \%Gream, \%Daniel \%Hartmeier, \%Lars \%Kotthoff, \%Constantine
 A. \%Murenin, J. \%Martin \%Petersen, \%Fredrik \%Soderblom, \%Harm
 A. \%Murenin, J. \%Martin \%Petersen, \%Fredrik \%Soderblom, \%Harm
 \%Schotanus and \%Martin van der \%Werff.
 \%Schotanus and \%Martin van der \%Werff.
+
+\%Valeriy \%Leshchinskiy maintains a windows symon client at
+https://github.com/ValHazelwood/SymonClient .
+
 .Sh SEE ALSO
 .Sh SEE ALSO
 .Xr symux 8
 .Xr symux 8

+ 0 - 0
symon/symux/c_smrrds.sh


+ 6 - 6
symon/symux/symux.8

@@ -227,9 +227,9 @@ Kernel variables debug0 to debug19. ( debug0 : ... : debug19 ). Values are 32
 bit unsigned integers.
 bit unsigned integers.
 .It df
 .It df
 Disk free statistics ( blocks : bfree : bavail : files :
 Disk free statistics ( blocks : bfree : bavail : files :
-ffree : synwrites : asyncwrites). Values are 64 bit unsigned integers.
+ffree : syncwrites : asyncwrites ). Values are 64 bit unsigned integers.
 .It load
 .It load
-Load averages for the last 1, 5, and 15 minutes. Data is offered with precision
+Load averages for the last 1, 5, and 15 minutes ( load1, load5, load15 ). Data is offered with prec ision
 2 and a maximum of 655.
 2 and a maximum of 655.
 .It if
 .It if
 Alias for if2. See below.
 Alias for if2. See below.
@@ -238,8 +238,8 @@ Pre OpenBSD 4.3 interface counters ( packets_in, packets_out, bytes_in,
 bytes_out, multicasts_in, multicasts_out, errors_in, errors_out, collisions,
 bytes_out, multicasts_in, multicasts_out, errors_in, errors_out, collisions,
 drops ). Values are 32 bit unsigned integers.
 drops ). Values are 32 bit unsigned integers.
 .It if2
 .It if2
-Interface counters ( packets_in, packets_out, bytes_in, bytes_out,
-multicasts_in, multicasts_out, errors_in, errors_out, collisions, drops
+Interface counters ( ipackets, opackets, ibytes, obytes,
+imcasts, omcasts, ierrors, oerrors, collisions, drops
 ). Values are 64 bit unsigned integers.
 ). Values are 64 bit unsigned integers.
 .It io
 .It io
 Alias for io2. See below.
 Alias for io2. See below.
@@ -247,8 +247,8 @@ Alias for io2. See below.
 Pre OpenBSD 3.5 io/disk counters ( total_transfers, total_seeks, total_bytes
 Pre OpenBSD 3.5 io/disk counters ( total_transfers, total_seeks, total_bytes
 ). Values are 64 bit unsigned integers.
 ). Values are 64 bit unsigned integers.
 .It io2
 .It io2
-Io/disk counters ( total_rxfer, total_wxfer, total_seeks, total_rbytes,
-total_wbytes). Values are 64 bit unsigned integers.
+Io/disk counters ( rxfer, wxfer, seeks, rbytes,
+wbytes). Values are 64 bit unsigned integers.
 .It mbuf
 .It mbuf
 Mbuf statistics ( totmbufs : mt_data : mt_oobdata : mt_control :
 Mbuf statistics ( totmbufs : mt_data : mt_oobdata : mt_control :
 mt_header : mt_ftable : mt_soname : mt_soopts : pgused : pgtotal :
 mt_header : mt_ftable : mt_soname : mt_soopts : pgused : pgtotal :