Re: systat -ifstat patch

2003-01-04 Thread phk

Committed, thanks!

Poul-Henning

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: systat -ifstat patch

2003-01-04 Thread Trent Nelson
On Sat, Jan 04, 2003 at 09:50:47PM +0100, [EMAIL PROTECTED] wrote:

> This looks pretty useful.

Thanks!  I think so, so have most other people I've spoken to.

> As far as I can see you have some genuine fixes in there:
> 
> >--- /shared/data/trent/src/src/usr.bin/systat/cmds.c Wed Dec 12 00:13:37 2001
> >+++ /usr/src/usr.bin/systat/cmds.c   Sat Jan  4 14:11:32 2003
> >@@ -119,6 +119,7 @@
> > goto done;
> > alarm(0);
> > (*curcmd->c_close)(wnd);
> >+curcmd->c_flags &= ~CF_INIT;
> > wnd = (*p->c_open)();
> > if (wnd == 0) {
> > error("Couldn't open new display");
> 
> We should probably commit them in a separate commit first.

I agree.  That particular bug caused me a lot of grief this morning
before I tracked it down.  None of the other displays were affected
'cause they didn't have to allocate any structures dynamically.

I've attached cmds.c.patch to this e-mail.

> >diff -uBN /shared/data/trent/src/src/usr.bin/systat/convtbl.c 
>/usr/src/usr.bin/systat/convtbl.c
> >--- /shared/data/trent/src/src/usr.bin/systat/convtbl.c  Thu Jan  1 01:00:00 
>1970
> >+++ /usr/src/usr.bin/systat/convtbl.cSat Jan  4 00:13:11 2003
> >@@ -0,0 +1,98 @@
> 
> This is only used for the ifstat page, right ?  Should/Could bits
> of the other code use it as well ?

Yup, it's currently only used for the ifstat display.  No other
displays did automatic scaling so I had to write it from scratch.
The only possible contender for using this code would be vmstat's
disk usage stats on the bottom left of the screen -- but I think
that would just unnecessarily clutter the display more than it
already is.

What would be nice is a new diskstat display that is the same as
ifstat, except you display transfer rates for drives on the system.
I think a lot of people would find this useful (possibly even more
so than the ifstat display).  What do you think?


> > .\" @(#)systat.18.2 (Berkeley) 12/30/93
> >-.\" $FreeBSD: src/usr.bin/systat/systat.1,v 1.36 2002/12/27 12:15:35 schweikh Exp $
> >+.\" $FreeBSD: src/usr.bin/systat/systat.1,v 1.23.2.9 2002/12/29 16:35:40 schweikh 
>Exp $
> 
> This looks worrisome to me, and some of the deltas look more so:

Erm.  Eek.  I think I copied the -stable systat.1 into my -current
sources.  I fixed this in the new patch, which can be found at
http://arpa.com/~trent.  My bad.

(``systat-ifstat-current.patch'' also now has the modification to
 cmds.c taken out and placed separately in ``cmds.c.patch''.)

> Otherwise I think it looks good.

Glad to hear it.

> Poul-Henning Kamp

Regards,

Trent.

Index: cmds.c
===
RCS file: /home/ncvs/src/usr.bin/systat/cmds.c,v
retrieving revision 1.4
diff -u -r1.4 cmds.c
--- cmds.c  12 Dec 2001 00:13:37 -  1.4
+++ cmds.c  4 Jan 2003 14:11:32 -
@@ -119,6 +119,7 @@
goto done;
 alarm(0);
(*curcmd->c_close)(wnd);
+   curcmd->c_flags &= ~CF_INIT;
wnd = (*p->c_open)();
if (wnd == 0) {
error("Couldn't open new display");



Re: systat -ifstat patch

2003-01-04 Thread phk
In message <[EMAIL PROTECTED]>, Trent Nelson writes:
>
>I've written an extension to systat that allows you to monitor the
>traffic through active network interfaces on the system, akin to
>netstat -I.  I've attached the patch to this e-mail, but it can also be
>found at http://arpa.com/~trent/systat-ifstat-current.patch[.tar.gz].
>
>All comments on code, style or functionality are welcome.

This looks pretty useful.

As far as I can see you have some genuine fixes in there:

>diff -uBN /shared/data/trent/src/src/usr.bin/systat/cmds.c 
>/usr/src/usr.bin/systat/cmds.c
>--- /shared/data/trent/src/src/usr.bin/systat/cmds.c   Wed Dec 12 00:13:37 2001
>+++ /usr/src/usr.bin/systat/cmds.c Sat Jan  4 14:11:32 2003
>@@ -119,6 +119,7 @@
>   goto done;
> alarm(0);
>   (*curcmd->c_close)(wnd);
>+  curcmd->c_flags &= ~CF_INIT;
>   wnd = (*p->c_open)();
>   if (wnd == 0) {
>   error("Couldn't open new display");

We should probably commit them in a separate commit first.

>diff -uBN /shared/data/trent/src/src/usr.bin/systat/convtbl.c 
>/usr/src/usr.bin/systat/convtbl.c
>--- /shared/data/trent/src/src/usr.bin/systat/convtbl.cThu Jan  1 01:00:00 
>1970
>+++ /usr/src/usr.bin/systat/convtbl.c  Sat Jan  4 00:13:11 2003
>@@ -0,0 +1,98 @@

This is only used for the ifstat page, right ?  Should/Could bits
of the other code use it as well ?

>diff -uBN /shared/data/trent/src/src/usr.bin/systat/systat.1 
>/usr/src/usr.bin/systat/systat.1
>--- /shared/data/trent/src/src/usr.bin/systat/systat.1 Fri Dec 27 12:15:35 2002
>+++ /usr/src/usr.bin/systat/systat.1   Sat Jan  4 14:31:06 2003
>@@ -30,7 +30,7 @@
> .\" SUCH DAMAGE.
> .\"
> .\"   @(#)systat.18.2 (Berkeley) 12/30/93
>-.\" $FreeBSD: src/usr.bin/systat/systat.1,v 1.36 2002/12/27 12:15:35 schweikh Exp $
>+.\" $FreeBSD: src/usr.bin/systat/systat.1,v 1.23.2.9 2002/12/29 16:35:40 schweikh 
>Exp $

This looks worrisome to me, and some of the deltas look more so:

>@@ -500,8 +522,8 @@
> .Xr iostat 8 ,
> .Xr vmstat 8
> .Sh FILES
>-.Bl -tag -width /boot/kernel/kernel -compact
>-.It Pa /boot/kernel/kernel
>+.Bl -tag -width /etc/networks -compact
>+.It Pa /kernel
> For the namelist.
> .It Pa /dev/kmem
> For information in main memory.

Otherwise I think it looks good.

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



systat -ifstat patch

2003-01-04 Thread Trent Nelson

I've written an extension to systat that allows you to monitor the
traffic through active network interfaces on the system, akin to
netstat -I.  I've attached the patch to this e-mail, but it can also be
found at http://arpa.com/~trent/systat-ifstat-current.patch[.tar.gz].

All comments on code, style or functionality are welcome.

Regards,

Trent.

Common subdirectories: /shared/data/trent/src/src/usr.bin/systat/CVS and 
/usr/src/usr.bin/systat/CVS
diff -uBN /shared/data/trent/src/src/usr.bin/systat/Makefile 
/usr/src/usr.bin/systat/Makefile
--- /shared/data/trent/src/src/usr.bin/systat/Makefile  Fri Feb  8 23:07:35 2002
+++ /usr/src/usr.bin/systat/MakefileSat Dec 28 16:23:57 2002
@@ -4,7 +4,7 @@
 PROG=  systat
 SRCS=  cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c \
mbufs.c netcmds.c netstat.c pigs.c swap.c icmp.c mode.c ip.c tcp.c \
-   vmstat.c
+   vmstat.c convtbl.c ifcmds.c ifstat.c
 DPADD= ${LIBCURSES} ${LIBM} ${LIBKVM} ${LIBDEVSTAT}
 LDADD= -lcurses -lm -lkvm -ldevstat
 
diff -uBN /shared/data/trent/src/src/usr.bin/systat/cmds.c 
/usr/src/usr.bin/systat/cmds.c
--- /shared/data/trent/src/src/usr.bin/systat/cmds.cWed Dec 12 00:13:37 2001
+++ /usr/src/usr.bin/systat/cmds.c  Sat Jan  4 14:11:32 2003
@@ -119,6 +119,7 @@
goto done;
 alarm(0);
(*curcmd->c_close)(wnd);
+   curcmd->c_flags &= ~CF_INIT;
wnd = (*p->c_open)();
if (wnd == 0) {
error("Couldn't open new display");
diff -uBN /shared/data/trent/src/src/usr.bin/systat/cmdtab.c 
/usr/src/usr.bin/systat/cmdtab.c
--- /shared/data/trent/src/src/usr.bin/systat/cmdtab.c  Wed Dec 12 00:13:37 2001
+++ /usr/src/usr.bin/systat/cmdtab.cSat Dec 28 16:30:52 2002
@@ -71,6 +71,9 @@
{ "tcp",showtcp,fetchtcp,   labeltcp,
  inittcp,  opentcp,closetcp,   cmdmode,
  resettcp, 0 },
+   { "ifstat", showifstat, fetchifstat,labelifstat,
+ initifstat,   openifstat, closeifstat,cmdifstat,
+ 0,CF_LOADAV },
 { NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 }
 };
 struct  cmdtab *curcmd = &cmdtab[0];
diff -uBN /shared/data/trent/src/src/usr.bin/systat/convtbl.c 
/usr/src/usr.bin/systat/convtbl.c
--- /shared/data/trent/src/src/usr.bin/systat/convtbl.c Thu Jan  1 01:00:00 1970
+++ /usr/src/usr.bin/systat/convtbl.c   Sat Jan  4 00:13:11 2003
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2003, Trent Nelson, <[EMAIL PROTECTED]>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $Id$
+ */
+
+#include 
+#include 
+#include "convtbl.h"
+
+struct convtbl convtbl[] = {
+   /* mul, scale, str */
+   { BYTE, BYTES, "bytes" },   /* SC_BYTE  (0) */
+   { BYTE, KILO, "KB" },   /* SC_KILOBYTE  (1) */
+   { BYTE, MEGA, "MB" },   /* SC_MEGABYTE  (2) */
+   { BYTE, GIGA, "GB" },   /* SC_GIGABYTE  (3) */
+
+   { BIT, BITS, "b" }, /* SC_BITS  (4) */
+   { BIT, KILO, "Kb" },/* SC_KILOBITS  (5) */
+   { BIT, MEGA, "Mb" },/* SC_MEGABITS  (6) */
+   { BIT, GIGA, "Gb" },/* SC_GIGABITS  (7) */
+
+   { 0, 0, "" }/* SC_AUTO  (8) */
+
+};
+
+
+static __inline__
+struct convtbl *
+get_tbl_ptr(const u_long size, const u_int scale)
+{
+   struct  convtbl *tbl_ptr = NULL;
+   u_long  tmp = 0;
+   u_int   index = scale;
+
+