From 6967ae698477e809eb79f71e8ee2b9db37c9183a Mon Sep 17 00:00:00 2001 From: Niklas Hallqvist Date: Mon, 25 Mar 1996 15:56:24 +0000 Subject: From NetBSD: merge of 960317 --- usr.sbin/pppd/pppstats/Makefile | 3 +- usr.sbin/pppd/pppstats/pppstats.8 | 63 +++++++++++++++++++++----------- usr.sbin/pppd/pppstats/pppstats.c | 76 ++++++++++++++++++++++++--------------- 3 files changed, 91 insertions(+), 51 deletions(-) (limited to 'usr.sbin/pppd/pppstats') diff --git a/usr.sbin/pppd/pppstats/Makefile b/usr.sbin/pppd/pppstats/Makefile index eef4e826b94..67909877094 100644 --- a/usr.sbin/pppd/pppstats/Makefile +++ b/usr.sbin/pppd/pppstats/Makefile @@ -1,9 +1,8 @@ -# $Id: Makefile,v 1.1 1995/10/18 08:48:00 deraadt Exp $ +# $OpenBSD: Makefile,v 1.2 1996/03/25 15:56:03 niklas Exp $ PROG= pppstats SRCS= pppstats.c MAN= pppstats.8 -MLINKS= pppstats.8 slstats.8 BINDIR= /usr/sbin .include diff --git a/usr.sbin/pppd/pppstats/pppstats.8 b/usr.sbin/pppd/pppstats/pppstats.8 index ab4b44d56dd..b8a2ee9f232 100644 --- a/usr.sbin/pppd/pppstats/pppstats.8 +++ b/usr.sbin/pppd/pppstats/pppstats.8 @@ -1,4 +1,4 @@ -.\" @(#) $Header: /cvs/OpenBSD/src/usr.sbin/pppd/pppstats/pppstats.8,v 1.1 1995/10/18 08:48:01 deraadt Exp $ (LBL) +.\" $OpenBSD: pppstats.8,v 1.2 1996/03/25 15:56:04 niklas Exp $ .Dd November 15, 1994 .Dt PPPSTATS 8 .Sh NAME @@ -9,6 +9,7 @@ .Op Fl v .Op Fl r .Op Fl z +.Op Fl a .Op Fl c Ar count .Op Fl w Ar wait .Op Ar interface @@ -27,17 +28,27 @@ into input and output sections containing columns of statistics describing the properties and volume of packets received and transmitted by the interface. .Pp -The first report will consist of a snapshot of the interface's -statistics. Further output, if any, will describe activity between -report intervals. -.Pp The options are as follows: .Bl -tag -width Ds +.It Fl a +Display absolute values rather than deltas. If this option is +specified with the +.Fl c +and/or +.Fl w +options, the second and subsequent reports (as well as the first) will +show statistics for the time since the link was initiated. .It Fl c Ar count Repeat the display .Ar count -times. The first display is for the time since a reboot and each -subsequent report is for the time period since the last display. +times. The first display is for the time since the link was initiated +(that is, since the corresponding +.Xr pppd 8 +was started), and each +subsequent report is for the time period since the last display +(unless the +.Fl a +option is specified). If this option is not specified, the default repeat .Ar count is 1 if the @@ -73,8 +84,14 @@ The total number of packets received by this interface. The number of compressed TCP packets received by this interface. .It Li VJUNC The number of uncompressed TCP packets received by this interface. +Not reported when the +.Fl r +option is specified. .It Li VJERR -The number of corrupted or bogus packets received by this interface. +The number of corrupted or bogus TCP packets received by this interface. +Not reported when the +.Fl r +option is specified. .It Li VJTOSS The number of VJ header-compressed TCP packets dropped on reception by this interface. Only reported when the @@ -86,11 +103,10 @@ reported when the .Fl v option is specified. .It Li RATIO -The overall compression ratio achieved for received packets by the -packet compression scheme in use, as a number between 0.0 and 1.0, -representing the average proportionate reduction in the size of the -packets achieved by the use of packet compression (thus 0.0 indicates -that the data is incompressible). Only reported when the +The compression ratio achieved for received packets by the +packet compression scheme in use, defined as the uncompressed size +divided by the compressed size. +Only reported when the .Fl r option is specified. .It Li UBYTE @@ -112,8 +128,14 @@ VJ-compressed TCP headers. .It Li VJUNC The number of TCP packets transmitted from this interface with VJ-uncompressed TCP headers. +Not reported when the +.Fl r +option is specified. .It Li NON-VJ The total number of non-TCP packets transmitted from this interface. +Not reported when the +.Fl r +option is specified. .It Li VJSRCH The number of searches for the cached header entry for a VJ header compressed TCP packet. Only reported when the @@ -125,15 +147,16 @@ VJ header compressed TCP packet. Only reported when the .Fl v option is specified. .It Li RATIO -The overall compression ratio achieved for transmitted packets by the -packet compression scheme in use, as a number between 0.0 and 1.0. +The compression ratio achieved for transmitted packets by the +packet compression scheme in use, defined as the size +before compression divided by the compressed size. Only reported when the .Fl r option is specified. .It Li UBYTE The total number of bytes to be transmitted, before packet compression is applied. Only reported when the -.Fl v +.Fl r option is specified. .El .Pp @@ -156,8 +179,9 @@ were transmitted in uncompressed form) received. .It Li INCOMPRESSIBLE PACK The number of incompressible packets received. .It Li COMP RATIO -The recent compression ratio for incoming packets, as a number between -0.0 and 1.0. +The recent compression ratio for incoming packets, defined as the +uncompressed size divided by the compressed size (including both +compressible and incompressible packets). .El .Pp The fields displayed on the output side are: @@ -172,8 +196,7 @@ those which were transmitted in uncompressed form). .It Li INCOMPRESSIBLE PACK The number of incompressible packets transmitted. .It Li COMP RATIO -The recent compression ratio for outgoing packets, as a number between -0.0 and 1.0. +The recent compression ratio for outgoing packets. .El .Sh SEE ALSO .Xr pppd 8 diff --git a/usr.sbin/pppd/pppstats/pppstats.c b/usr.sbin/pppd/pppstats/pppstats.c index 69e57ee25c5..fc6a541bcc8 100644 --- a/usr.sbin/pppd/pppstats/pppstats.c +++ b/usr.sbin/pppd/pppstats/pppstats.c @@ -1,3 +1,5 @@ +/* $OpenBSD: pppstats.c,v 1.2 1996/03/25 15:56:05 niklas Exp $ */ + /* * print PPP statistics: * pppstats [-v] [-r] [-z] [-c count] [-w wait] [interface] @@ -28,7 +30,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: pppstats.c,v 1.1 1995/10/18 08:48:01 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: pppstats.c,v 1.2 1996/03/25 15:56:05 niklas Exp $"; #endif #include @@ -39,6 +41,8 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1 1995/10/18 08:48:01 deraadt Exp $"; #include #include #include +#include +#include #include #include #include @@ -48,6 +52,7 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1 1995/10/18 08:48:01 deraadt Exp $"; #include int vflag, rflag, zflag; /* select type of display */ +int aflag; /* print absolute values, not deltas */ int interval, count; int infinite; int unit; @@ -59,7 +64,7 @@ char interface[IFNAMSIZ]; void usage() { - fprintf(stderr, "Usage: %s [-v|-r|-z] [-c count] [-w wait] [interface]\n", + fprintf(stderr, "Usage: %s [-v|-r|-z] [-a] [-c count] [-w wait] [interface]\n", progname); exit(1); } @@ -93,6 +98,7 @@ get_ppp_stats(curp) err(1, "couldn't get PPP statistics"); } +void get_ppp_cstats(csp) struct ppp_comp_stats *csp; { @@ -116,9 +122,8 @@ get_ppp_cstats(csp) #define V(offset) (cur.offset - old.offset) #define W(offset) (ccs.offset - ocs.offset) -#define CRATE(x) ((x).unc_bytes == 0? 0.0: \ - 1.0 - ((double)((x).comp_bytes + (x).inc_bytes) \ - / (x).unc_bytes)) +#define RATIO(c, i, u) ((c) == 0? 1.0: (u) / ((double)(c) + (i))) +#define CRATE(x) RATIO(W(x.comp_bytes), W(x.inc_bytes), W(x.unc_bytes)) /* * Print a running summary of interface statistics. @@ -130,7 +135,7 @@ void intpr() { register int line = 0; - sigset_t oldmask, mask; + sigset_t oldmask; struct ppp_stats cur, old; struct ppp_comp_stats ccs, ocs; @@ -153,47 +158,53 @@ intpr() printf(" BYTE PACK BYTE PACK RATIO | "); printf(" BYTE PACK BYTE PACK RATIO"); } else { - printf("%8.8s %6.6s %6.6s %6.6s %6.6s", - "IN", "PACK", "VJCOMP", "VJUNC", "VJERR"); + printf("%8.8s %6.6s %6.6s", + "IN", "PACK", "VJCOMP"); + + if (!rflag) + printf(" %6.6s %6.6s", "VJUNC", "VJERR"); if (vflag) printf(" %6.6s %6.6s", "VJTOSS", "NON-VJ"); if (rflag) printf(" %6.6s %6.6s", "RATIO", "UBYTE"); - printf(" | %8.8s %6.6s %6.6s %6.6s %6.6s", - "OUT", "PACK", "VJCOMP", "VJUNC", "NON-VJ"); + printf(" | %8.8s %6.6s %6.6s", + "OUT", "PACK", "VJCOMP"); + + if (!rflag) + printf(" %6.6s %6.6s", "VJUNC", "NON-VJ"); if (vflag) printf(" %6.6s %6.6s", "VJSRCH", "VJMISS"); - if(rflag) + if (rflag) printf(" %6.6s %6.6s", "RATIO", "UBYTE"); } putchar('\n'); } - + if (zflag) { printf("%8u %6u %8u %6u %6.2f", W(d.comp_bytes), W(d.comp_packets), W(d.inc_bytes), W(d.inc_packets), - ccs.d.ratio == 0? 0.0: - 1 - 1.0 / ccs.d.ratio * 256.0); + ccs.d.ratio * 256.0); printf(" | %8u %6u %8u %6u %6.2f", W(c.comp_bytes), W(c.comp_packets), W(c.inc_bytes), W(c.inc_packets), - ccs.c.ratio == 0? 0.0: - 1 - 1.0 / ccs.c.ratio * 256.0); + ccs.c.ratio * 256.0); } else { - printf("%8u %6u %6u %6u %6u", + printf("%8u %6u %6u", V(p.ppp_ibytes), V(p.ppp_ipackets), - V(vj.vjs_compressedin), - V(vj.vjs_uncompressedin), - V(vj.vjs_errorin)); + V(vj.vjs_compressedin)); + if (!rflag) + printf(" %6u %6u", + V(vj.vjs_uncompressedin), + V(vj.vjs_errorin)); if (vflag) printf(" %6u %6u", V(vj.vjs_tossed), @@ -203,14 +214,16 @@ intpr() V(vj.vjs_errorin)); if (rflag) printf(" %6.2f %6u", - CRATE(ccs.d), + CRATE(d), W(d.unc_bytes)); - printf(" | %8u %6u %6u %6u %6u", + printf(" | %8u %6u %6u", V(p.ppp_obytes), V(p.ppp_opackets), - V(vj.vjs_compressed), - V(vj.vjs_packets) - V(vj.vjs_compressed), - V(p.ppp_opackets) - V(vj.vjs_packets)); + V(vj.vjs_compressed)); + if (!rflag) + printf(" %6u %6u", + V(vj.vjs_packets) - V(vj.vjs_compressed), + V(p.ppp_opackets) - V(vj.vjs_packets)); if (vflag) printf(" %6u %6u", V(vj.vjs_searches), @@ -218,7 +231,7 @@ intpr() if (rflag) printf(" %6.2f %6u", - CRATE(ccs.c), + CRATE(c), W(c.unc_bytes)); } @@ -237,8 +250,10 @@ intpr() sigsetmask(oldmask); signalled = 0; (void)alarm(interval); - old = cur; - ocs = ccs; + if (!aflag) { + old = cur; + ocs = ccs; + } } } @@ -256,8 +271,11 @@ main(argc, argv) else ++progname; - while ((c = getopt(argc, argv, "vrzc:w:")) != -1) { + while ((c = getopt(argc, argv, "avrzc:w:")) != -1) { switch (c) { + case 'a': + ++aflag; + break; case 'v': ++vflag; break; -- cgit v1.2.3