Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/systat Add 4 new modes: ip, icmp, tcp, tcpsyn. XXX s...



details:   https://anonhg.NetBSD.org/src/rev/9d57f899f14a
branches:  trunk
changeset: 473356:9d57f899f14a
user:      ad <ad%NetBSD.org@localhost>
date:      Sun May 30 20:26:20 1999 +0000

description:
Add 4 new modes: ip, icmp, tcp, tcpsyn. XXX still some work to be done
on aesthetics and update modes.

diffstat:

 usr.bin/systat/Makefile |    5 +-
 usr.bin/systat/cmdtab.c |   16 ++-
 usr.bin/systat/extern.h |   22 ++++-
 usr.bin/systat/icmp.c   |  178 ++++++++++++++++++++++++++++++++++++
 usr.bin/systat/ip.c     |  201 +++++++++++++++++++++++++++++++++++++++++
 usr.bin/systat/systat.1 |   19 +++-
 usr.bin/systat/tcp.c    |  232 ++++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 666 insertions(+), 7 deletions(-)

diffs (truncated from 796 to 300 lines):

diff -r f5d77bc18a4b -r 9d57f899f14a usr.bin/systat/Makefile
--- a/usr.bin/systat/Makefile   Sun May 30 20:17:48 1999 +0000
+++ b/usr.bin/systat/Makefile   Sun May 30 20:26:20 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.16 1999/04/29 15:00:21 lukem Exp $
+#      $NetBSD: Makefile,v 1.17 1999/05/30 20:26:20 ad Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/6/93
 
 PROG=  systat
@@ -8,7 +8,8 @@
 CPPFLAGS+=-I${.CURDIR}/../../usr.bin/vmstat
 CWARNFLAGS+=    -Wno-format-y2k
 SRCS=  cmds.c cmdtab.c disks.c dkstats.c fetch.c iostat.c keyboard.c \
-       main.c mbufs.c netcmds.c netstat.c pigs.c ps.c swap.c vmstat.c
+       main.c mbufs.c netcmds.c netstat.c pigs.c ps.c swap.c vmstat.c \
+       tcp.c ip.c icmp.c
 DPADD= ${LIBCURSES} ${LIBM} ${LIBKVM}
 LDADD= -lcurses -lm -lkvm
 BINGRP=        kmem
diff -r f5d77bc18a4b -r 9d57f899f14a usr.bin/systat/cmdtab.c
--- a/usr.bin/systat/cmdtab.c   Sun May 30 20:17:48 1999 +0000
+++ b/usr.bin/systat/cmdtab.c   Sun May 30 20:26:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmdtab.c,v 1.5 1999/02/21 21:48:07 jwise Exp $ */
+/*     $NetBSD: cmdtab.c,v 1.6 1999/05/30 20:26:21 ad Exp $    */
 
 /*-
  * Copyright (c) 1980, 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)cmdtab.c   8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: cmdtab.c,v 1.5 1999/02/21 21:48:07 jwise Exp $");
+__RCSID("$NetBSD: cmdtab.c,v 1.6 1999/05/30 20:26:21 ad Exp $");
 #endif /* not lint */
 
 #include "systat.h"
@@ -66,6 +66,18 @@
        { "ps",         showps,         fetchpigs,      labelps,
          initpigs,     openpigs,       closepigs,      0,
          CF_LOADAV },
+       { "tcp",        showtcp,        fetchtcp,       labeltcp,
+         inittcp,      opentcp,        closetcp,       0,
+         CF_LOADAV },
+       { "tcpsyn",     showtcpsyn,     fetchtcp,       labeltcpsyn,
+         inittcp,      opentcp,        closetcp,       0,
+         CF_LOADAV },
+       { "ip",         showip,         fetchip,        labelip,
+         initip,       openip,         closeip,        0,
+         CF_LOADAV },
+       { "icmp",       showicmp,       fetchicmp,      labelicmp,
+         initicmp,     openicmp,       closeicmp,      0,
+         CF_LOADAV },
        { 0 }
 };
 struct  cmdtab *curcmd = &cmdtab[0];
