Updated to follow the example of slstats(8) more closely.
This commit is contained in:
parent
647f483937
commit
b00e161b26
|
@ -1,49 +1,28 @@
|
|||
.\" @(#) $Header: /cvsroot/src/usr.sbin/pppd/pppstats/Attic/pppstats.8,v 1.3 1995/03/11 21:05:17 glass Exp $ (LBL)
|
||||
.\" @(#) $Header: /cvsroot/src/usr.sbin/pppd/pppstats/Attic/pppstats.8,v 1.4 1995/08/17 11:44:51 paulus Exp $ (LBL)
|
||||
.Dd November 15, 1994
|
||||
.Dt PPPSTATS/SLSTATS 8
|
||||
.Dt PPPSTATS 8
|
||||
.Sh NAME
|
||||
.Nm pppstats ,
|
||||
.Nm slstats
|
||||
.Nd report statistics for the specified PPP or SLIP interface
|
||||
.Nm pppstats
|
||||
.Nd report statistics for the specified PPP interface
|
||||
.Sh SYNOPSIS
|
||||
.Nm pppstats
|
||||
.Op Fl v
|
||||
.Op Fl r
|
||||
.Op Fl z
|
||||
.Op Fl c Ar count
|
||||
.Op Fl w Ar wait
|
||||
.Op Fl M Ar core
|
||||
.Op Fl N Ar system
|
||||
.Op Ar interface
|
||||
.Nm slstats
|
||||
.Op Fl v
|
||||
.Op Fl c Ar count
|
||||
.Op Fl w Ar wait
|
||||
.Op Fl M Ar core
|
||||
.Op Fl N Ar system
|
||||
.Op Ar interface
|
||||
.Sh DESCRIPTION
|
||||
.Pp
|
||||
The
|
||||
.Nm pppstats
|
||||
utility reports PPP-related statistics for the specified PPP
|
||||
utility reports PPP-related statistics at regular intervals for the
|
||||
specified PPP
|
||||
.Ar interface .
|
||||
If the
|
||||
.Ar interface
|
||||
is unspecified, it will default to ppp0.
|
||||
.Pp
|
||||
The
|
||||
.Nm slstats
|
||||
utility reports SLIP-related statistics for the specified SLIP
|
||||
.Ar interface .
|
||||
If the
|
||||
.Ar interface
|
||||
is unspecified, it will default to sl0.
|
||||
.Pp
|
||||
Otherwise
|
||||
.Nm pppstats
|
||||
and
|
||||
.Nm slstats
|
||||
function identically. Both programs will report interface-specific
|
||||
statistics at regular intervals. The display is split horizontally
|
||||
The display is split horizontally
|
||||
into input and output sections containing columns of statistics
|
||||
describing the properties and volume of packets received and
|
||||
transmitted by the interface.
|
||||
|
@ -58,51 +37,67 @@ The options are as follows:
|
|||
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. If no
|
||||
repeat
|
||||
subsequent report is for the time period since the last display.
|
||||
If this option is not specified, the default repeat
|
||||
.Ar count
|
||||
is specified, the default is infinity.
|
||||
is 1 if the
|
||||
.Fl w
|
||||
option is not specified, otherwise infinity.
|
||||
.It Fl r
|
||||
Display additional statistics summarizing the compression ratio
|
||||
achieved by the packet compression algorithm in use.
|
||||
.It Fl v
|
||||
Display additional statistics demonstrating the efficacy of VJ header
|
||||
compression and providing more explicit information on failure
|
||||
distribution.
|
||||
compression and providing more explicit information on the operation
|
||||
of the algorithm.
|
||||
.It Fl w Ar wait
|
||||
Pause
|
||||
.Ar wait
|
||||
seconds between each display. If no
|
||||
.Ar wait
|
||||
interval is specified, the default is 5 seconds.
|
||||
.It Fl M Ar core
|
||||
Extract values associated with the name list from the specified core
|
||||
instead of the default
|
||||
.Pa /dev/kmem .
|
||||
.It Fl N Ar system
|
||||
Extract the name list from the specified system instead of the default
|
||||
.Pa /netbsd .
|
||||
.It Fl z
|
||||
Instead of the standard display, show statistics indicating the
|
||||
performance of the packet compression algorithm in use.
|
||||
.El
|
||||
.Pp
|
||||
The following fields are printed on the input side:
|
||||
The following fields are printed on the input side when the
|
||||
.Fl z
|
||||
option is not used:
|
||||
.Bl -tag -width search
|
||||
.It Li IN
|
||||
The total number of bytes received by this interface.
|
||||
.It Li PACK
|
||||
The total number of packets received by this interface.
|
||||
.It Li COMP
|
||||
.It Li VJCOMP
|
||||
The number of compressed TCP packets received by this interface.
|
||||
.It Li UNCOMP
|
||||
.It Li VJUNC
|
||||
The number of uncompressed TCP packets received by this interface.
|
||||
.It Li ERR
|
||||
The number of packets received by this interface of unknown type.
|
||||
.It Li TOSS
|
||||
The number of packets dropped on reception by this interface. Only
|
||||
reported when the
|
||||
.It Li VJERR
|
||||
The number of corrupted or bogus packets received by this interface.
|
||||
.It Li VJTOSS
|
||||
The number of VJ header-compressed TCP packets dropped on reception by
|
||||
this interface. Only reported when the
|
||||
.Fl v
|
||||
option is specified.
|
||||
.It Li IP
|
||||
.It Li NON-VJ
|
||||
The total number of non-TCP packets received by this interface. Only
|
||||
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
|
||||
.Fl r
|
||||
option is specified.
|
||||
.It Li UBYTE
|
||||
The total number of bytes received, after decompression of compressed
|
||||
packets. Only reported when the
|
||||
.Fl r
|
||||
option is specified.
|
||||
.El
|
||||
.Pp
|
||||
The following fields are printed on the output side:
|
||||
|
@ -111,30 +106,74 @@ The following fields are printed on the output side:
|
|||
The total number of bytes transmitted from this interface.
|
||||
.It Li PACK
|
||||
The total number of packets transmitted from this interface.
|
||||
.It Li COMP
|
||||
The number of TCP packets compressed and then transmitted from this interface.
|
||||
.It Li UNCOMP
|
||||
The number of uncompressed TCP packets transmitted from this interface.
|
||||
.It Li IP
|
||||
.It Li VJCOMP
|
||||
The number of TCP packets transmitted from this interface with
|
||||
VJ-compressed TCP headers.
|
||||
.It Li VJUNC
|
||||
The number of TCP packets transmitted from this interface with
|
||||
VJ-uncompressed TCP headers.
|
||||
.It Li NON-VJ
|
||||
The total number of non-TCP packets transmitted from this interface.
|
||||
.It Li SEARCH
|
||||
The number of searches for the cached header entry for a compressed
|
||||
packet. Only reported when the
|
||||
.It Li VJSRCH
|
||||
The number of searches for the cached header entry for a VJ header
|
||||
compressed TCP packet. Only reported when the
|
||||
.Fl v
|
||||
option is specified.
|
||||
.It Li MISS
|
||||
.It Li VJMISS
|
||||
The number of failed searches for the cached header entry for a
|
||||
compressed packet. Only reported when the
|
||||
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.
|
||||
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
|
||||
option is specified.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width /dev/kmem -compact
|
||||
.It Pa /netbsd
|
||||
Default kernel namelist.
|
||||
.It Pa /dev/kmem
|
||||
Default memory file.
|
||||
.Pp
|
||||
When the
|
||||
.Fl z
|
||||
option is specified,
|
||||
.Nm pppstats
|
||||
instead displays the following fields, relating to the packet
|
||||
compression algorithm currently in use. If packet compression is not
|
||||
in use, these fields will all display zeroes. The fields displayed on
|
||||
the input side are:
|
||||
.Bl -tag -width search
|
||||
.It Li COMPRESSED BYTE
|
||||
The number of bytes of compressed packets received.
|
||||
.It Li COMPRESSED PACK
|
||||
The number of compressed packets received.
|
||||
.It Li INCOMPRESSIBLE BYTE
|
||||
The number of bytes of incompressible packets (that is, those which
|
||||
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.
|
||||
.El
|
||||
.Pp
|
||||
The fields displayed on the output side are:
|
||||
.Bl -tag -width search
|
||||
.It Li COMPRESSED BYTE
|
||||
The number of bytes of compressed packets transmitted.
|
||||
.It Li COMPRESSED PACK
|
||||
The number of compressed packets transmitted.
|
||||
.It Li INCOMPRESSIBLE BYTE
|
||||
The number of bytes of incompressible packets transmitted (that is,
|
||||
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.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr pppd 8 ,
|
||||
.Xr slattach 8
|
||||
.Xr pppd 8
|
||||
|
|
|
@ -1,20 +1,12 @@
|
|||
/*
|
||||
* print PPP statistics:
|
||||
* pppstats [-i interval] [-v] [-r] [-c] [interface]
|
||||
* pppstats [-v] [-r] [-z] [-c count] [-w wait] [interface]
|
||||
*
|
||||
* -i <update interval in seconds>
|
||||
* -v Verbose mode for default display
|
||||
* -r Show compression ratio in default display
|
||||
* -c Show Compression statistics instead of default display
|
||||
* -z Show compression statistics instead of default display
|
||||
*
|
||||
*
|
||||
* History:
|
||||
* perkins@cps.msu.edu: Added compression statistics and alternate
|
||||
* display. 11/94
|
||||
|
||||
* Brad Parker (brad@cayman.com) 6/92
|
||||
*
|
||||
* from the original "slstats" by Van Jaconson
|
||||
* from the original "slstats" by Van Jacobson
|
||||
*
|
||||
* Copyright (c) 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
|
@ -36,125 +28,105 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: pppstats.c,v 1.10 1995/07/04 23:43:54 paulus Exp $";
|
||||
static char rcsid[] = "$Id: pppstats.c,v 1.11 1995/08/17 11:44:53 paulus Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <nlist.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <net/ppp_defs.h>
|
||||
|
||||
#ifdef __svr4__
|
||||
#include <sys/stropts.h>
|
||||
#include <net/pppio.h> /* SVR4, Solaris 2, etc. */
|
||||
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <net/ppp_defs.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_ppp.h>
|
||||
|
||||
#ifndef STREAMS
|
||||
#include <net/if_ppp.h> /* BSD, Linux, NeXT, etc. */
|
||||
|
||||
#else /* SunOS 4, AIX 4, OSF/1, etc. */
|
||||
#define PPP_STATS 1 /* should be defined iff it is in ppp_if.c */
|
||||
#include <sys/stream.h>
|
||||
#include <net/ppp_str.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int vflag, rflag, cflag;
|
||||
unsigned interval = 5;
|
||||
int vflag, rflag, zflag; /* select type of display */
|
||||
int interval, count;
|
||||
int infinite;
|
||||
int unit;
|
||||
int s; /* socket file descriptor */
|
||||
int signalled; /* set if alarm goes off "early" */
|
||||
char *progname;
|
||||
char interface[IFNAMSIZ];
|
||||
|
||||
extern char *malloc();
|
||||
void catchalarm __P((int));
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
--argc; ++argv;
|
||||
while (argc > 0) {
|
||||
if (strcmp(argv[0], "-v") == 0) {
|
||||
++vflag;
|
||||
++argv, --argc;
|
||||
continue;
|
||||
}
|
||||
if (strcmp(argv[0], "-r") == 0) {
|
||||
++rflag;
|
||||
++argv, --argc;
|
||||
continue;
|
||||
}
|
||||
if (strcmp(argv[0], "-c") == 0) {
|
||||
++cflag;
|
||||
++argv, --argc;
|
||||
continue;
|
||||
}
|
||||
if (strcmp(argv[0], "-i") == 0 && argv[1] &&
|
||||
isdigit(argv[1][0])) {
|
||||
interval = atoi(argv[1]);
|
||||
if (interval < 0)
|
||||
usage();
|
||||
++argv, --argc;
|
||||
++argv, --argc;
|
||||
continue;
|
||||
}
|
||||
if (isdigit(argv[0][0])) {
|
||||
unit = atoi(argv[0]);
|
||||
if (unit < 0)
|
||||
usage();
|
||||
++argv, --argc;
|
||||
continue;
|
||||
}
|
||||
usage();
|
||||
}
|
||||
|
||||
#ifdef __svr4__
|
||||
if ((s = open("/dev/ppp", O_RDONLY)) < 0) {
|
||||
perror("pppstats: Couldn't open /dev/ppp: ");
|
||||
exit(1);
|
||||
}
|
||||
if (strioctl(s, PPPIO_ATTACH, &unit, sizeof(int), 0) < 0) {
|
||||
fprintf(stderr, "pppstats: ppp%d is not available\n", unit);
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
perror("couldn't create IP socket");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
intpr();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: pppstats [-v] [-r] [-c] [-i interval] [unit]\n");
|
||||
fprintf(stderr, "Usage: %s [-v|-r|-z] [-c count] [-w wait] [interface]\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#define V(offset) (line % 20? cur.offset - old.offset: cur.offset)
|
||||
#define W(offset) (line % 20? ccs.offset - ocs.offset: ccs.offset)
|
||||
/*
|
||||
* Called if an interval expires before intpr has completed a loop.
|
||||
* Sets a flag to not wait for the alarm.
|
||||
*/
|
||||
void
|
||||
catchalarm(arg)
|
||||
int arg;
|
||||
{
|
||||
signalled = 1;
|
||||
}
|
||||
|
||||
#define CRATE(comp, inc, unc) ((unc) == 0? 0.0: \
|
||||
1.0 - (double)((comp) + (inc)) / (unc))
|
||||
void
|
||||
get_ppp_stats(curp)
|
||||
struct ppp_stats *curp;
|
||||
{
|
||||
struct ifpppstatsreq req;
|
||||
|
||||
strncpy(req.ifr_name, interface, sizeof(req.ifr_name));
|
||||
if (ioctl(s, SIOCGPPPSTATS, &req) == 0) {
|
||||
*curp = req.stats;
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s: ", progname);
|
||||
if (errno == ENOTTY)
|
||||
errx(1, "kernel support missing");
|
||||
else
|
||||
err(1, "couldn't get PPP statistics");
|
||||
}
|
||||
|
||||
get_ppp_cstats(csp)
|
||||
struct ppp_comp_stats *csp;
|
||||
{
|
||||
struct ifpppcstatsreq creq;
|
||||
|
||||
strncpy(creq.ifr_name, interface, sizeof(creq.ifr_name));
|
||||
if (ioctl(s, SIOCGPPPCSTATS, &creq) == 0) {
|
||||
*csp = creq.stats;
|
||||
return;
|
||||
}
|
||||
if (errno == ENOTTY) {
|
||||
if (zflag)
|
||||
errx(1, "no kernel compression support\n");
|
||||
warnx("no kernel compression support\n");
|
||||
rflag = 0;
|
||||
} else
|
||||
err(1, "couldn't get PPP compression stats");
|
||||
}
|
||||
|
||||
|
||||
#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))
|
||||
|
||||
/*
|
||||
* Print a running summary of interface statistics.
|
||||
* Repeat display every interval seconds, showing statistics
|
||||
* collected over that interval. Assumes that interval is non-zero.
|
||||
* First line printed at top of screen is always cumulative.
|
||||
* First line printed is cumulative.
|
||||
*/
|
||||
void
|
||||
intpr()
|
||||
{
|
||||
register int line = 0;
|
||||
|
@ -167,7 +139,7 @@ intpr()
|
|||
|
||||
while (1) {
|
||||
get_ppp_stats(&cur);
|
||||
if (cflag || rflag)
|
||||
if (zflag || rflag)
|
||||
get_ppp_cstats(&ccs);
|
||||
|
||||
(void)signal(SIGALRM, catchalarm);
|
||||
|
@ -175,97 +147,94 @@ intpr()
|
|||
(void)alarm(interval);
|
||||
|
||||
if ((line % 20) == 0) {
|
||||
if (line > 0)
|
||||
putchar('\n');
|
||||
if (cflag) {
|
||||
|
||||
printf("%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
|
||||
"ubyte", "upack", "cbyte", "cpack", "ibyte", "ipack", "ratio");
|
||||
printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
|
||||
"ubyte", "upack", "cbyte", "cpack", "ibyte", "ipack", "ratio");
|
||||
putchar('\n');
|
||||
if (zflag) {
|
||||
printf("IN: COMPRESSED INCOMPRESSIBLE COMP | ");
|
||||
printf("OUT: COMPRESSED INCOMPRESSIBLE COMP\n");
|
||||
printf(" BYTE PACK BYTE PACK RATIO | ");
|
||||
printf(" BYTE PACK BYTE PACK RATIO");
|
||||
} else {
|
||||
|
||||
printf("%6.6s %6.6s %6.6s %6.6s %6.6s",
|
||||
"in", "pack", "comp", "uncomp", "err");
|
||||
printf("%8.8s %6.6s %6.6s %6.6s %6.6s",
|
||||
"IN", "PACK", "VJCOMP", "VJUNC", "VJERR");
|
||||
if (vflag)
|
||||
printf(" %6.6s %6.6s", "toss", "ip");
|
||||
printf(" %6.6s %6.6s", "VJTOSS", "NON-VJ");
|
||||
if (rflag)
|
||||
printf(" %6.6s %6.6s", "ratio", "ubyte");
|
||||
printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s",
|
||||
"out", "pack", "comp", "uncomp", "ip");
|
||||
printf(" %6.6s %6.6s", "RATIO", "UBYTE");
|
||||
printf(" | %8.8s %6.6s %6.6s %6.6s %6.6s",
|
||||
"OUT", "PACK", "VJCOMP", "VJUNC", "NON-VJ");
|
||||
if (vflag)
|
||||
printf(" %6.6s %6.6s", "search", "miss");
|
||||
printf(" %6.6s %6.6s", "VJSRCH", "VJMISS");
|
||||
if(rflag)
|
||||
printf(" %6.6s %6.6s", "ratio", "ubyte");
|
||||
printf(" %6.6s %6.6s", "RATIO", "UBYTE");
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
memset(&old, 0, sizeof(old));
|
||||
memset(&ocs, 0, sizeof(ocs));
|
||||
}
|
||||
|
||||
if (cflag) {
|
||||
printf("%6d %6d %6d %6d %6d %6d %6.2f",
|
||||
W(d.unc_bytes),
|
||||
W(d.unc_packets),
|
||||
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),
|
||||
W(d.ratio) == 0? 0.0: 1 - 1.0 / W(d.ratio) * 256.0);
|
||||
ccs.d.ratio == 0? 0.0:
|
||||
1 - 1.0 / ccs.d.ratio * 256.0);
|
||||
|
||||
printf(" | %6d %6d %6d %6d %6d %6d %6.2f",
|
||||
W(c.unc_bytes),
|
||||
W(c.unc_packets),
|
||||
printf(" | %8u %6u %8u %6u %6.2f",
|
||||
W(c.comp_bytes),
|
||||
W(c.comp_packets),
|
||||
W(c.inc_bytes),
|
||||
W(c.inc_packets),
|
||||
W(d.ratio) == 0? 0.0: 1 - 1.0 / W(d.ratio) * 256.0);
|
||||
ccs.c.ratio == 0? 0.0:
|
||||
1 - 1.0 / ccs.c.ratio * 256.0);
|
||||
|
||||
putchar('\n');
|
||||
} else {
|
||||
|
||||
printf("%6d %6d %6d %6d %6d",
|
||||
printf("%8u %6u %6u %6u %6u",
|
||||
V(p.ppp_ibytes),
|
||||
V(p.ppp_ipackets), V(vj.vjs_compressedin),
|
||||
V(vj.vjs_uncompressedin), V(vj.vjs_errorin));
|
||||
V(p.ppp_ipackets),
|
||||
V(vj.vjs_compressedin),
|
||||
V(vj.vjs_uncompressedin),
|
||||
V(vj.vjs_errorin));
|
||||
if (vflag)
|
||||
printf(" %6d %6d", V(vj.vjs_tossed),
|
||||
V(p.ppp_ipackets) - V(vj.vjs_compressedin) -
|
||||
V(vj.vjs_uncompressedin) - V(vj.vjs_errorin));
|
||||
printf(" %6u %6u",
|
||||
V(vj.vjs_tossed),
|
||||
V(p.ppp_ipackets) -
|
||||
V(vj.vjs_compressedin) -
|
||||
V(vj.vjs_uncompressedin) -
|
||||
V(vj.vjs_errorin));
|
||||
if (rflag)
|
||||
printf(" %6.2f %6d",
|
||||
CRATE(W(d.comp_bytes), W(d.unc_bytes), W(d.unc_bytes)),
|
||||
printf(" %6.2f %6u",
|
||||
CRATE(ccs.d),
|
||||
W(d.unc_bytes));
|
||||
printf(" | %6d %6d %6d %6d %6d", V(p.ppp_obytes),
|
||||
V(p.ppp_opackets), V(vj.vjs_compressed),
|
||||
printf(" | %8u %6u %6u %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));
|
||||
if (vflag)
|
||||
printf(" %6d %6d", V(vj.vjs_searches), V(vj.vjs_misses));
|
||||
printf(" %6u %6u",
|
||||
V(vj.vjs_searches),
|
||||
V(vj.vjs_misses));
|
||||
|
||||
if (rflag)
|
||||
printf(" %6.2f %6d",
|
||||
CRATE(W(d.comp_bytes), W(d.unc_bytes), W(d.unc_bytes)),
|
||||
printf(" %6.2f %6u",
|
||||
CRATE(ccs.c),
|
||||
W(c.unc_bytes));
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
fflush(stdout);
|
||||
line++;
|
||||
if (interval == 0)
|
||||
exit(0);
|
||||
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGALRM);
|
||||
sigprocmask(SIG_BLOCK, &mask, &oldmask);
|
||||
if (! signalled) {
|
||||
sigemptyset(&mask);
|
||||
sigsuspend(&mask);
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, &oldmask, NULL);
|
||||
count--;
|
||||
if (!infinite && !count)
|
||||
break;
|
||||
|
||||
oldmask = sigblock(sigmask(SIGALRM));
|
||||
if (signalled == 0)
|
||||
sigpause(0);
|
||||
sigsetmask(oldmask);
|
||||
signalled = 0;
|
||||
(void)alarm(interval);
|
||||
old = cur;
|
||||
|
@ -273,110 +242,69 @@ intpr()
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called if an interval expires before sidewaysintpr has completed a loop.
|
||||
* Sets a flag to not wait for the alarm.
|
||||
*/
|
||||
void catchalarm(arg)
|
||||
int arg;
|
||||
{
|
||||
signalled = 1;
|
||||
}
|
||||
|
||||
#ifndef __svr4__
|
||||
get_ppp_stats(curp)
|
||||
struct ppp_stats *curp;
|
||||
{
|
||||
struct ifpppstatsreq req;
|
||||
|
||||
#ifdef _linux_
|
||||
req.stats_ptr = &req.stats;
|
||||
#undef ifr_name
|
||||
#define ifr_name ifr__name
|
||||
#endif
|
||||
|
||||
sprintf(req.ifr_name, "ppp%d", unit);
|
||||
if (ioctl(s, SIOCGPPPSTATS, &req) < 0) {
|
||||
if (errno == ENOTTY)
|
||||
fprintf(stderr, "pppstats: kernel support missing\n");
|
||||
else
|
||||
perror("ioctl(SIOCGPPPSTATS)");
|
||||
exit(1);
|
||||
}
|
||||
*curp = req.stats;
|
||||
}
|
||||
|
||||
get_ppp_cstats(csp)
|
||||
struct ppp_comp_stats *csp;
|
||||
{
|
||||
struct ifpppcstatsreq creq;
|
||||
|
||||
#ifdef _linux_
|
||||
creq.stats_ptr = &creq.stats;
|
||||
#undef ifr_name
|
||||
#define ifr_name ifr__name
|
||||
#endif
|
||||
|
||||
sprintf(creq.ifr_name, "ppp%d", unit);
|
||||
if (ioctl(s, SIOCGPPPCSTATS, &creq) < 0) {
|
||||
if (errno == ENOTTY) {
|
||||
fprintf(stderr, "pppstats: no kernel compression support\n");
|
||||
if (cflag)
|
||||
exit(1);
|
||||
rflag = 0;
|
||||
} else {
|
||||
perror("ioctl(SIOCGPPPCSTATS)");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
*csp = creq.stats;
|
||||
}
|
||||
|
||||
#else /* __svr4__ */
|
||||
get_ppp_stats(curp)
|
||||
struct ppp_stats *curp;
|
||||
{
|
||||
if (strioctl(s, PPPIO_GETSTAT, curp, 0, sizeof(*curp)) < 0) {
|
||||
if (errno == EINVAL)
|
||||
fprintf(stderr, "pppstats: kernel support missing\n");
|
||||
else
|
||||
perror("pppstats: Couldn't get statistics");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
get_ppp_cstats(csp)
|
||||
struct ppp_comp_stats *csp;
|
||||
{
|
||||
if (strioctl(s, PPPIO_GETCSTAT, csp, 0, sizeof(*csp)) < 0) {
|
||||
if (errno == ENOTTY) {
|
||||
fprintf(stderr, "pppstats: no kernel compression support\n");
|
||||
if (cflag)
|
||||
exit(1);
|
||||
rflag = 0;
|
||||
} else {
|
||||
perror("pppstats: Couldn't get compression statistics");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
strioctl(fd, cmd, ptr, ilen, olen)
|
||||
int fd, cmd, ilen, olen;
|
||||
char *ptr;
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
struct strioctl str;
|
||||
int c;
|
||||
struct ifreq ifr;
|
||||
|
||||
str.ic_cmd = cmd;
|
||||
str.ic_timout = 0;
|
||||
str.ic_len = ilen;
|
||||
str.ic_dp = ptr;
|
||||
if (ioctl(fd, I_STR, &str) == -1)
|
||||
return -1;
|
||||
if (str.ic_len != olen)
|
||||
fprintf(stderr, "strioctl: expected %d bytes, got %d for cmd %x\n",
|
||||
olen, str.ic_len, cmd);
|
||||
return 0;
|
||||
strcpy(interface, "ppp0");
|
||||
if ((progname = strrchr(argv[0], '/')) == NULL)
|
||||
progname = argv[0];
|
||||
else
|
||||
++progname;
|
||||
|
||||
while ((c = getopt(argc, argv, "vrzc:w:")) != -1) {
|
||||
switch (c) {
|
||||
case 'v':
|
||||
++vflag;
|
||||
break;
|
||||
case 'r':
|
||||
++rflag;
|
||||
break;
|
||||
case 'z':
|
||||
++zflag;
|
||||
break;
|
||||
case 'c':
|
||||
count = atoi(optarg);
|
||||
if (count <= 0)
|
||||
usage();
|
||||
break;
|
||||
case 'w':
|
||||
interval = atoi(optarg);
|
||||
if (interval <= 0)
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (!interval && count)
|
||||
interval = 5;
|
||||
if (interval && !count)
|
||||
infinite = 1;
|
||||
if (!interval && !count)
|
||||
count = 1;
|
||||
|
||||
if (argc > 1)
|
||||
usage();
|
||||
if (argc > 0)
|
||||
strncpy(interface, argv[0], sizeof(interface));
|
||||
|
||||
if (sscanf(interface, "ppp%d", &unit) != 1)
|
||||
errx(1, "invalid interface '%s' specified\n", interface);
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0)
|
||||
err(1, "couldn't create IP socket");
|
||||
strcpy(ifr.ifr_name, interface);
|
||||
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0)
|
||||
errx(1, "nonexistent interface '%s' specified\n", interface);
|
||||
|
||||
intpr();
|
||||
exit(0);
|
||||
}
|
||||
#endif /* __svr4__ */
|
||||
|
|
Loading…
Reference in New Issue