Add support for a '-b' option to provide byte counts in and out,
instead of just packet counts. On the byte screens, errors and collisions are not shown, since they are more packet count related.
This commit is contained in:
parent
7eed6ad8d8
commit
9433195784
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if.c,v 1.25 1997/10/19 05:49:58 lukem Exp $ */
|
||||
/* $NetBSD: if.c,v 1.26 1998/03/19 02:42:57 kml Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: if.c,v 1.25 1997/10/19 05:49:58 lukem Exp $");
|
||||
__RCSID("$NetBSD: if.c,v 1.26 1998/03/19 02:42:57 kml Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -110,10 +110,18 @@ intpr(interval, ifnetaddr)
|
||||
return;
|
||||
ifnetaddr = (u_long)ifhead.tqh_first;
|
||||
|
||||
printf("%-5.5s %-5.5s %-13.13s %-17.17s %8.8s %5.5s %8.8s %5.5s",
|
||||
"Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs",
|
||||
"Opkts", "Oerrs");
|
||||
printf(" %5s", "Coll");
|
||||
if (bflag) {
|
||||
printf("%-5.5s %-5.5s %-13.13s %-17.17s "
|
||||
"%10.10s %10.10s",
|
||||
"Name", "Mtu", "Network", "Address",
|
||||
"Ibytes", "Obytes");
|
||||
} else {
|
||||
printf("%-5.5s %-5.5s %-13.13s %-17.17s "
|
||||
"%8.8s %5.5s %8.8s %5.5s",
|
||||
"Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs",
|
||||
"Opkts", "Oerrs");
|
||||
printf(" %5s", "Coll");
|
||||
}
|
||||
if (tflag)
|
||||
printf(" %s", "Time");
|
||||
if (dflag)
|
||||
@ -239,10 +247,15 @@ intpr(interval, ifnetaddr)
|
||||
}
|
||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
|
||||
}
|
||||
printf("%8ld %5ld %8ld %5ld %5ld",
|
||||
ifnet.if_ipackets, ifnet.if_ierrors,
|
||||
ifnet.if_opackets, ifnet.if_oerrors,
|
||||
ifnet.if_collisions);
|
||||
if (bflag) {
|
||||
printf("%10ld %10ld",
|
||||
ifnet.if_ibytes, ifnet.if_obytes);
|
||||
} else {
|
||||
printf("%8ld %5ld %8ld %5ld %5ld",
|
||||
ifnet.if_ipackets, ifnet.if_ierrors,
|
||||
ifnet.if_opackets, ifnet.if_oerrors,
|
||||
ifnet.if_collisions);
|
||||
}
|
||||
if (tflag)
|
||||
printf(" %3d", ifnet.if_timer);
|
||||
if (dflag)
|
||||
@ -255,8 +268,10 @@ intpr(interval, ifnetaddr)
|
||||
struct iftot {
|
||||
char ift_name[IFNAMSIZ]; /* interface name */
|
||||
int ift_ip; /* input packets */
|
||||
int ift_ib; /* input bytes */
|
||||
int ift_ie; /* input errors */
|
||||
int ift_op; /* output packets */
|
||||
int ift_ob; /* output bytes */
|
||||
int ift_oe; /* output errors */
|
||||
int ift_co; /* collisions */
|
||||
int ift_dr; /* drops */
|
||||
@ -327,20 +342,32 @@ banner:
|
||||
}
|
||||
for (ip = iftot; ip < iftot + MAXIF; ip++) {
|
||||
ip->ift_ip = 0;
|
||||
ip->ift_ib = 0;
|
||||
ip->ift_ie = 0;
|
||||
ip->ift_op = 0;
|
||||
ip->ift_ob = 0;
|
||||
ip->ift_oe = 0;
|
||||
ip->ift_co = 0;
|
||||
ip->ift_dr = 0;
|
||||
}
|
||||
putchar('\n');
|
||||
printf("%8.8s %5.5s %8.8s %5.5s %5.5s ",
|
||||
"packets", "errs", "packets", "errs", "colls");
|
||||
if (bflag) {
|
||||
printf("%10.10s %8.8s %10.10s %5.5s",
|
||||
"bytes", " ", "bytes", " ");
|
||||
} else {
|
||||
printf("%8.8s %5.5s %8.8s %5.5s %5.5s ",
|
||||
"packets", "errs", "packets", "errs", "colls");
|
||||
}
|
||||
if (dflag)
|
||||
printf("%5.5s ", "drops");
|
||||
if (lastif - iftot > 0)
|
||||
printf(" %8.8s %5.5s %8.8s %5.5s %5.5s",
|
||||
"packets", "errs", "packets", "errs", "colls");
|
||||
if (bflag) {
|
||||
printf("%10.10s %8.8s %10.10s %5.5s",
|
||||
"bytes", " ", "bytes", " ");
|
||||
} else {
|
||||
printf("%8.8s %5.5s %8.8s %5.5s %5.5s ",
|
||||
"packets", "errs", "packets", "errs", "colls");
|
||||
}
|
||||
if (dflag)
|
||||
printf(" %5.5s", "drops");
|
||||
putchar('\n');
|
||||
@ -348,8 +375,10 @@ banner:
|
||||
line = 0;
|
||||
loop:
|
||||
sum->ift_ip = 0;
|
||||
sum->ift_ib = 0;
|
||||
sum->ift_ie = 0;
|
||||
sum->ift_op = 0;
|
||||
sum->ift_ob = 0;
|
||||
sum->ift_oe = 0;
|
||||
sum->ift_co = 0;
|
||||
sum->ift_dr = 0;
|
||||
@ -359,37 +388,53 @@ loop:
|
||||
continue;
|
||||
}
|
||||
if (ip == interesting) {
|
||||
printf("%8ld %5ld %8ld %5ld %5ld",
|
||||
ifnet.if_ipackets - ip->ift_ip,
|
||||
ifnet.if_ierrors - ip->ift_ie,
|
||||
ifnet.if_opackets - ip->ift_op,
|
||||
ifnet.if_oerrors - ip->ift_oe,
|
||||
ifnet.if_collisions - ip->ift_co);
|
||||
if (bflag) {
|
||||
printf("%10ld %8.8s %10ld %5.5s",
|
||||
ifnet.if_ibytes - ip->ift_ib, " ",
|
||||
ifnet.if_obytes - ip->ift_ob, " ");
|
||||
} else {
|
||||
printf("%8ld %5ld %8ld %5ld %5ld",
|
||||
ifnet.if_ipackets - ip->ift_ip,
|
||||
ifnet.if_ierrors - ip->ift_ie,
|
||||
ifnet.if_opackets - ip->ift_op,
|
||||
ifnet.if_oerrors - ip->ift_oe,
|
||||
ifnet.if_collisions - ip->ift_co);
|
||||
}
|
||||
if (dflag)
|
||||
printf(" %5d",
|
||||
ifnet.if_snd.ifq_drops - ip->ift_dr);
|
||||
}
|
||||
ip->ift_ip = ifnet.if_ipackets;
|
||||
ip->ift_ib = ifnet.if_ibytes;
|
||||
ip->ift_ie = ifnet.if_ierrors;
|
||||
ip->ift_op = ifnet.if_opackets;
|
||||
ip->ift_ob = ifnet.if_obytes;
|
||||
ip->ift_oe = ifnet.if_oerrors;
|
||||
ip->ift_co = ifnet.if_collisions;
|
||||
ip->ift_dr = ifnet.if_snd.ifq_drops;
|
||||
sum->ift_ip += ip->ift_ip;
|
||||
sum->ift_ib += ip->ift_ib;
|
||||
sum->ift_ie += ip->ift_ie;
|
||||
sum->ift_op += ip->ift_op;
|
||||
sum->ift_ob += ip->ift_ob;
|
||||
sum->ift_oe += ip->ift_oe;
|
||||
sum->ift_co += ip->ift_co;
|
||||
sum->ift_dr += ip->ift_dr;
|
||||
off = (u_long)ifnet.if_list.tqe_next;
|
||||
}
|
||||
if (lastif - iftot > 0) {
|
||||
printf(" %8d %5d %8d %5d %5d",
|
||||
sum->ift_ip - total->ift_ip,
|
||||
sum->ift_ie - total->ift_ie,
|
||||
sum->ift_op - total->ift_op,
|
||||
sum->ift_oe - total->ift_oe,
|
||||
sum->ift_co - total->ift_co);
|
||||
if (bflag) {
|
||||
printf(" %10d %8.8s %10d %5.5s",
|
||||
sum->ift_ib - total->ift_ib, " ",
|
||||
sum->ift_ob - total->ift_ob, " ");
|
||||
} else {
|
||||
printf(" %8d %5d %8d %5d %5d",
|
||||
sum->ift_ip - total->ift_ip,
|
||||
sum->ift_ie - total->ift_ie,
|
||||
sum->ift_op - total->ift_op,
|
||||
sum->ift_oe - total->ift_oe,
|
||||
sum->ift_co - total->ift_co);
|
||||
}
|
||||
if (dflag)
|
||||
printf(" %5d", sum->ift_dr - total->ift_dr);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.12 1997/10/19 05:50:03 lukem Exp $ */
|
||||
/* $NetBSD: main.c,v 1.13 1998/03/19 02:42:57 kml Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.12 1997/10/19 05:50:03 lukem Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.13 1998/03/19 02:42:57 kml Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -226,7 +226,7 @@ main(argc, argv)
|
||||
tp = NULL;
|
||||
af = AF_UNSPEC;
|
||||
|
||||
while ((ch = getopt(argc, argv, "Aadf:ghI:iM:mN:np:rstuw:")) != -1)
|
||||
while ((ch = getopt(argc, argv, "Aabdf:ghI:iM:mN:np:rstuw:")) != -1)
|
||||
switch(ch) {
|
||||
case 'A':
|
||||
Aflag = 1;
|
||||
@ -234,6 +234,9 @@ main(argc, argv)
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
break;
|
||||
case 'b':
|
||||
bflag = 1;
|
||||
break;
|
||||
case 'd':
|
||||
dflag = 1;
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: netstat.1,v 1.14 1997/10/28 22:38:42 kml Exp $
|
||||
.\" $NetBSD: netstat.1,v 1.15 1998/03/19 02:42:57 kml Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1990, 1992, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -89,6 +89,10 @@ for debugging.
|
||||
With the default display,
|
||||
show the state of all sockets; normally sockets used by
|
||||
server processes are not shown.
|
||||
.It Fl b
|
||||
With the interface display (option
|
||||
.Fl i
|
||||
), show bytes in and out, instead of packets in and out.
|
||||
.It Fl d
|
||||
With either interface display (option
|
||||
.Fl i
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: netstat.h,v 1.8 1997/04/03 04:46:51 christos Exp $ */
|
||||
/* $NetBSD: netstat.h,v 1.9 1998/03/19 02:42:58 kml Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -39,6 +39,7 @@
|
||||
|
||||
int Aflag; /* show addresses of protocol control block */
|
||||
int aflag; /* show all sockets (including servers) */
|
||||
int bflag; /* show i/f byte stats */
|
||||
int dflag; /* show i/f dropped packets */
|
||||
int gflag; /* show group (multicast) routing or stats */
|
||||
int iflag; /* show interfaces */
|
||||
|
Loading…
x
Reference in New Issue
Block a user