diff -r f5d77bc18a4b -r 9d57f899f14a usr.bin/systat/extern.h
--- a/usr.bin/systat/extern.h   Sun May 30 20:17:48 1999 +0000
+++ b/usr.bin/systat/extern.h   Sun May 30 20:26:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.9 1999/04/24 23:54:56 ross Exp $  */
+/*     $NetBSD: extern.h,v 1.10 1999/05/30 20:26:21 ad Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -69,6 +69,9 @@
 void    closenetstat __P((WINDOW *));
 void    closepigs __P((WINDOW *));
 void    closeswap __P((WINDOW *));
+void    closetcp __P ((WINDOW *));
+void    closeip __P ((WINDOW *));
+void    closeicmp __P ((WINDOW *));
 int     cmdiostat __P((char *, char *));
 int     cmdkre __P((char *, char *));
 int     cmdnetstat __P((char *, char *));
@@ -85,12 +88,18 @@
 void    fetchnetstat __P((void));
 void    fetchpigs __P((void));
 void    fetchswap __P((void));
+void    fetchtcp __P((void));
+void    fetchip __P((void));
+void    fetchicmp __P((void));
 int     initiostat __P((void));
 int     initkre __P((void));
 int     initmbufs __P((void));
 int     initnetstat __P((void));
 int     initpigs __P((void));
 int     initswap __P((void));
+int     inittcp __P((void));
+int     initip __P((void));
+int     initicmp __P((void));
 int     keyboard __P((void)) __attribute__((__noreturn__));
 ssize_t         kvm_ckread __P((void *, void *, size_t));
 void    labeliostat __P((void));
@@ -99,6 +108,10 @@
 void    labelnetstat __P((void));
 void    labelpigs __P((void));
 void    labelps __P((void));
+void    labeltcp __P((void));
+void    labeltcpsyn __P((void));
+void    labelip __P((void));
+void    labelicmp __P((void));
 void    labels __P((void));
 void    labelswap __P((void));
 void    load __P((void));
@@ -110,6 +123,9 @@
 WINDOW *opennetstat __P((void));
 WINDOW *openpigs __P((void));
 WINDOW *openswap __P((void));
+WINDOW *opentcp __P((void));
+WINDOW *openip __P((void));
+WINDOW *openicmp __P((void));
 int     prefix __P((char *, char *));
 void    redraw __P((int));
 void    showiostat __P((void));
@@ -118,6 +134,10 @@
 void    shownetstat __P((void));
 void    showpigs __P((void));
 void    showswap __P((void));
+void    showtcp __P((void));
+void    showtcpsyn __P((void));
+void    showip __P((void));
+void    showicmp __P((void));
 void    showps __P((void));
 void    status __P((void));
 void    suspend __P((int));
diff -r f5d77bc18a4b -r 9d57f899f14a usr.bin/systat/icmp.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/systat/icmp.c     Sun May 30 20:26:20 1999 +0000
@@ -0,0 +1,178 @@
+/*     $NetBSD: icmp.c,v 1.1 1999/05/30 20:26:21 ad Exp $ */
+
+/*
+ * Copyright (c) 1999 Andy Doran <ad%NetBSD.org@localhost>
+ * 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.
+ *
+ * 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.
+ *
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: icmp.c,v 1.1 1999/05/30 20:26:21 ad Exp $");
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/icmp_var.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <paths.h>
+#include <nlist.h>
+#include <kvm.h>
+#include "systat.h"
+#include "extern.h"
+
+#define LHD(row, str) mvwprintw(wnd, row, 10, str)
+#define RHD(row, str) mvwprintw(wnd, row, 45, str);
+#define BD(row, str) LHD(row, str); RHD(row, str)
+#define SHOW(stat, row, col) mvwprintw(wnd, row, col, "%9lu", stats.stat)
+#define SHOW2(type, row) SHOW(icps_inhist[type], row, 0); \
+    SHOW(icps_outhist[type], row, 35)
+
+static struct icmpstat stats;
+
+static struct nlist namelist[] = {
+       { "_icmpstat" },
+       { "" }
+};
+
+WINDOW *
+openicmp(void)
+{
+
+       return (subwin(stdscr, LINES-5-1, 0, 5, 0));
+}
+
+void
+closeicmp(w)
+       WINDOW *w;
+{
+
+       if (w != NULL) {
+               wclear(w);
+               wrefresh(w);
+               delwin(w);
+       }
+}
+
+void
+labelicmp(void)
+{
+
+       wmove(wnd, 0, 0); wclrtoeol(wnd);
+
+       mvwprintw(wnd, 1, 0,  "------------ ICMP input -------------");
+       mvwprintw(wnd, 1, 38, "------------- ICMP output -------------");
+
+       mvwprintw(wnd, 8, 0,  "---------- Input histogram ----------");
+       mvwprintw(wnd, 8, 38, "---------- Output histogram -----------");
+       
+       LHD(3, "with bad code");
+       LHD(4, "with bad length");
+       LHD(5, "with bad checksum");
+       LHD(6, "with insufficient data");
+       
+       RHD(3, "errors generated");
+       RHD(4, "suppressed - original too short");
+       RHD(5, "suppressed - original was ICMP");
+       RHD(6, "responses sent");
+
+       BD(2, "total messages");
+       BD(9, "echo response");
+       BD(10, "echo request");
+       BD(11, "destination unreachable");
+       BD(12, "redirect");
+       BD(13, "time-to-live exceeded");
+       BD(14, "parameter problem");
+       LHD(15, "router advertisement");        
+       RHD(15, "router solicitation");
+}
+
+void
+showicmp(void)
+{
+       u_long tin, tout;
+       int i;
+
+       for (i = tin = tout = 0; i <= ICMP_MAXTYPE; i++) {
+               tin += stats.icps_inhist[i];
+               tout += stats.icps_outhist[i];
+       }
+
+       tin += stats.icps_badcode + stats.icps_badlen + stats.icps_checksum + 
+           stats.icps_tooshort;
+       mvwprintw(wnd, 2, 0, "%9lu", tin);
+       mvwprintw(wnd, 2, 35, "%9lu", tout);
+
+       SHOW(icps_badcode, 3, 0);
+       SHOW(icps_badlen, 4, 0);
+       SHOW(icps_checksum, 5, 0);
+       SHOW(icps_tooshort, 6, 0);
+       SHOW(icps_error, 3, 35);
+       SHOW(icps_oldshort, 4, 35);
+       SHOW(icps_oldicmp, 5, 35);
+       SHOW(icps_reflect, 6, 35);
+
+       SHOW2(ICMP_ECHOREPLY, 9);
+       SHOW2(ICMP_ECHO, 10);
+       SHOW2(ICMP_UNREACH, 11);
+       SHOW2(ICMP_REDIRECT, 12);
+       SHOW2(ICMP_TIMXCEED, 13);
+       SHOW2(ICMP_PARAMPROB, 14);
+       SHOW(icps_inhist[ICMP_ROUTERADVERT], 15, 0);
+       SHOW(icps_outhist[ICMP_ROUTERSOLICIT], 15, 35);
+}
+
+int
+initicmp(void)
+{
+
+       if (namelist[0].n_type == 0) {
+               if (kvm_nlist(kd, namelist)) {
+                       nlisterr(namelist);
+                       return(0);
+               }
+               if (namelist[0].n_type == 0) {
+                       error("No namelist");
+                       return(0);
+               }
+       }
+       
+       return (1);



Home | Main Index | Thread Index | Old Index