- Add `boot', `run', `time' and `zero' commands to all IP displays. These work

as in the `vmstat' display mode. The default mode is now `time', not `boot'.
- ANSIfy.
- s@kre\(@vmstat\(@.
- __RCSID() police.
- Tweak inet.icmp display visual a little.
This commit is contained in:
ad 2000-07-05 11:03:20 +00:00
parent 176fa63b5b
commit fc3915475d
23 changed files with 885 additions and 558 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bufcache.c,v 1.7 2000/04/27 00:30:51 jdc Exp $ */
/* $NetBSD: bufcache.c,v 1.8 2000/07/05 11:03:20 ad Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: bufcache.c,v 1.7 2000/04/27 00:30:51 jdc Exp $");
__RCSID("$NetBSD: bufcache.c,v 1.8 2000/07/05 11:03:20 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -106,22 +106,21 @@ static void *bufaddr;
static struct buf *buf = NULL;
static TAILQ_HEAD(bqueues, buf) bufqueues[BQUEUES];
static void vc_init __P((void));
static void ml_init __P((void));
static struct vnode *vc_lookup __P((struct vnode *));
static struct mount *ml_lookup __P((struct mount *, int, int));
static void vc_init(void);
static void ml_init(void);
static struct vnode *vc_lookup(struct vnode *);
static struct mount *ml_lookup(struct mount *, int, int);
WINDOW *
openbufcache()
openbufcache(void)
{
return (subwin(stdscr, LINES-5-1, 0, 5, 0));
}
void
closebufcache(w)
WINDOW *w;
closebufcache(WINDOW *w)
{
if (w == NULL)
@ -133,7 +132,7 @@ closebufcache(w)
}
void
labelbufcache()
labelbufcache(void)
{
mvwprintw(wnd, 0, 0, "There are %d buffers using %d kBytes of memory.",
nbuf, bufkb);
@ -146,7 +145,7 @@ labelbufcache()
}
void
showbufcache()
showbufcache(void)
{
int tbuf, i, lastrow;
long tvalid, tsize;
@ -186,7 +185,7 @@ showbufcache()
}
int
initbufcache()
initbufcache(void)
{
if (namelist[X_NBUF].n_type == 0) {
if (kvm_nlist(kd, namelist)) {
@ -213,7 +212,7 @@ initbufcache()
}
void
fetchbufcache()
fetchbufcache(void)
{
int i, count;
struct buf *bp;
@ -271,7 +270,7 @@ fetchbufcache()
}
static void
vc_init()
vc_init(void)
{
int i;
@ -281,7 +280,7 @@ vc_init()
}
static void
ml_init()
ml_init(void)
{
struct ml_entry *ml;
@ -294,8 +293,7 @@ ml_init()
static struct vnode *
vc_lookup(vaddr)
struct vnode *vaddr;
vc_lookup(struct vnode *vaddr)
{
struct vnode *ret;
int i, oldest, match;
@ -332,9 +330,7 @@ vc_lookup(vaddr)
}
static struct mount *
ml_lookup(maddr, size, valid)
struct mount *maddr;
int size, valid;
ml_lookup(struct mount *maddr, int size, int valid)
{
struct ml_entry *ml;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmds.c,v 1.21 2000/06/05 21:48:25 mycroft Exp $ */
/* $NetBSD: cmds.c,v 1.22 2000/07/05 11:03:20 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/29/95";
#endif
__RCSID("$NetBSD: cmds.c,v 1.21 2000/06/05 21:48:25 mycroft Exp $");
__RCSID("$NetBSD: cmds.c,v 1.22 2000/07/05 11:03:20 ad Exp $");
#endif /* not lint */
#include <stdlib.h>
@ -49,11 +49,10 @@ __RCSID("$NetBSD: cmds.c,v 1.21 2000/06/05 21:48:25 mycroft Exp $");
#include "systat.h"
#include "extern.h"
void switch_mode __P((struct mode *p));
void switch_mode(struct mode *p);
void
command(cmd)
char *cmd;
command(char *cmd)
{
struct command *c;
struct mode *p;
@ -101,8 +100,7 @@ done:
}
void
switch_mode(p)
struct mode *p;
switch_mode(struct mode *p)
{
int switchfail;
@ -146,7 +144,7 @@ switch_mode(p)
}
void
status()
status(void)
{
error("Showing %s, refresh every %d seconds.", curmode->c_name, naptime);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmdtab.c,v 1.15 2000/04/11 01:18:35 jwise Exp $ */
/* $NetBSD: cmdtab.c,v 1.16 2000/07/05 11:03: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.15 2000/04/11 01:18:35 jwise Exp $");
__RCSID("$NetBSD: cmdtab.c,v 1.16 2000/07/05 11:03:21 ad Exp $");
#endif /* not lint */
#include "systat.h"
@ -59,6 +59,14 @@ struct command global_commands[] = {
{ 0 }
};
struct command icmp_commands[] = {
{ "boot", icmp_boot, "show total stats since boot"},
{ "run", icmp_run, "show running total stats"},
{ "time", icmp_time, "show stats for each sample time"},
{ "zero", icmp_zero, "re-zero running totals"},
{ 0 }
};
struct command iostat_commands[] = {
{ "bars", iostat_bars, "show io stats as a bar graph"},
{ "numbers", iostat_numbers, "show io stats numerically"},
@ -72,6 +80,34 @@ struct command iostat_commands[] = {
{ 0 }
};
struct command ip_commands[] = {
{ "boot", ip_boot, "show total stats since boot"},
{ "run", ip_run, "show running total stats"},
{ "time", ip_time, "show stats for each sample time"},
{ "zero", ip_zero, "re-zero running totals"},
{ 0 }
};
#ifdef INET6
struct command ip6_commands[] = {
{ "boot", ip6_boot, "show total stats since boot"},
{ "run", ip6_run, "show running total stats"},
{ "time", ip6_time, "show stats for each sample time"},
{ "zero", ip6_zero, "re-zero running totals"},
{ 0 }
};
#endif
#ifdef IPSEC
struct command ipsec_commands[] = {
{ "boot", ipsec_boot, "show total stats since boot"},
{ "run", ipsec_run, "show running total stats"},
{ "time", ipsec_time, "show stats for each sample time"},
{ "zero", ipsec_zero, "re-zero running totals"},
{ NULL, NULL, NULL },
};
#endif
struct command netstat_commands[] = {
{ "all", netstat_all, "include server sockets"},
{ "display", netstat_display, "show specified hosts or ports"},
@ -90,6 +126,14 @@ struct command ps_commands[] = {
{ 0 }
};
struct command tcp_commands[] = {
{ "boot", tcp_boot, "show total stats since boot"},
{ "run", tcp_run, "show running total stats"},
{ "time", tcp_time, "show stats for each sample time"},
{ "zero", tcp_zero, "re-zero running totals"},
{ NULL, NULL, NULL },
};
struct command vmstat_commands[] = {
{ "boot", vmstat_boot, "show total vm stats since boot"},
{ "run", vmstat_run, "show running total vm stats"},
@ -113,25 +157,25 @@ struct mode modes[] = {
initbufcache, openbufcache, closebufcache, 0,
CF_LOADAV },
{ "inet.icmp", showicmp, fetchicmp, labelicmp,
initicmp, openicmp, closeicmp, 0,
initicmp, openicmp, closeicmp, icmp_commands,
CF_LOADAV },
{ "inet.ip", showip, fetchip, labelip,
initip, openip, closeip, 0,
initip, openip, closeip, ip_commands,
CF_LOADAV },
{ "inet.tcp", showtcp, fetchtcp, labeltcp,
inittcp, opentcp, closetcp, 0,
inittcp, opentcp, closetcp, tcp_commands,
CF_LOADAV },
{ "inet.tcpsyn",showtcpsyn, fetchtcp, labeltcpsyn,
inittcp, opentcp, closetcp, 0,
inittcp, opentcp, closetcp, tcp_commands,
CF_LOADAV },
#ifdef INET6
{ "inet6.ip6", showip6, fetchip6, labelip6,
initip6, openip6, closeip6, 0,
initip6, openip6, closeip6, ip6_commands,
CF_LOADAV },
#endif
#ifdef IPSEC
{ "ipsec", showipsec, fetchipsec, labelipsec,
initipsec, openipsec, closeipsec, 0,
initipsec, openipsec, closeipsec, ipsec_commands,
CF_LOADAV },
#endif
{ "iostat", showiostat, fetchiostat, labeliostat,
@ -149,8 +193,8 @@ struct mode modes[] = {
{ "swap", showswap, fetchswap, labelswap,
initswap, openswap, closeswap, 0,
CF_LOADAV },
{ "vmstat", showkre, fetchkre, labelkre,
initkre, openkre, closekre, vmstat_commands,
{ "vmstat", showvmstat, fetchvmstat, labelvmstat,
initvmstat, openvmstat, closevmstat, vmstat_commands,
0 },
{ 0 }
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: disks.c,v 1.10 2000/06/05 21:48:26 mycroft Exp $ */
/* $NetBSD: disks.c,v 1.11 2000/07/05 11:03:21 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)disks.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: disks.c,v 1.10 2000/06/05 21:48:26 mycroft Exp $");
__RCSID("$NetBSD: disks.c,v 1.11 2000/07/05 11:03:21 ad Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -51,27 +51,26 @@ __RCSID("$NetBSD: disks.c,v 1.10 2000/06/05 21:48:26 mycroft Exp $");
#include "systat.h"
#include "extern.h"
static void dkselect __P((char *args, int truefalse, int selections[]));
static void dkselect(char *args, int truefalse, int selections[]);
void
disks_add (args)
char *args;
disks_add(char *args)
{
if (args)
dkselect(args, 1, dk_select);
}
void
disks_delete (args)
char *args;
disks_delete(char *args)
{
if (args)
dkselect(args, 0, dk_select);
}
void
disks_drives (args)
char *args;
disks_drives(char *args)
{
int i;
@ -82,9 +81,7 @@ disks_drives (args)
}
static void
dkselect(args, truefalse, selections)
char *args;
int truefalse, selections[];
dkselect(char *args, int truefalse, int selections[])
{
char *cp;
int i;

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.22 2000/06/04 16:06:25 thorpej Exp $ */
/* $NetBSD: extern.h,v 1.23 2000/07/05 11:03:23 ad Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -39,6 +39,8 @@
#include <fcntl.h>
#include <kvm.h>
#define ADJINETCTR(c, o, n, e) (c.e = n.e - o.e)
extern struct command global_commands[];
extern struct mode *curmode;
extern struct mode modes[];
@ -67,126 +69,148 @@ struct inpcb;
struct in6pcb;
#endif
int checkhost __P((struct inpcb *));
int checkport __P((struct inpcb *));
int checkhost(struct inpcb *);
int checkport(struct inpcb *);
#ifdef INET6
int checkhost6 __P((struct in6pcb *));
int checkport6 __P((struct in6pcb *));
int checkhost6(struct in6pcb *);
int checkport6(struct in6pcb *);
#endif
void closebufcache __P((WINDOW *));
void closeicmp __P ((WINDOW *));
void closeiostat __P((WINDOW *));
void closeip __P ((WINDOW *));
void closekre __P((WINDOW *));
void closembufs __P((WINDOW *));
void closenetstat __P((WINDOW *));
void closepigs __P((WINDOW *));
void closeswap __P((WINDOW *));
void closetcp __P ((WINDOW *));
void command __P((char *));
void die __P((int));
void disks_add __P((char *));
void disks_delete __P((char *));
void disks_drives __P((char *));
void display __P((int));
int dkinit __P((int, gid_t));
void error __P((const char *fmt, ...));
void fetchbufcache __P((void));
void fetchicmp __P((void));
void fetchiostat __P((void));
void fetchip __P((void));
void fetchkre __P((void));
void fetchmbufs __P((void));
void fetchnetstat __P((void));
void fetchpigs __P((void));
void fetchswap __P((void));
void fetchtcp __P((void));
int fetch_cptime __P((u_int64_t *));
void global_help __P((char *args));
void global_interval __P((char *args));
void global_load __P((char *args));
void global_quit __P((char *args));
void global_stop __P((char *args));
int initbufcache __P((void));
int initicmp __P((void));
int initiostat __P((void));
int initip __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));
void iostat_bars __P((char *));
void iostat_numbers __P((char *));
void iostat_secs __P((char *));
int keyboard __P((void)) __attribute__((__noreturn__));
ssize_t kvm_ckread __P((void *, void *, size_t));
void labelbufcache __P((void));
void labelicmp __P((void));
void labeliostat __P((void));
void labelip __P((void));
void labelkre __P((void));
void labelmbufs __P((void));
void labelnetstat __P((void));
void labelpigs __P((void));
void labelps __P((void));
void labels __P((void));
void labelswap __P((void));
void labeltcp __P((void));
void labeltcpsyn __P((void));
void netstat_all __P((char *));
void netstat_display __P((char *));
void netstat_ignore __P((char *));
void netstat_names __P((char *));
void netstat_numbers __P((char *));
void netstat_reset __P((char *));
void netstat_show __P((char *));
void netstat_tcp __P((char *));
void netstat_udp __P((char *));
void nlisterr __P((struct nlist []));
WINDOW *openbufcache __P((void));
WINDOW *openicmp __P((void));
WINDOW *openiostat __P((void));
WINDOW *openip __P((void));
WINDOW *openkre __P((void));
WINDOW *openmbufs __P((void));
WINDOW *opennetstat __P((void));
WINDOW *openpigs __P((void));
WINDOW *openswap __P((void));
WINDOW *opentcp __P((void));
void ps_user __P((char *));
void redraw __P((int));
void showbufcache __P((void));
void showicmp __P((void));
void showiostat __P((void));
void showip __P((void));
void showkre __P((void));
void showmbufs __P((void));
void shownetstat __P((void));
void showpigs __P((void));
void showps __P((void));
void showswap __P((void));
void showtcp __P((void));
void showtcpsyn __P((void));
void status __P((void));
void vmstat_boot __P((char *args));
void vmstat_run __P((char *args));
void vmstat_time __P((char *args));
void vmstat_zero __P((char *args));
void closebufcache(WINDOW *);
void closeicmp(WINDOW *);
void closeiostat(WINDOW *);
void closeip(WINDOW *);
void closevmstat(WINDOW *);
void closembufs(WINDOW *);
void closenetstat(WINDOW *);
void closepigs(WINDOW *);
void closeswap(WINDOW *);
void closetcp(WINDOW *);
void command(char *);
void die(int);
void disks_add(char *);
void disks_delete(char *);
void disks_drives(char *);
void display(int);
int dkinit(int, gid_t);
void error(const char *, ...);
void fetchbufcache(void);
void fetchicmp(void);
void fetchiostat(void);
void fetchip(void);
void fetchvmstat(void);
void fetchmbufs(void);
void fetchnetstat(void);
void fetchpigs(void);
void fetchswap(void);
void fetchtcp(void);
int fetch_cptime(u_int64_t *);
void global_help(char *);
void global_interval(char *);
void global_load(char *);
void global_quit(char *);
void global_stop(char *);
void icmp_boot(char *);
void icmp_run(char *);
void icmp_time(char *);
void icmp_zero(char *);
int initbufcache(void);
int initicmp(void);
int initiostat(void);
int initip(void);
int initvmstat(void);
int initmbufs(void);
int initnetstat(void);
int initpigs(void);
int initswap(void);
int inittcp(void);
void iostat_bars(char *);
void iostat_numbers(char *);
void iostat_secs(char *);
void ip_boot(char *);
void ip_run(char *);
void ip_time(char *);
void ip_zero(char *);
int keyboard(void) __attribute__((__noreturn__));
ssize_t kvm_ckread(void *, void *, size_t);
void labelbufcache(void);
void labelicmp(void);
void labeliostat(void);
void labelip(void);
void labelvmstat(void);
void labelmbufs(void);
void labelnetstat(void);
void labelpigs(void);
void labelps(void);
void labels(void);
void labelswap(void);
void labeltcp(void);
void labeltcpsyn(void);
void netstat_all(char *);
void netstat_display(char *);
void netstat_ignore(char *);
void netstat_names(char *);
void netstat_numbers(char *);
void netstat_reset(char *);
void netstat_show(char *);
void netstat_tcp(char *);
void netstat_udp(char *);
void nlisterr(struct nlist []);
WINDOW *openbufcache(void);
WINDOW *openicmp(void);
WINDOW *openiostat(void);
WINDOW *openip(void);
WINDOW *openvmstat(void);
WINDOW *openmbufs(void);
WINDOW *opennetstat(void);
WINDOW *openpigs(void);
WINDOW *openswap(void);
WINDOW *opentcp(void);
void ps_user(char *);
void redraw(int);
void showbufcache(void);
void showicmp(void);
void showiostat(void);
void showip(void);
void showvmstat(void);
void showmbufs(void);
void shownetstat(void);
void showpigs(void);
void showps(void);
void showswap(void);
void showtcp(void);
void showtcpsyn(void);
void status(void);
void tcp_boot(char *);
void tcp_run(char *);
void tcp_time(char *);
void tcp_zero(char *);
void vmstat_boot(char *);
void vmstat_run(char *);
void vmstat_time(char *);
void vmstat_zero(char *);
#ifdef INET6
void closeip6 __P ((WINDOW *));
void fetchip6 __P((void));
int initip6 __P((void));
void labelip6 __P((void));
WINDOW *openip6 __P((void));
void showip6 __P((void));
void closeip6(WINDOW *);
void fetchip6(void);
int initip6(void);
void labelip6(void);
WINDOW *openip6(void);
void showip6(void);
void ip6_boot(char *);
void ip6_run(char *);
void ip6_time(char *);
void ip6_zero(char *);
#endif
#ifdef IPSEC
void closeipsec __P ((WINDOW *));
void fetchipsec __P((void));
int initipsec __P((void));
void labelipsec __P((void));
WINDOW *openipsec __P((void));
void showipsec __P((void));
void closeipsec(WINDOW *);
void fetchipsec(void);
int initipsec(void);
void labelipsec(void);
WINDOW *openipsec(void);
void showipsec(void);
void ipsec_boot(char *);
void ipsec_run(char *);
void ipsec_time(char *);
void ipsec_zero(char *);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: fetch.c,v 1.6 2000/06/04 16:06:25 thorpej Exp $ */
/* $NetBSD: fetch.c,v 1.7 2000/07/05 11:03:21 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)fetch.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: fetch.c,v 1.6 2000/06/04 16:06:25 thorpej Exp $");
__RCSID("$NetBSD: fetch.c,v 1.7 2000/07/05 11:03:21 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -49,9 +49,7 @@ __RCSID("$NetBSD: fetch.c,v 1.6 2000/06/04 16:06:25 thorpej Exp $");
#include "extern.h"
ssize_t
kvm_ckread(a, b, l)
void *a, *b;
size_t l;
kvm_ckread(void *a, void *b, size_t l)
{
if (kvm_read(kd, (u_long)a, b, l) != l) {
if (verbose)
@ -62,8 +60,7 @@ kvm_ckread(a, b, l)
}
int
fetch_cptime(cptime)
u_int64_t *cptime;
fetch_cptime(u_int64_t *cptime)
{
size_t ssize;
int mib[2];

View File

@ -1,4 +1,4 @@
/* $NetBSD: globalcmds.c,v 1.7 2000/01/08 23:34:17 itojun Exp $ */
/* $NetBSD: globalcmds.c,v 1.8 2000/07/05 11:03:21 ad Exp $ */
/*-
* Copyright (c) 1999
@ -32,6 +32,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: globalcmds.c,v 1.8 2000/07/05 11:03:21 ad Exp $");
#endif /* not lint */
#include <curses.h>
#include <stdlib.h>
#include <string.h>
@ -39,13 +44,10 @@
#include "systat.h"
#include "extern.h"
static char *shortname __P((const char *, const char *));
static char *shortname(const char *, const char *);
static char *
shortname(key, s)
const char *key;
const char *s;
shortname(const char *key, const char *s)
{
char *p, *q;
size_t l;
@ -67,8 +69,7 @@ shortname(key, s)
}
void
global_help(args)
char *args;
global_help(char *args)
{
int col, len;
struct mode *p;
@ -111,8 +112,7 @@ global_help(args)
}
void
global_interval(args)
char *args;
global_interval(char *args)
{
int interval;
@ -135,8 +135,7 @@ global_interval(args)
void
global_load(args)
char *args;
global_load(char *args)
{
(void)getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
mvprintw(CMDLINE, 0, "%4.1f %4.1f %4.1f",
@ -145,15 +144,13 @@ global_load(args)
}
void
global_quit(args)
char *args;
global_quit(char *args)
{
die(0);
}
void
global_stop(args)
char *args;
global_stop(char *args)
{
alarm(0);
mvaddstr(CMDLINE, 0, "Refresh disabled.");

View File

@ -1,7 +1,7 @@
/* $NetBSD: icmp.c,v 1.4 2000/06/13 13:37:12 ad Exp $ */
/* $NetBSD: icmp.c,v 1.5 2000/07/05 11:03:21 ad Exp $ */
/*
* Copyright (c) 1999 Andrew Doran <ad@NetBSD.org>
* Copyright (c) 1999, 2000 Andrew Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: icmp.c,v 1.4 2000/06/13 13:37:12 ad Exp $");
__RCSID("$NetBSD: icmp.c,v 1.5 2000/07/05 11:03:21 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -56,11 +56,20 @@ __RCSID("$NetBSD: icmp.c,v 1.4 2000/06/13 13:37:12 ad Exp $");
#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, "%9llu", (unsigned long long)stats.stat)
mvwprintw(wnd, row, col, "%9llu", (unsigned long long)curstat.stat)
#define SHOW2(type, row) SHOW(icps_inhist[type], row, 0); \
SHOW(icps_outhist[type], row, 35)
static struct icmpstat stats;
enum update {
UPDATE_TIME,
UPDATE_BOOT,
UPDATE_RUN,
};
static enum update update = UPDATE_TIME;
static struct icmpstat curstat;
static struct icmpstat newstat;
static struct icmpstat oldstat;
static struct nlist namelist[] = {
{ "_icmpstat" },
@ -75,8 +84,7 @@ openicmp(void)
}
void
closeicmp(w)
WINDOW *w;
closeicmp(WINDOW *w)
{
if (w != NULL) {
@ -92,11 +100,11 @@ labelicmp(void)
wmove(wnd, 0, 0); wclrtoeol(wnd);
mvwprintw(wnd, 1, 0, "------------ ICMP input -------------");
mvwprintw(wnd, 1, 38, "------------- ICMP output -------------");
mvwprintw(wnd, 1, 0, "------------ ICMP input -----------");
mvwprintw(wnd, 1, 36, "------------- ICMP output ---------------");
mvwprintw(wnd, 8, 0, "---------- Input histogram ----------");
mvwprintw(wnd, 8, 38, "---------- Output histogram -----------");
mvwprintw(wnd, 8, 0, "---------- Input histogram --------");
mvwprintw(wnd, 8, 36, "---------- Output histogram -------------");
LHD(3, "with bad code");
LHD(4, "with bad length");
@ -126,12 +134,12 @@ showicmp(void)
int i;
for (i = tin = tout = 0; i <= ICMP_MAXTYPE; i++) {
tin += stats.icps_inhist[i];
tout += stats.icps_outhist[i];
tin += curstat.icps_inhist[i];
tout += curstat.icps_outhist[i];
}
tin += stats.icps_badcode + stats.icps_badlen + stats.icps_checksum +
stats.icps_tooshort;
tin += curstat.icps_badcode + curstat.icps_badlen +
curstat.icps_checksum + curstat.icps_tooshort;
mvwprintw(wnd, 2, 0, "%9lu", tin);
mvwprintw(wnd, 2, 35, "%9lu", tout);
@ -175,6 +183,60 @@ initicmp(void)
void
fetchicmp(void)
{
int i;
KREAD((void *)namelist[0].n_value, &stats, sizeof(stats));
KREAD((void *)namelist[0].n_value, &newstat, sizeof(newstat));
ADJINETCTR(curstat, oldstat, newstat, icps_badcode);
ADJINETCTR(curstat, oldstat, newstat, icps_badlen);
ADJINETCTR(curstat, oldstat, newstat, icps_checksum);
ADJINETCTR(curstat, oldstat, newstat, icps_tooshort);
ADJINETCTR(curstat, oldstat, newstat, icps_error);
ADJINETCTR(curstat, oldstat, newstat, icps_oldshort);
ADJINETCTR(curstat, oldstat, newstat, icps_oldicmp);
ADJINETCTR(curstat, oldstat, newstat, icps_reflect);
for (i = 0; i <= ICMP_MAXTYPE; i++) {
ADJINETCTR(curstat, oldstat, newstat, icps_inhist[i]);
ADJINETCTR(curstat, oldstat, newstat, icps_outhist[i]);
}
if (update == UPDATE_TIME)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}
void
icmp_boot(char *args)
{
memset(&oldstat, 0, sizeof(oldstat));
update = UPDATE_BOOT;
}
void
icmp_run(char *args)
{
if (update != UPDATE_RUN) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_RUN;
}
}
void
icmp_time(char *args)
{
if (update != UPDATE_TIME) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_TIME;
}
}
void
icmp_zero(char *args)
{
if (update == UPDATE_RUN)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: iostat.c,v 1.15 2000/06/04 18:29:13 mycroft Exp $ */
/* $NetBSD: iostat.c,v 1.16 2000/07/05 11:03:21 ad Exp $ */
/*
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: iostat.c,v 1.15 2000/06/04 18:29:13 mycroft Exp $");
__RCSID("$NetBSD: iostat.c,v 1.16 2000/07/05 11:03:21 ad Exp $");
#endif not lint
#include <sys/param.h>
@ -62,23 +62,22 @@ static double etime;
static int numbers = 0; /* default display bar graphs */
static int secs = 0; /* default seconds shown */
static int barlabels __P((int));
static void histogram __P((double, int, double));
static int numlabels __P((int));
static int stats __P((int, int, int));
static void stat1 __P((int, int));
static int barlabels(int);
static void histogram(double, int, double);
static int numlabels(int);
static int stats(int, int, int);
static void stat1(int, int);
WINDOW *
openiostat()
openiostat(void)
{
return (subwin(stdscr, LINES-1-5, 0, 5, 0));
}
void
closeiostat(w)
WINDOW *w;
closeiostat(WINDOW *w)
{
if (w == NULL)
@ -89,7 +88,7 @@ closeiostat(w)
}
int
initiostat()
initiostat(void)
{
extern gid_t egid;
@ -99,7 +98,7 @@ initiostat()
}
void
fetchiostat()
fetchiostat(void)
{
if (dk_ndrive == 0)
@ -110,7 +109,7 @@ fetchiostat()
#define INSET 14
void
labeliostat()
labeliostat(void)
{
int row;
@ -134,8 +133,7 @@ labeliostat()
}
static int
numlabels(row)
int row;
numlabels(int row)
{
int i, col, regions, ndrives;
@ -173,8 +171,7 @@ numlabels(row)
}
static int
barlabels(row)
int row;
barlabels(int row)
{
int i;
@ -193,9 +190,8 @@ barlabels(row)
return (row);
}
void
showiostat()
showiostat(void)
{
int i, row, col;
@ -249,8 +245,7 @@ showiostat()
}
static int
stats(row, col, dn)
int row, col, dn;
stats(int row, int col, int dn)
{
double atime, words;
@ -277,8 +272,7 @@ stats(row, col, dn)
}
static void
stat1(row, o)
int row, o;
stat1(int row, int o)
{
int i;
double time;
@ -294,10 +288,7 @@ stat1(row, o)
}
static void
histogram(val, colwidth, scale)
double val;
int colwidth;
double scale;
histogram(double val, int colwidth, double scale)
{
char buf[10];
int k;
@ -318,8 +309,7 @@ histogram(val, colwidth, scale)
}
void
iostat_bars (args)
char *args;
iostat_bars(char *args)
{
numbers = 0;
wclear(wnd);
@ -328,8 +318,7 @@ iostat_bars (args)
}
void
iostat_numbers (args)
char *args;
iostat_numbers(char *args)
{
numbers = 1;
wclear(wnd);
@ -338,8 +327,7 @@ iostat_numbers (args)
}
void
iostat_secs (args)
char *args;
iostat_secs(char *args)
{
secs = !secs;
wclear(wnd);

View File

@ -1,7 +1,7 @@
/* $NetBSD: ip.c,v 1.7 2000/06/13 13:37:12 ad Exp $ */
/* $NetBSD: ip.c,v 1.8 2000/07/05 11:03:21 ad Exp $ */
/*
* Copyright (c) 1999 Andrew Doran <ad@NetBSD.org>
* Copyright (c) 1999, 2000 Andrew Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ip.c,v 1.7 2000/06/13 13:37:12 ad Exp $");
__RCSID("$NetBSD: ip.c,v 1.8 2000/07/05 11:03:21 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -63,7 +63,16 @@ struct mystat {
struct udpstat u;
};
enum update {
UPDATE_TIME,
UPDATE_BOOT,
UPDATE_RUN,
};
static enum update update = UPDATE_TIME;
static struct mystat curstat;
static struct mystat oldstat;
static struct mystat newstat;
static struct nlist namelist[] = {
{ "_ipstat" },
@ -79,8 +88,7 @@ openip(void)
}
void
closeip(w)
WINDOW *w;
closeip(WINDOW *w)
{
if (w != NULL) {
@ -201,6 +209,80 @@ void
fetchip(void)
{
KREAD((void *)namelist[0].n_value, &curstat.i, sizeof(curstat.i));
KREAD((void *)namelist[1].n_value, &curstat.u, sizeof(curstat.u));
KREAD((void *)namelist[0].n_value, &newstat.i,
sizeof(newstat.i));
KREAD((void *)namelist[1].n_value, &newstat.u,
sizeof(newstat.u));
ADJINETCTR(curstat, oldstat, newstat, i.ips_total);
ADJINETCTR(curstat, oldstat, newstat, i.ips_delivered);
ADJINETCTR(curstat, oldstat, newstat, i.ips_badsum);
ADJINETCTR(curstat, oldstat, newstat, i.ips_tooshort);
ADJINETCTR(curstat, oldstat, newstat, i.ips_toosmall);
ADJINETCTR(curstat, oldstat, newstat, i.ips_badhlen);
ADJINETCTR(curstat, oldstat, newstat, i.ips_badlen);
ADJINETCTR(curstat, oldstat, newstat, i.ips_badvers);
ADJINETCTR(curstat, oldstat, newstat, i.ips_toolong);
ADJINETCTR(curstat, oldstat, newstat, i.ips_badoptions);
ADJINETCTR(curstat, oldstat, newstat, i.ips_localout);
ADJINETCTR(curstat, oldstat, newstat, i.ips_odropped);
ADJINETCTR(curstat, oldstat, newstat, i.ips_ofragments);
ADJINETCTR(curstat, oldstat, newstat, i.ips_cantfrag);
ADJINETCTR(curstat, oldstat, newstat, i.ips_noroute);
ADJINETCTR(curstat, oldstat, newstat, i.ips_rawout);
ADJINETCTR(curstat, oldstat, newstat, i.ips_fragments);
ADJINETCTR(curstat, oldstat, newstat, i.ips_fragdropped);
ADJINETCTR(curstat, oldstat, newstat, i.ips_fragtimeout);
ADJINETCTR(curstat, oldstat, newstat, i.ips_reassembled);
ADJINETCTR(curstat, oldstat, newstat, i.ips_forward);
ADJINETCTR(curstat, oldstat, newstat, i.ips_fastforward);
ADJINETCTR(curstat, oldstat, newstat, i.ips_cantforward);
ADJINETCTR(curstat, oldstat, newstat, i.ips_redirectsent);
ADJINETCTR(curstat, oldstat, newstat, u.udps_opackets);
ADJINETCTR(curstat, oldstat, newstat, u.udps_ipackets);
ADJINETCTR(curstat, oldstat, newstat, u.udps_hdrops);
ADJINETCTR(curstat, oldstat, newstat, u.udps_badsum);
ADJINETCTR(curstat, oldstat, newstat, u.udps_badlen);
ADJINETCTR(curstat, oldstat, newstat, u.udps_noport);
ADJINETCTR(curstat, oldstat, newstat, u.udps_noportbcast);
ADJINETCTR(curstat, oldstat, newstat, u.udps_fullsock);
if (update == UPDATE_TIME)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}
void
ip_boot(char *args)
{
memset(&oldstat, 0, sizeof(oldstat));
update = UPDATE_BOOT;
}
void
ip_run(char *args)
{
if (update != UPDATE_RUN) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_RUN;
}
}
void
ip_time(char *args)
{
if (update != UPDATE_TIME) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_TIME;
}
}
void
ip_zero(char *args)
{
if (update == UPDATE_RUN)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: ip6.c,v 1.4 2000/06/13 13:37:13 ad Exp $ */
/* $NetBSD: ip6.c,v 1.5 2000/07/05 11:03:22 ad Exp $ */
/*
* Copyright (c) 1999 Andrew Doran <ad@NetBSD.org>
* Copyright (c) 1999, 2000 Andrew Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ip6.c,v 1.4 2000/06/13 13:37:13 ad Exp $");
__RCSID("$NetBSD: ip6.c,v 1.5 2000/07/05 11:03:22 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -54,13 +54,18 @@ __RCSID("$NetBSD: ip6.c,v 1.4 2000/06/13 13:37:13 ad Exp $");
#define LHD(row, str) mvwprintw(wnd, row, 10, str)
#define RHD(row, str) mvwprintw(wnd, row, 45, str);
#define SHOW(stat, row, col) \
mvwprintw(wnd, row, col, "%9llu", (unsigned long long)curstat.stat)
mvwprintw(wnd, row, col, "%9llu", (unsigned long long)curstat.##stat)
struct mystat {
struct ip6stat i;
enum update {
UPDATE_TIME,
UPDATE_BOOT,
UPDATE_RUN,
};
static struct mystat curstat;
static enum update update = UPDATE_TIME;
static struct ip6stat curstat;
static struct ip6stat newstat;
static struct ip6stat oldstat;
static struct nlist namelist[] = {
{ "_ip6stat" },
@ -75,8 +80,7 @@ openip6(void)
}
void
closeip6(w)
WINDOW *w;
closeip6(WINDOW *w)
{
if (w != NULL) {
@ -143,52 +147,52 @@ showip6(void)
m2m = 0;
for (i = 0;
i < sizeof(curstat.i.ip6s_m2m)/sizeof(curstat.i.ip6s_m2m[0]);
i < sizeof(curstat.ip6s_m2m)/sizeof(curstat.ip6s_m2m[0]);
i++) {
m2m += curstat.i.ip6s_m2m[i];
m2m += curstat.ip6s_m2m[i];
}
#endif
SHOW(i.ip6s_total, 0, 0);
SHOW(i.ip6s_toosmall, 1, 0);
SHOW(i.ip6s_tooshort, 2, 0);
SHOW(i.ip6s_badoptions, 3, 0);
SHOW(i.ip6s_badvers, 4, 0);
SHOW(i.ip6s_exthdrtoolong, 5, 0);
SHOW(i.ip6s_delivered, 6, 0);
SHOW(i.ip6s_notmember, 7, 0);
SHOW(i.ip6s_toomanyhdr, 8, 0);
SHOW(i.ip6s_nogif, 9, 0);
SHOW(ip6s_total, 0, 0);
SHOW(ip6s_toosmall, 1, 0);
SHOW(ip6s_tooshort, 2, 0);
SHOW(ip6s_badoptions, 3, 0);
SHOW(ip6s_badvers, 4, 0);
SHOW(ip6s_exthdrtoolong, 5, 0);
SHOW(ip6s_delivered, 6, 0);
SHOW(ip6s_notmember, 7, 0);
SHOW(ip6s_toomanyhdr, 8, 0);
SHOW(ip6s_nogif, 9, 0);
SHOW(i.ip6s_fragments, 11, 0);
SHOW(i.ip6s_fragdropped, 12, 0);
SHOW(i.ip6s_fragtimeout, 13, 0);
SHOW(i.ip6s_fragoverflow, 14, 0);
SHOW(i.ip6s_reassembled, 15, 0);
SHOW(ip6s_fragments, 11, 0);
SHOW(ip6s_fragdropped, 12, 0);
SHOW(ip6s_fragtimeout, 13, 0);
SHOW(ip6s_fragoverflow, 14, 0);
SHOW(ip6s_reassembled, 15, 0);
#if 0
SHOW(i.ip6s_m1, 17, 0);
SHOW(i.ip6s_mext1, 18, 0);
SHOW(i.ip6s_mext2m, 19, 0);
SHOW(ip6s_m1, 17, 0);
SHOW(ip6s_mext1, 18, 0);
SHOW(ip6s_mext2m, 19, 0);
mvwprintw(wnd, 20, 0, "%9llu", (unsigned long long)m2m);
#endif
SHOW(i.ip6s_forward, 0, 35);
SHOW(i.ip6s_cantforward, 1, 35);
SHOW(i.ip6s_redirectsent, 2, 35);
SHOW(ip6s_forward, 0, 35);
SHOW(ip6s_cantforward, 1, 35);
SHOW(ip6s_redirectsent, 2, 35);
SHOW(i.ip6s_localout, 4, 35);
SHOW(i.ip6s_rawout, 5, 35);
SHOW(i.ip6s_odropped, 6, 35);
SHOW(i.ip6s_noroute, 7, 35);
SHOW(i.ip6s_fragmented, 8, 35);
SHOW(i.ip6s_ofragments, 9, 35);
SHOW(i.ip6s_cantfrag, 10, 35);
SHOW(ip6s_localout, 4, 35);
SHOW(ip6s_rawout, 5, 35);
SHOW(ip6s_odropped, 6, 35);
SHOW(ip6s_noroute, 7, 35);
SHOW(ip6s_fragmented, 8, 35);
SHOW(ip6s_ofragments, 9, 35);
SHOW(ip6s_cantfrag, 10, 35);
SHOW(i.ip6s_badscope, 12, 35);
SHOW(i.ip6s_pulldown, 13, 35);
SHOW(i.ip6s_pulldown_alloc, 14, 35);
SHOW(i.ip6s_pulldown_copy, 15, 35);
SHOW(ip6s_badscope, 12, 35);
SHOW(ip6s_pulldown, 13, 35);
SHOW(ip6s_pulldown_alloc, 14, 35);
SHOW(ip6s_pulldown_copy, 15, 35);
}
int
@ -213,5 +217,75 @@ void
fetchip6(void)
{
KREAD((void *)namelist[0].n_value, &curstat.i, sizeof(curstat.i));
ADJINETCTR(curstat, oldstat, newstat, ip6s_total);
ADJINETCTR(curstat, oldstat, newstat, ip6s_toosmall);
ADJINETCTR(curstat, oldstat, newstat, ip6s_tooshort);
ADJINETCTR(curstat, oldstat, newstat, ip6s_badoptions);
ADJINETCTR(curstat, oldstat, newstat, ip6s_badvers);
ADJINETCTR(curstat, oldstat, newstat, ip6s_exthdrtoolong);
ADJINETCTR(curstat, oldstat, newstat, ip6s_delivered);
ADJINETCTR(curstat, oldstat, newstat, ip6s_notmember);
ADJINETCTR(curstat, oldstat, newstat, ip6s_toomanyhdr);
ADJINETCTR(curstat, oldstat, newstat, ip6s_nogif);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragments);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragdropped);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragtimeout);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragoverflow);
ADJINETCTR(curstat, oldstat, newstat, ip6s_reassembled);
ADJINETCTR(curstat, oldstat, newstat, ip6s_m1);
ADJINETCTR(curstat, oldstat, newstat, ip6s_mext1);
ADJINETCTR(curstat, oldstat, newstat, ip6s_mext2m);
ADJINETCTR(curstat, oldstat, newstat, ip6s_forward);
ADJINETCTR(curstat, oldstat, newstat, ip6s_cantforward);
ADJINETCTR(curstat, oldstat, newstat, ip6s_redirectsent);
ADJINETCTR(curstat, oldstat, newstat, ip6s_localout);
ADJINETCTR(curstat, oldstat, newstat, ip6s_rawout);
ADJINETCTR(curstat, oldstat, newstat, ip6s_odropped);
ADJINETCTR(curstat, oldstat, newstat, ip6s_noroute);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragmented);
ADJINETCTR(curstat, oldstat, newstat, ip6s_ofragments);
ADJINETCTR(curstat, oldstat, newstat, ip6s_cantfrag);
ADJINETCTR(curstat, oldstat, newstat, ip6s_badscope);
ADJINETCTR(curstat, oldstat, newstat, ip6s_pulldown);
ADJINETCTR(curstat, oldstat, newstat, ip6s_pulldown_alloc);
ADJINETCTR(curstat, oldstat, newstat, ip6s_pulldown_copy);
if (update == UPDATE_TIME)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}
void
ip6_boot(char *args)
{
memset(&oldstat, 0, sizeof(oldstat));
update = UPDATE_BOOT;
}
void
ip6_run(char *args)
{
if (update != UPDATE_RUN) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_RUN;
}
}
void
ip6_time(char *args)
{
if (update != UPDATE_TIME) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_TIME;
}
}
void
ip6_zero(char *args)
{
if (update == UPDATE_RUN)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: ipsec.c,v 1.4 2000/06/13 13:37:13 ad Exp $ */
/* $NetBSD: ipsec.c,v 1.5 2000/07/05 11:03:22 ad Exp $ */
/*
* Copyright (c) 1999 Andrew Doran <ad@NetBSD.org>
* Copyright (c) 1999, 2000 Andrew Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ipsec.c,v 1.4 2000/06/13 13:37:13 ad Exp $");
__RCSID("$NetBSD: ipsec.c,v 1.5 2000/07/05 11:03:22 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -62,7 +62,16 @@ struct mystat {
#endif
};
enum update {
UPDATE_TIME,
UPDATE_BOOT,
UPDATE_RUN,
};
static enum update update = UPDATE_TIME;
static struct mystat curstat;
static struct mystat newstat;
static struct mystat oldstat;
static struct nlist namelist[] = {
{ "_ipsecstat" },
@ -80,8 +89,7 @@ openipsec(void)
}
void
closeipsec(w)
WINDOW *w;
closeipsec(WINDOW *w)
{
if (w != NULL) {
@ -206,13 +214,83 @@ fetchipsec(void)
{
if (namelist[0].n_type) {
KREAD((void *)namelist[0].n_value, &curstat.i4,
sizeof(curstat.i4));
KREAD((void *)namelist[0].n_value, &newstat.i4,
sizeof(newstat.i4));
ADJINETCTR(curstat, oldstat, newstat, i4.in_success);
ADJINETCTR(curstat, oldstat, newstat, i4.in_polvio);
ADJINETCTR(curstat, oldstat, newstat, i4.in_nosa);
ADJINETCTR(curstat, oldstat, newstat, i4.in_inval);
ADJINETCTR(curstat, oldstat, newstat, i4.in_badspi);
ADJINETCTR(curstat, oldstat, newstat, i4.in_ahreplay);
ADJINETCTR(curstat, oldstat, newstat, i4.in_espreplay);
ADJINETCTR(curstat, oldstat, newstat, i4.in_ahauthsucc);
ADJINETCTR(curstat, oldstat, newstat, i4.in_ahauthfail);
ADJINETCTR(curstat, oldstat, newstat, i4.out_success);
ADJINETCTR(curstat, oldstat, newstat, i4.out_polvio);
ADJINETCTR(curstat, oldstat, newstat, i4.out_nosa);
ADJINETCTR(curstat, oldstat, newstat, i4.out_inval);
ADJINETCTR(curstat, oldstat, newstat, i4.out_noroute);
}
#ifdef INET6
if (namelist[1].n_type) {
KREAD((void *)namelist[1].n_value, &curstat.i6,
sizeof(curstat.i6));
KREAD((void *)namelist[1].n_value, &newstat.i6,
sizeof(newstat.i6));
ADJINETCTR(curstat, oldstat, newstat, i6.in_success);
ADJINETCTR(curstat, oldstat, newstat, i6.in_polvio);
ADJINETCTR(curstat, oldstat, newstat, i6.in_nosa);
ADJINETCTR(curstat, oldstat, newstat, i6.in_inval);
ADJINETCTR(curstat, oldstat, newstat, i6.in_badspi);
ADJINETCTR(curstat, oldstat, newstat, i6.in_ahreplay);
ADJINETCTR(curstat, oldstat, newstat, i6.in_espreplay);
ADJINETCTR(curstat, oldstat, newstat, i6.in_ahauthsucc);
ADJINETCTR(curstat, oldstat, newstat, i6.in_ahauthfail);
ADJINETCTR(curstat, oldstat, newstat, i6.out_success);
ADJINETCTR(curstat, oldstat, newstat, i6.out_polvio);
ADJINETCTR(curstat, oldstat, newstat, i6.out_nosa);
ADJINETCTR(curstat, oldstat, newstat, i6.out_inval);
ADJINETCTR(curstat, oldstat, newstat, i6.out_noroute);
}
#endif
if (update == UPDATE_TIME)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}
void
ipsec_boot(char *args)
{
memset(&oldstat, 0, sizeof(oldstat));
update = UPDATE_BOOT;
}
void
ipsec_run(char *args)
{
if (update != UPDATE_RUN) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_RUN;
}
}
void
ipsec_time(char *args)
{
if (update != UPDATE_TIME) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_TIME;
}
}
void
ipsec_zero(char *args)
{
if (update == UPDATE_RUN)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: keyboard.c,v 1.11 2000/04/11 01:01:26 jwise Exp $ */
/* $NetBSD: keyboard.c,v 1.12 2000/07/05 11:03:22 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)keyboard.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: keyboard.c,v 1.11 2000/04/11 01:01:26 jwise Exp $");
__RCSID("$NetBSD: keyboard.c,v 1.12 2000/07/05 11:03:22 ad Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -53,7 +53,7 @@ __RCSID("$NetBSD: keyboard.c,v 1.11 2000/04/11 01:01:26 jwise Exp $");
#include "extern.h"
int
keyboard()
keyboard(void)
{
char ch, rch, *line;
int i, linesz;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.25 2000/06/04 18:29:13 mycroft Exp $ */
/* $NetBSD: main.c,v 1.26 2000/07/05 11:03:22 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1992, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: main.c,v 1.25 2000/06/04 18:29:13 mycroft Exp $");
__RCSID("$NetBSD: main.c,v 1.26 2000/07/05 11:03:22 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -54,6 +54,7 @@ __RCSID("$NetBSD: main.c,v 1.25 2000/06/04 18:29:13 mycroft Exp $");
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "systat.h"
#include "extern.h"
@ -85,15 +86,13 @@ int CMDLINE;
static WINDOW *wload; /* one line window for load average */
static void usage __P((void));
int main __P((int, char **));
static void usage(void);
int main(int, char **);
gid_t egid; /* XXX needed by initiostat() and initkre() */
int
main(argc, argv)
int argc;
char **argv;
main(int argc, char **argv)
{
int ch;
char errbuf[_POSIX2_LINE_MAX];
@ -221,7 +220,7 @@ main(argc, argv)
}
static void
usage()
usage(void)
{
fprintf(stderr, "usage: systat [-n] [-M core] [-N system] [-w wait] "
"[display] [refresh-interval]\n");
@ -230,7 +229,7 @@ usage()
void
labels()
labels(void)
{
if (curmode->c_flags & CF_LOADAV) {
mvaddstr(2, 20,
@ -245,8 +244,7 @@ labels()
}
void
display(signo)
int signo;
display(int signo)
{
int j;
sigset_t set;
@ -287,8 +285,7 @@ display(signo)
}
void
redraw(signo)
int signo;
redraw(int signo)
{
sigset_t set;
@ -301,8 +298,7 @@ redraw(signo)
}
void
die(signo)
int signo;
die(int signo)
{
move(CMDLINE, 0);
clrtoeol();
@ -311,30 +307,14 @@ die(signo)
exit(0);
}
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#if __STDC__
void
error(const char *fmt, ...)
#else
void
error(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
char buf[255];
int oy, ox;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
if (wnd) {
getyx(stdscr, oy, ox);
@ -353,8 +333,7 @@ error(fmt, va_alist)
}
void
nlisterr(namelist)
struct nlist namelist[];
nlisterr(struct nlist namelist[])
{
int i, n;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbufs.c,v 1.8 2000/06/04 18:29:13 mycroft Exp $ */
/* $NetBSD: mbufs.c,v 1.9 2000/07/05 11:03:22 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: mbufs.c,v 1.8 2000/06/04 18:29:13 mycroft Exp $");
__RCSID("$NetBSD: mbufs.c,v 1.9 2000/07/05 11:03:22 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -74,15 +74,14 @@ char *mtnames[] = {
#define NNAMES (sizeof (mtnames) / sizeof (mtnames[0]))
WINDOW *
openmbufs()
openmbufs(void)
{
return (subwin(stdscr, LINES-5-1, 0, 5, 0));
}
void
closembufs(w)
WINDOW *w;
closembufs(WINDOW *w)
{
if (w == NULL)
@ -93,7 +92,7 @@ closembufs(w)
}
void
labelmbufs()
labelmbufs(void)
{
wmove(wnd, 0, 0); wclrtoeol(wnd);
@ -102,7 +101,7 @@ labelmbufs()
}
void
showmbufs()
showmbufs(void)
{
int i, j, max, index;
char buf[10];
@ -145,7 +144,7 @@ static struct nlist namelist[] = {
};
int
initmbufs()
initmbufs(void)
{
if (namelist[X_MBSTAT].n_type == 0) {
@ -164,7 +163,7 @@ initmbufs()
}
void
fetchmbufs()
fetchmbufs(void)
{
if (namelist[X_MBSTAT].n_type == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: netcmds.c,v 1.15 2000/04/27 00:30:51 jdc Exp $ */
/* $NetBSD: netcmds.c,v 1.16 2000/07/05 11:03:22 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)netcmds.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: netcmds.c,v 1.15 2000/04/27 00:30:51 jdc Exp $");
__RCSID("$NetBSD: netcmds.c,v 1.16 2000/07/05 11:03:22 ad Exp $");
#endif /* not lint */
/*
@ -77,34 +77,31 @@ static struct hitem {
int nports, nhosts, protos;
static void changeitems __P((char *, int));
static void selectproto __P((char *));
static void showprotos __P((void));
static int selectport __P((long, int));
static void showports __P((void));
static int addrcmp __P((struct sockaddr *, struct sockaddr *));
static int selecthost __P((struct sockaddr *, int));
static void showhosts __P((void));
static void changeitems(char *, int);
static void selectproto(char *);
static void showprotos(void);
static int selectport(long, int);
static void showports(void);
static int addrcmp(struct sockaddr *, struct sockaddr *);
static int selecthost(struct sockaddr *, int);
static void showhosts(void);
/* please note: there are also some netstat commands in netstat.c */
void
netstat_display (args)
char *args;
netstat_display(char *args)
{
changeitems(args, 1);
}
void
netstat_ignore (args)
char *args;
netstat_ignore(char *args)
{
changeitems(args, 0);
}
void
netstat_reset (args)
char *args;
netstat_reset(char *args)
{
selectproto(0);
selecthost(0, 0);
@ -112,8 +109,7 @@ netstat_reset (args)
}
void
netstat_show (args)
char *args;
netstat_show(char *args)
{
move(CMDLINE, 0); clrtoeol();
if (!args || *args == '\0') {
@ -133,23 +129,19 @@ netstat_show (args)
}
void
netstat_tcp (args)
char *args;
netstat_tcp(char *args)
{
selectproto("tcp");
}
void
netstat_udp (args)
char *args;
netstat_udp(char *args)
{
selectproto("udp");
}
static void
changeitems(args, onoff)
char *args;
int onoff;
changeitems(char *args, int onoff)
{
char *cp;
struct servent *sp;
@ -189,8 +181,7 @@ changeitems(args, onoff)
}
static void
selectproto(proto)
char *proto;
selectproto(char *proto)
{
if (proto == 0 || streq(proto, "all"))
@ -202,7 +193,7 @@ selectproto(proto)
}
static void
showprotos()
showprotos(void)
{
if ((protos & TCP) == 0)
@ -219,9 +210,7 @@ static struct pitem {
} *ports = NULL;
static int
selectport(port, onoff)
long port;
int onoff;
selectport(long port, int onoff)
{
struct pitem *p;
@ -251,8 +240,7 @@ selectport(port, onoff)
}
int
checkport(inp)
struct inpcb *inp;
checkport(struct inpcb *inp)
{
struct pitem *p;
@ -265,8 +253,7 @@ checkport(inp)
#ifdef INET6
int
checkport6(in6p)
struct in6pcb *in6p;
checkport6(struct in6pcb *in6p)
{
struct pitem *p;
@ -279,7 +266,7 @@ checkport6(in6p)
#endif
static void
showports()
showports(void)
{
struct pitem *p;
struct servent *sp;
@ -297,9 +284,7 @@ showports()
}
static int
addrcmp(sa1, sa2)
struct sockaddr *sa1;
struct sockaddr *sa2;
addrcmp(struct sockaddr *sa1, struct sockaddr *sa2)
{
if (sa1->sa_family != sa2->sa_family)
return 0;
@ -327,9 +312,7 @@ addrcmp(sa1, sa2)
}
static int
selecthost(sa, onoff)
struct sockaddr *sa;
int onoff;
selecthost(struct sockaddr *sa, int onoff)
{
struct hitem *p;
@ -360,8 +343,7 @@ selecthost(sa, onoff)
}
int
checkhost(inp)
struct inpcb *inp;
checkhost(struct inpcb *inp)
{
struct hitem *p;
struct sockaddr_in *sin;
@ -380,8 +362,7 @@ checkhost(inp)
#ifdef INET6
int
checkhost6(in6p)
struct in6pcb *in6p;
checkhost6(struct in6pcb *in6p)
{
struct hitem *p;
struct sockaddr_in6 *sin6;
@ -400,7 +381,7 @@ checkhost6(in6p)
#endif
static void
showhosts()
showhosts(void)
{
struct hitem *p;
char hbuf[NI_MAXHOST];

View File

@ -1,4 +1,4 @@
/* $NetBSD: netstat.c,v 1.18 2000/04/27 00:30:51 jdc Exp $ */
/* $NetBSD: netstat.c,v 1.19 2000/07/05 11:03:22 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: netstat.c,v 1.18 2000/04/27 00:30:51 jdc Exp $");
__RCSID("$NetBSD: netstat.c,v 1.19 2000/07/05 11:03:22 ad Exp $");
#endif /* not lint */
/*
@ -84,15 +84,15 @@ __RCSID("$NetBSD: netstat.c,v 1.18 2000/04/27 00:30:51 jdc Exp $");
#include "systat.h"
#include "extern.h"
static void fetchnetstat4 __P((void *, int));
static void enter __P((struct inpcb *, struct socket *, int, char *));
static const char *inetname __P((struct in_addr));
static void inetprint __P((struct in_addr *, int, char *));
static void fetchnetstat4(void *, int);
static void enter(struct inpcb *, struct socket *, int, char *);
static const char *inetname(struct in_addr);
static void inetprint(struct in_addr *, int, char *);
#ifdef INET6
static void fetchnetstat6 __P((void *, int));
static void enter6 __P((struct in6pcb *, struct socket *, int, char *));
static const char *inet6name __P((struct in6_addr *));
static void inet6print __P((struct in6_addr *, int, char *));
static void fetchnetstat6(void *, int);
static void enter6(struct in6pcb *, struct socket *, int, char *);
static const char *inet6name(struct in6_addr *);
static void inet6print(struct in6_addr *, int, char *);
#endif
#define streq(a,b) (strcmp(a,b)==0)
@ -130,7 +130,7 @@ int nflag = 0;
static int lastrow = 1;
WINDOW *
opennetstat()
opennetstat(void)
{
sethostent(1);
@ -139,8 +139,7 @@ opennetstat()
}
void
closenetstat(w)
WINDOW *w;
closenetstat(WINDOW *w)
{
struct netinfo *p;
@ -175,7 +174,7 @@ static struct nlist namelist[] = {
};
int
initnetstat()
initnetstat(void)
{
int n;
@ -194,7 +193,7 @@ initnetstat()
}
void
fetchnetstat()
fetchnetstat(void)
{
struct netinfo *p;
@ -220,9 +219,7 @@ fetchnetstat()
}
static void
fetchnetstat4(off, istcp)
void *off;
int istcp;
fetchnetstat4(void *off, int istcp)
{
struct inpcbtable pcbtable;
struct inpcb *head, *prev, *next;
@ -264,9 +261,7 @@ printf("prev = %p, head = %p, next = %p, inpcb...prev = %p\n", prev, head, next,
#ifdef INET6
static void
fetchnetstat6(off, istcp)
void *off;
int istcp;
fetchnetstat6(void *off, int istcp)
{
struct netinfo *p;
struct socket sockb;
@ -307,11 +302,7 @@ printf("prev = %p, head = %p, next = %p, in6pcb...prev = %p\n", prev6, head6, ne
#endif /*INET6*/
static void
enter(inp, so, state, proto)
struct inpcb *inp;
struct socket *so;
int state;
char *proto;
enter(struct inpcb *inp, struct socket *so, int state, char *proto)
{
struct netinfo *p;
@ -360,11 +351,7 @@ enter(inp, so, state, proto)
#ifdef INET6
static void
enter6(in6p, so, state, proto)
struct in6pcb *in6p;
struct socket *so;
int state;
char *proto;
enter6(struct in6pcb *in6p, struct socket *so, int state, char *proto)
{
struct netinfo *p;
@ -421,7 +408,7 @@ enter6(in6p, so, state, proto)
#define STATE SNDCC+7
void
labelnetstat()
labelnetstat(void)
{
if (namelist[X_TCBTABLE].n_type == 0)
@ -436,7 +423,7 @@ labelnetstat()
}
void
shownetstat()
shownetstat(void)
{
struct netinfo *p, *q;
@ -539,10 +526,7 @@ shownetstat()
* If the nflag was specified, use numbers instead of names.
*/
static void
inetprint(in, port, proto)
struct in_addr *in;
int port;
char *proto;
inetprint(struct in_addr *in, int port, char *proto)
{
struct servent *sp = 0;
char line[80], *cp;
@ -567,10 +551,7 @@ inetprint(in, port, proto)
#ifdef INET6
static void
inet6print(in6, port, proto)
struct in6_addr *in6;
int port;
char *proto;
inet6print(struct in6_addr *in6, int port, char *proto)
{
struct servent *sp = 0;
char line[80], *cp;
@ -600,8 +581,7 @@ inet6print(in6, port, proto)
* numeric value, otherwise try for symbolic name.
*/
static const char *
inetname(in)
struct in_addr in;
inetname(struct in_addr in)
{
char *cp = 0;
static char line[50];
@ -641,8 +621,7 @@ inetname(in)
#ifdef INET6
static const char *
inet6name(in6)
struct in6_addr *in6;
inet6name(struct in6_addr *in6)
{
static char line[NI_MAXHOST];
struct sockaddr_in6 sin6;
@ -668,8 +647,7 @@ inet6name(in6)
/* please note: there are also some netstat commands in netcmds.c */
void
netstat_all (args)
char *args;
netstat_all(char *args)
{
aflag = !aflag;
fetchnetstat();
@ -678,8 +656,7 @@ netstat_all (args)
}
void
netstat_names (args)
char *args;
netstat_names(char *args)
{
struct netinfo *p;
@ -700,8 +677,7 @@ netstat_names (args)
}
void
netstat_numbers (args)
char *args;
netstat_numbers(char *args)
{
struct netinfo *p;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pigs.c,v 1.19 2000/06/04 18:29:13 mycroft Exp $ */
/* $NetBSD: pigs.c,v 1.20 2000/07/05 11:03:23 ad Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pigs.c 8.2 (Berkeley) 9/23/93";
#endif
__RCSID("$NetBSD: pigs.c,v 1.19 2000/06/04 18:29:13 mycroft Exp $");
__RCSID("$NetBSD: pigs.c,v 1.20 2000/07/05 11:03:23 ad Exp $");
#endif /* not lint */
/*
@ -64,7 +64,7 @@ __RCSID("$NetBSD: pigs.c,v 1.19 2000/06/04 18:29:13 mycroft Exp $");
#include "systat.h"
#include "ps.h"
int compare_pctcpu __P((const void *, const void *));
int compare_pctcpu(const void *, const void *);
int nproc;
struct p_times *pt;
@ -79,15 +79,14 @@ double lccpu;
#endif
WINDOW *
openpigs()
openpigs(void)
{
return (subwin(stdscr, LINES-5-1, 0, 5, 0));
}
void
closepigs(w)
WINDOW *w;
closepigs(WINDOW *w)
{
if (w == NULL)
@ -99,7 +98,7 @@ closepigs(w)
void
showpigs()
showpigs(void)
{
int i, y, k;
struct eproc *ep;
@ -161,7 +160,7 @@ static struct nlist namelist[] = {
};
int
initpigs()
initpigs(void)
{
fixpt_t ccpu;
@ -185,7 +184,7 @@ initpigs()
}
void
fetchpigs()
fetchpigs(void)
{
int i;
float time;
@ -244,7 +243,7 @@ fetchpigs()
}
void
labelpigs()
labelpigs(void)
{
wmove(wnd, 0, 0);
wclrtoeol(wnd);
@ -252,8 +251,7 @@ labelpigs()
}
int
compare_pctcpu(a, b)
const void *a, *b;
compare_pctcpu(const void *a, const void *b)
{
return (((struct p_times *) a)->pt_pctcpu >
((struct p_times *) b)->pt_pctcpu)? -1: 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ps.c,v 1.15 2000/06/04 01:53:51 perry Exp $ */
/* $NetBSD: ps.c,v 1.16 2000/07/05 11:03:23 ad Exp $ */
/*-
* Copyright (c) 1999
@ -45,7 +45,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ps.c,v 1.15 2000/06/04 01:53:51 perry Exp $");
__RCSID("$NetBSD: ps.c,v 1.16 2000/07/05 11:03:23 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -69,15 +69,15 @@ __RCSID("$NetBSD: ps.c,v 1.15 2000/06/04 01:53:51 perry Exp $");
#include "systat.h"
#include "ps.h"
int compare_pctcpu_noidle __P((const void *, const void *));
char *state2str __P((struct kinfo_proc *));
char *tty2str __P((struct kinfo_proc *));
int rss2int __P((struct kinfo_proc *));
int vsz2int __P((struct kinfo_proc *));
char *comm2str __P((struct kinfo_proc *));
double pmem2float __P((struct kinfo_proc *));
char *start2str __P((struct kinfo_proc *));
char *time2str __P((struct kinfo_proc *));
int compare_pctcpu_noidle(const void *, const void *);
char *state2str(struct kinfo_proc *);
char *tty2str(struct kinfo_proc *);
int rss2int(struct kinfo_proc *);
int vsz2int(struct kinfo_proc *);
char *comm2str(struct kinfo_proc *);
double pmem2float(struct kinfo_proc *);
char *start2str(struct kinfo_proc *);
char *time2str(struct kinfo_proc *);
static time_t now;
@ -89,13 +89,13 @@ static uid_t showuser = SHOWUSER_ANY;
#endif
void
labelps ()
labelps(void)
{
mvwaddstr(wnd, 0, 0, "USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND");
}
void
showps ()
showps(void)
{
int i, k, y, vsz, rss;
const char *user, *comm, *state, *tty, *start, *time;
@ -143,8 +143,7 @@ showps ()
}
int
compare_pctcpu_noidle (a, b)
const void *a, *b;
compare_pctcpu_noidle(const void *a, const void *b)
{
if (((struct p_times *) a)->pt_kp == NULL)
return 1;
@ -158,8 +157,7 @@ compare_pctcpu_noidle (a, b)
/* from here down adapted from .../src/usr.bin/ps/print.c . Any mistakes are my own, however. */
char *
state2str(kp)
struct kinfo_proc *kp;
state2str(struct kinfo_proc *kp)
{
struct proc *p;
struct eproc *e;
@ -229,8 +227,7 @@ state2str(kp)
}
char *
tty2str(kp)
struct kinfo_proc *kp;
tty2str(struct kinfo_proc *kp)
{
static char ttystr[4];
char *ttyname;
@ -253,8 +250,7 @@ tty2str(kp)
#define pgtok(a) (((a)*getpagesize())/1024)
int
vsz2int(kp)
struct kinfo_proc *kp;
vsz2int(struct kinfo_proc *kp)
{
struct eproc *e;
int i;
@ -266,8 +262,7 @@ vsz2int(kp)
}
int
rss2int(kp)
struct kinfo_proc *kp;
rss2int(struct kinfo_proc *kp)
{
struct eproc *e;
int i;
@ -280,8 +275,7 @@ rss2int(kp)
}
char *
comm2str(kp)
struct kinfo_proc *kp;
comm2str(struct kinfo_proc *kp)
{
char **argv, **pt;
static char commstr[41];
@ -308,8 +302,7 @@ comm2str(kp)
}
double
pmem2float(kp)
struct kinfo_proc *kp;
pmem2float(struct kinfo_proc *kp)
{
struct proc *p;
struct eproc *e;
@ -329,8 +322,7 @@ pmem2float(kp)
}
char *
start2str(kp)
struct kinfo_proc *kp;
start2str(struct kinfo_proc *kp)
{
struct proc *p;
struct pstats pstats;
@ -363,8 +355,7 @@ start2str(kp)
}
char *
time2str(kp)
struct kinfo_proc *kp;
time2str(struct kinfo_proc *kp)
{
long secs;
long psecs; /* "parts" of a second. first micro, then centi */
@ -403,8 +394,7 @@ time2str(kp)
}
void
ps_user(args)
char *args;
ps_user(char *args)
{
uid_t uid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: swap.c,v 1.12 2000/06/04 18:29:14 mycroft Exp $ */
/* $NetBSD: swap.c,v 1.13 2000/07/05 11:03:23 ad Exp $ */
/*-
* Copyright (c) 1997 Matthew R. Green. All rights reserved.
@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)swap.c 8.3 (Berkeley) 4/29/95";
#endif
__RCSID("$NetBSD: swap.c,v 1.12 2000/06/04 18:29:14 mycroft Exp $");
__RCSID("$NetBSD: swap.c,v 1.13 2000/07/05 11:03:23 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -58,7 +58,7 @@ __RCSID("$NetBSD: swap.c,v 1.12 2000/06/04 18:29:14 mycroft Exp $");
#include "systat.h"
#include "extern.h"
void showspace __P((char *header, int hlen, long blocksize));
void showspace(char *header, int hlen, long blocksize);
static long blocksize;
static int hlen, nswap, rnswap;
@ -66,15 +66,14 @@ static int first = 1;
static struct swapent *swap_devices;
WINDOW *
openswap()
openswap(void)
{
return (subwin(stdscr, LINES-5-1, 0, 5, 0));
}
void
closeswap(w)
WINDOW *w;
closeswap(WINDOW *w)
{
if (w == NULL)
@ -86,14 +85,14 @@ closeswap(w)
/* do nothing */
int
initswap()
initswap(void)
{
return (1);
}
void
fetchswap()
fetchswap(void)
{
int update_label = 0;
@ -122,7 +121,7 @@ fetchswap()
}
void
labelswap()
labelswap(void)
{
char *header;
int row;
@ -143,7 +142,8 @@ labelswap()
}
void
showswap() {
showswap(void)
{
int col, div, i, avail, used, xsize, free;
struct swapent *sep;
char *p;

View File

@ -1,4 +1,4 @@
/* $NetBSD: systat.h,v 1.6 1999/12/20 03:45:03 jwise Exp $ */
/*-
* Copyright (c) 1980, 1989, 1992, 1993
@ -39,19 +39,19 @@
struct mode {
char *c_name; /* command name */
void (*c_refresh) __P((void)); /* display refresh */
void (*c_fetch) __P((void)); /* sets up data structures */
void (*c_label) __P((void)); /* label display */
int (*c_init) __P((void)); /* initialize namelist, etc. */
WINDOW *(*c_open) __P((void)); /* open display */
void (*c_close) __P((WINDOW *)); /* close display */
void (*c_refresh)(void); /* display refresh */
void (*c_fetch)(void); /* sets up data structures */
void (*c_label)(void); /* label display */
int (*c_init)(void); /* initialize namelist, etc. */
WINDOW *(*c_open)(void); /* open display */
void (*c_close)(WINDOW *); /* close display */
struct command *c_commands; /* commands for mode */
char c_flags; /* see below */
};
struct command {
char *c_name;
void (*c_cmd) __P((char *args));
void (*c_cmd)(char *args);
char *helptext;
};
@ -67,5 +67,5 @@ struct command {
#define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len))
#define LONG (sizeof (long))
void dkreadstats __P((void)); /* XXX: from ../vmstat/dkstats.c */
void dkswap __P((void)); /* XXX: from ../vmstat/dkstats.c */
void dkreadstats(void); /* XXX: from ../vmstat/dkstats.c */
void dkswap(void); /* XXX: from ../vmstat/dkstats.c */

View File

@ -1,7 +1,7 @@
/* $NetBSD: tcp.c,v 1.6 2000/06/13 13:37:13 ad Exp $ */
/* $NetBSD: tcp.c,v 1.7 2000/07/05 11:03:23 ad Exp $ */
/*
* Copyright (c) 1999 Andrew Doran <ad@NetBSD.org>
* Copyright (c) 1999, 2000 Andrew Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: tcp.c,v 1.6 2000/06/13 13:37:13 ad Exp $");
__RCSID("$NetBSD: tcp.c,v 1.7 2000/07/05 11:03:23 ad Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -58,9 +58,19 @@ __RCSID("$NetBSD: tcp.c,v 1.6 2000/06/13 13:37:13 ad Exp $");
#define LHD(row, str) mvwprintw(wnd, row, 10, str)
#define RHD(row, str) mvwprintw(wnd, row, 45, str)
#define SHOW(row, col, stat) mvwprintw(wnd, row, col, "%9llu", (unsigned long long) curstat.stat)
#define SHOW(row, col, stat) \
mvwprintw(wnd, row, col, "%9llu", (unsigned long long)curstat.stat)
static struct tcpstat curstat, oldstat;
enum update {
UPDATE_TIME,
UPDATE_BOOT,
UPDATE_RUN,
};
static enum update update = UPDATE_TIME;
static struct tcpstat curstat;
static struct tcpstat newstat;
static struct tcpstat oldstat;
static struct nlist namelist[] = {
{ "_tcpstat" },
@ -75,8 +85,7 @@ opentcp(void)
}
void
closetcp(w)
WINDOW *w;
closetcp(WINDOW *w)
{
if (w != NULL) {
@ -231,6 +240,77 @@ void
fetchtcp(void)
{
oldstat = curstat;
KREAD((void *)namelist[0].n_value, &curstat, sizeof(curstat));
KREAD((void *)namelist[0].n_value, &newstat, sizeof(newstat));
ADJINETCTR(curstat, oldstat, newstat, tcps_connattempt);
ADJINETCTR(curstat, oldstat, newstat, tcps_accepts);
ADJINETCTR(curstat, oldstat, newstat, tcps_connects);
ADJINETCTR(curstat, oldstat, newstat, tcps_drops);
ADJINETCTR(curstat, oldstat, newstat, tcps_conndrops);
ADJINETCTR(curstat, oldstat, newstat, tcps_timeoutdrop);
ADJINETCTR(curstat, oldstat, newstat, tcps_keepdrops);
ADJINETCTR(curstat, oldstat, newstat, tcps_persistdrops);
ADJINETCTR(curstat, oldstat, newstat, tcps_segstimed);
ADJINETCTR(curstat, oldstat, newstat, tcps_rttupdated);
ADJINETCTR(curstat, oldstat, newstat, tcps_delack);
ADJINETCTR(curstat, oldstat, newstat, tcps_rexmttimeo);
ADJINETCTR(curstat, oldstat, newstat, tcps_persisttimeo);
ADJINETCTR(curstat, oldstat, newstat, tcps_keepprobe);
ADJINETCTR(curstat, oldstat, newstat, tcps_keeptimeo);
ADJINETCTR(curstat, oldstat, newstat, tcps_sndtotal);
ADJINETCTR(curstat, oldstat, newstat, tcps_sndpack);
ADJINETCTR(curstat, oldstat, newstat, tcps_sndrexmitpack);
ADJINETCTR(curstat, oldstat, newstat, tcps_sndacks);
ADJINETCTR(curstat, oldstat, newstat, tcps_sndprobe);
ADJINETCTR(curstat, oldstat, newstat, tcps_sndwinup);
ADJINETCTR(curstat, oldstat, newstat, tcps_sndurg);
ADJINETCTR(curstat, oldstat, newstat, tcps_sndctrl);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvtotal);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvpack);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvduppack);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvpartduppack);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvoopack);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvdupack);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvackpack);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvwinprobe);
ADJINETCTR(curstat, oldstat, newstat, tcps_rcvwinupd);
if (update == UPDATE_TIME)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}
void
tcp_boot(char *args)
{
memset(&oldstat, 0, sizeof(oldstat));
update = UPDATE_BOOT;
}
void
tcp_run(char *args)
{
if (update != UPDATE_RUN) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_RUN;
}
}
void
tcp_time(char *args)
{
if (update != UPDATE_TIME) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
update = UPDATE_TIME;
}
}
void
tcp_zero(char *args)
{
if (update == UPDATE_RUN)
memcpy(&oldstat, &newstat, sizeof(oldstat));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vmstat.c,v 1.32 2000/06/29 06:29:16 mrg Exp $ */
/* $NetBSD: vmstat.c,v 1.33 2000/07/05 11:03:23 ad Exp $ */
/*-
* Copyright (c) 1983, 1989, 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif
__RCSID("$NetBSD: vmstat.c,v 1.32 2000/06/29 06:29:16 mrg Exp $");
__RCSID("$NetBSD: vmstat.c,v 1.33 2000/07/05 11:03:23 ad Exp $");
#endif /* not lint */
/*
@ -92,14 +92,14 @@ extern struct _disk cur;
static enum state { BOOT, TIME, RUN } state = TIME;
static void allocinfo __P((struct Info *));
static void copyinfo __P((struct Info *, struct Info *));
static float cputime __P((int));
static void dinfo __P((int, int));
static void getinfo __P((struct Info *, enum state));
static void putint __P((int, int, int, int));
static void putfloat __P((double, int, int, int, int, int));
static int ucount __P((void));
static void allocinfo(struct Info *);
static void copyinfo(struct Info *, struct Info *);
static float cputime(int);
static void dinfo(int, int);
static void getinfo(struct Info *, enum state);
static void putint(int, int, int, int);
static void putfloat(double, int, int, int, int, int);
static int ucount(void);
static int ut;
static char buf[26];
@ -114,7 +114,7 @@ static int nextintsrow;
struct utmp utmp;
WINDOW *
openkre()
openvmstat(void)
{
ut = open(_PATH_UTMP, O_RDONLY);
@ -124,8 +124,7 @@ openkre()
}
void
closekre(w)
WINDOW *w;
closevmstat(WINDOW *w)
{
(void) close(ut);
@ -185,7 +184,7 @@ static struct nlist namelist[] = {
#endif
int
initkre()
initvmstat(void)
{
char *intrnamebuf, *cp;
int i;
@ -250,7 +249,7 @@ initkre()
}
void
fetchkre()
fetchvmstat(void)
{
time_t now;
@ -261,7 +260,7 @@ fetchkre()
}
void
labelkre()
labelvmstat(void)
{
int i, j;
@ -340,7 +339,7 @@ static char cpuchar[CPUSTATES] = { '=' , '>', '-', '%', ' ' };
static char cpuorder[CPUSTATES] = { CP_SYS, CP_USER, CP_NICE, CP_INTR, CP_IDLE };
void
showkre()
showvmstat(void)
{
float f1, f2;
int psiz, inttotal;
@ -483,16 +482,14 @@ showkre()
}
void
vmstat_boot (args)
char *args;
vmstat_boot(char *args)
{
copyinfo(&z, &s1);
state = BOOT;
}
void
vmstat_run (args)
char *args;
vmstat_run(char *args)
{
copyinfo(&s1, &s2);
state = RUN;
@ -506,8 +503,7 @@ vmstat_time (args)
}
void
vmstat_zero (args)
char *args;
vmstat_zero(char *args)
{
if (state == RUN)
getinfo(&s1, RUN);
@ -515,7 +511,7 @@ vmstat_zero (args)
/* calculate number of users on the system */
static int
ucount()
ucount(void)
{
int nusers = 0, onusers = -1;
@ -537,8 +533,7 @@ ucount()
}
static float
cputime(indx)
int indx;
cputime(int indx)
{
double t;
int i;
@ -552,8 +547,7 @@ cputime(indx)
}
static void
putint(n, l, c, w)
int n, l, c, w;
putint(int n, int l, int c, int w)
{
char b[128];
@ -571,9 +565,7 @@ putint(n, l, c, w)
}
static void
putfloat(f, l, c, w, d, nz)
double f;
int l, c, w, d, nz;
putfloat(double f, int l, int c, int w, int d, int nz)
{
char b[128];
@ -591,9 +583,7 @@ putfloat(f, l, c, w, d, nz)
}
static void
getinfo(s, st)
struct Info *s;
enum state st;
getinfo(struct Info *s, enum state st)
{
int mib[2];
size_t size;
@ -619,8 +609,7 @@ getinfo(s, st)
}
static void
allocinfo(s)
struct Info *s;
allocinfo(struct Info *s)
{
if ((s->intrcnt = malloc(nintr * sizeof(long))) == NULL) {
@ -630,8 +619,7 @@ allocinfo(s)
}
static void
copyinfo(from, to)
struct Info *from, *to;
copyinfo(struct Info *from, struct Info *to)
{
long *intrcnt;
@ -641,8 +629,7 @@ copyinfo(from, to)
}
static void
dinfo(dn, c)
int dn, c;
dinfo(int dn, int c)
{
double words, atime;