pppstats(8) and slstats(8) has been rewritten and merged
semantics and interface now follow the iostat/vmstat standard for statistics reporting. man page rewritten to match new semantics and interface. now shared.
This commit is contained in:
parent
578e1d6f3a
commit
6614c5a7b3
|
@ -1,10 +1,12 @@
|
||||||
# $Id: Makefile,v 1.5 1994/08/26 05:13:11 paulus Exp $
|
# $Id: Makefile,v 1.6 1994/11/15 07:20:52 glass Exp $
|
||||||
|
|
||||||
PROG= pppstats
|
PROG= pppstats
|
||||||
SRCS= pppstats.c
|
SRCS= pppstats.c
|
||||||
|
CFLAGS+= -DPPP
|
||||||
LDADD= -lkvm
|
LDADD= -lkvm
|
||||||
DPADD= ${LIBKVM}
|
DPADD= ${LIBKVM}
|
||||||
MAN8= pppstats.0
|
MAN8= pppstats.0
|
||||||
|
MLINKS= pppstats.8 slstats.8
|
||||||
BINMODE=2555
|
BINMODE=2555
|
||||||
BINGRP= kmem
|
BINGRP= kmem
|
||||||
BINDIR= /usr/sbin
|
BINDIR= /usr/sbin
|
||||||
|
|
|
@ -1,39 +1,140 @@
|
||||||
.\" @(#) $Id: pppstats.8,v 1.1 1994/08/26 05:13:13 paulus Exp $
|
.\" @(#) $Header: /cvsroot/src/usr.sbin/pppd/pppstats/Attic/pppstats.8,v 1.2 1994/11/15 07:28:02 glass Exp $ (LBL)
|
||||||
.TH PPPSTATS 8 "23 Aug 1994"
|
.Dd November 15, 1994
|
||||||
.SH NAME
|
.Dt PPPSTATS/SLSTATS 8
|
||||||
pppstats \- print PPP statistics
|
.Sh NAME
|
||||||
.SH SYNOPSIS
|
.Nm pppstats ,
|
||||||
.B pppstats
|
.Nm slstats
|
||||||
[
|
.Nd report statistics for the specified PPP or SLIP interface
|
||||||
.B -v
|
.Sh SYNOPSIS
|
||||||
] [
|
.Nm pppstats
|
||||||
.B -i
|
.Op Fl v
|
||||||
.I <secs>
|
.Op Fl c Ar count
|
||||||
] [
|
.Op Fl w Ar wait
|
||||||
.I <unit#>
|
.Op Fl M Ar core
|
||||||
]
|
.Op Fl N Ar system
|
||||||
.ti 12
|
.Op Ar interface
|
||||||
.br
|
.Nm slstats
|
||||||
[
|
.Op Fl v
|
||||||
.I objectfile
|
.Op Fl c Ar count
|
||||||
[
|
.Op Fl w Ar wait
|
||||||
.I corefile
|
.Op Fl M Ar core
|
||||||
]]
|
.Op Fl N Ar system
|
||||||
.SH DESCRIPTION
|
.Op Ar interface
|
||||||
.B pppstats
|
.Sh DESCRIPTION
|
||||||
prints PPP-related statistics.
|
.Pp
|
||||||
.PP
|
|
||||||
The
|
The
|
||||||
.B -v
|
.Nm pppstats
|
||||||
flag causes
|
utility reports PPP-related statistics for the specified PPP
|
||||||
.B pppstats
|
.Ar interface .
|
||||||
to display additional statistics, such as the number of packets tossed.
|
If the
|
||||||
.PP
|
.Ar interface
|
||||||
|
is unspecified, it will default to ppp0.
|
||||||
|
.Pp
|
||||||
The
|
The
|
||||||
.B -i
|
.Nm slstats
|
||||||
flag is used to specify the interval between printouts. The default is
|
utility reports SLIP-related statistics for the specified SLIP
|
||||||
5 seconds.
|
.Ar interface .
|
||||||
.PP
|
If the
|
||||||
.B pppstats
|
.Ar interface
|
||||||
must be installed set-group-id to kmem, or the user must have read
|
is unspecified, it will default to sl0.
|
||||||
access to /dev/kmem.
|
.Pp
|
||||||
|
Otherwise
|
||||||
|
.Nm pppstats
|
||||||
|
and
|
||||||
|
.Nm slstats
|
||||||
|
function identically. Both programs will report interface-specific
|
||||||
|
statistics at regular intervals. 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.
|
||||||
|
.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 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. If
|
||||||
|
no
|
||||||
|
.Ar wait
|
||||||
|
interval is specified, the default is 5 seconds.
|
||||||
|
.It Fl v
|
||||||
|
Display additional statistics demonstrating the efficacy of VJ header
|
||||||
|
compression and providing more explicit information on failure
|
||||||
|
distribution.
|
||||||
|
.It Fl w Ar wait
|
||||||
|
Pause
|
||||||
|
.Ar wait
|
||||||
|
seconds between each display. If no repeat
|
||||||
|
.Ar count
|
||||||
|
is specified, the default is infinity.
|
||||||
|
.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 .
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
The following fields are printed on the input side:
|
||||||
|
.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
|
||||||
|
The number of compressed TCP packets received by this interface.
|
||||||
|
.It Li UNCOMP
|
||||||
|
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
|
||||||
|
.Fl v
|
||||||
|
option is specified.
|
||||||
|
.It Li IP
|
||||||
|
The total number of non-TCP packets received by this interface. Only
|
||||||
|
reported when the
|
||||||
|
.Fl v
|
||||||
|
option is specified.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
The following fields are printed on the output side:
|
||||||
|
.Bl -tag -width search
|
||||||
|
.It Li OUT
|
||||||
|
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
|
||||||
|
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
|
||||||
|
.Fl v
|
||||||
|
option is specified.
|
||||||
|
.It Li MISS
|
||||||
|
The number of failed searches for the cached header entry for a
|
||||||
|
compressed packet. 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.
|
||||||
|
.El
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr pppd 8 ,
|
||||||
|
.Xr slattach 8
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* print PPP statistics:
|
* print PPP interface statistics:
|
||||||
* pppstats [-i interval] [-v] [interface] [system] [core]
|
* pppstats [-v] [-c count] [-w wait] [-M core] [-N system ] [interface]
|
||||||
|
* print SLIP interface statistics:
|
||||||
|
* slstats [-v] [-c count] [-w wait] [-M core] [-N system ] [interface]
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* Brad Parker (brad@cayman.com) 6/92
|
* Brad Parker (brad@cayman.com) 6/92
|
||||||
*
|
*
|
||||||
* from the original "slstats" by Van Jacobson
|
* from the original "slstats" by Van Jacobson
|
||||||
*
|
*
|
||||||
* Copyright (c) 1989 Regents of the University of California.
|
* Copyright (c) 1989, 1990, 1991, 1992 Regents of the University of
|
||||||
* All rights reserved.
|
* California. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms are permitted
|
* Redistribution and use in source and binary forms are permitted
|
||||||
* provided that the above copyright notice and this paragraph are
|
* provided that the above copyright notice and this paragraph are
|
||||||
|
@ -21,118 +24,89 @@
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
* Van Jacobson (van@ee.lbl.gov), Dec 31, 1989:
|
||||||
* - Initial distribution.
|
* - Initial distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$Id: pppstats.c,v 1.7 1994/05/14 19:00:35 cgd Exp $";
|
/*static char rcsid[] =
|
||||||
|
"@(#) $Header: /cvsroot/src/usr.sbin/pppd/pppstats/Attic/pppstats.c,v 1.8 1994/11/15 07:20:54 glass Exp $ (LBL)";*/
|
||||||
|
static char rcsid[] = "$Id: pppstats.c,v 1.8 1994/11/15 07:20:54 glass Exp $";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <nlist.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <kvm.h>
|
|
||||||
#include <paths.h>
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/mbuf.h>
|
#include <sys/mbuf.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/in_systm.h>
|
#include <netinet/in_systm.h>
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#include <netinet/ip_var.h>
|
#include <netinet/ip_var.h>
|
||||||
|
|
||||||
#define VJC 1
|
#define VJC 1 /* XXX */
|
||||||
|
#define INET /* XXX */
|
||||||
|
|
||||||
#include <net/slcompress.h>
|
#include <net/slcompress.h>
|
||||||
|
#include <net/if_slvar.h>
|
||||||
#include <net/if_ppp.h>
|
#include <net/if_ppp.h>
|
||||||
|
|
||||||
char *kmemf;
|
#include <ctype.h>
|
||||||
kvm_t *kd;
|
#include <errno.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <nlist.h>
|
||||||
|
#include <paths.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define V(offset) ((line != 0) ? sc->offset - osc->offset : sc->offset)
|
||||||
|
|
||||||
|
#ifdef PPP
|
||||||
|
#define STRUCT struct ppp_softc
|
||||||
|
#define NLIST_ENTRY "_ppp_softc"
|
||||||
|
#define INTERFACE_PREFIX "ppp"
|
||||||
|
#else
|
||||||
|
#define STRUCT struct sl_softc
|
||||||
|
#define NLIST_ENTRY "_sl_softc"
|
||||||
|
#define INTERFACE_PREFIX "sl"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct nlist nl[] = {
|
struct nlist nl[] = {
|
||||||
#define N_SOFTC 0
|
#define N_SOFTC 0
|
||||||
{ "_ppp_softc" },
|
{ NLIST_ENTRY },
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
char *system = _PATH_UNIX;
|
kvm_t *kd;
|
||||||
|
char *progname, interface[IFNAMSIZ];
|
||||||
int kflag;
|
int count, infinite, interval, signalled, unit, vflag;
|
||||||
int vflag;
|
|
||||||
unsigned interval = 5;
|
|
||||||
int unit;
|
|
||||||
|
|
||||||
extern char *malloc();
|
|
||||||
|
|
||||||
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], "-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;
|
|
||||||
}
|
|
||||||
if (kflag)
|
|
||||||
usage();
|
|
||||||
|
|
||||||
system = *argv;
|
|
||||||
++argv, --argc;
|
|
||||||
if (argc > 0) {
|
|
||||||
kmemf = *argv++;
|
|
||||||
--argc;
|
|
||||||
kflag++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* BSD4.3+ */
|
|
||||||
kd = kvm_open(system, kmemf, (char *)0, O_RDONLY, "pppstats");
|
|
||||||
if (kd == NULL)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
if (kvm_nlist(kd, nl)) {
|
|
||||||
fprintf(stderr, "pppstats: can't find symbols in nlist\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
intpr();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
fprintf(stderr,"usage: pppstats [-i interval] [-v] [unit] [system] [core]\n");
|
fprintf(stderr,
|
||||||
|
"usage: %s [-v] [-c count] [-w wait] [-M core] [-N system ] [interface]\n",
|
||||||
|
progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
u_char signalled; /* set if alarm goes off "early" */
|
/*
|
||||||
|
* Called if an interval expires before intpr has completed a loop.
|
||||||
#define V(offset) ((line % 20)? sc->offset - osc->offset : sc->offset)
|
* Sets a flag to not wait for the alarm.
|
||||||
|
*/
|
||||||
#define STRUCT struct ppp_softc
|
void
|
||||||
#define COMP sc_comp
|
catchalarm()
|
||||||
#define STATS sc_if
|
{
|
||||||
|
signalled = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print a running summary of interface statistics.
|
* Print a running summary of interface statistics.
|
||||||
|
@ -140,90 +114,168 @@ u_char signalled; /* set if alarm goes off "early" */
|
||||||
* collected over that interval. Assumes that interval is non-zero.
|
* collected over that interval. Assumes that interval is non-zero.
|
||||||
* First line printed at top of screen is always cumulative.
|
* First line printed at top of screen is always cumulative.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
intpr()
|
intpr()
|
||||||
{
|
{
|
||||||
register int line = 0;
|
|
||||||
int oldmask;
|
|
||||||
#ifdef __STDC__
|
|
||||||
void catchalarm(int);
|
|
||||||
#else
|
|
||||||
void catchalarm();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
STRUCT *sc, *osc;
|
STRUCT *sc, *osc;
|
||||||
|
off_t addr;
|
||||||
|
int oldmask, line = 0;
|
||||||
|
|
||||||
nl[N_SOFTC].n_value += unit * sizeof(STRUCT);
|
addr = nl[N_SOFTC].n_value + unit * sizeof(STRUCT);
|
||||||
sc = (STRUCT *) malloc(sizeof(STRUCT));
|
sc = (STRUCT *) malloc(sizeof(STRUCT));
|
||||||
osc = (STRUCT *) malloc(sizeof(STRUCT));
|
osc = (STRUCT *) malloc(sizeof(STRUCT));
|
||||||
|
memset(osc, 0, sizeof(STRUCT));
|
||||||
bzero((char *)osc, sizeof(STRUCT));
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (kvm_read(kd, nl[N_SOFTC].n_value, sc,
|
if (kvm_read(kd, addr, sc,
|
||||||
sizeof(STRUCT)) != sizeof(STRUCT)) {
|
sizeof(STRUCT)) != sizeof(STRUCT))
|
||||||
perror("kvm_read");
|
errx(1, "reading statistics: %s", kvm_geterr(kd));
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)signal(SIGALRM, catchalarm);
|
(void)signal(SIGALRM, catchalarm);
|
||||||
signalled = 0;
|
signalled = 0;
|
||||||
(void)alarm(interval);
|
(void)alarm(interval);
|
||||||
|
|
||||||
if ((line % 20) == 0) {
|
if ((line % 20) == 0) {
|
||||||
printf("%6.6s %6.6s %6.6s %6.6s %6.6s",
|
printf("%8.8s %6.6s %6.6s %6.6s %6.6s",
|
||||||
"in", "pack", "comp", "uncomp", "err");
|
"IN", "PACK", "COMP", "UNCOMP", "ERR");
|
||||||
if (vflag)
|
if (vflag)
|
||||||
printf(" %6.6s %6.6s", "toss", "ip");
|
printf(" %6.6s %6.6s", "TOSS", "IP");
|
||||||
printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s",
|
printf(" | %8.8s %6.6s %6.6s %6.6s %6.6s",
|
||||||
"out", "pack", "comp", "uncomp", "ip");
|
"OUT", "PACK", "COMP", "UNCOMP", "IP");
|
||||||
if (vflag)
|
if (vflag)
|
||||||
printf(" %6.6s %6.6s", "search", "miss");
|
printf(" %6.6s %6.6s", "SEARCH", "MISS");
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
printf("%8u %6d %6u %6u %6u",
|
||||||
printf("%6d %6d %6d %6d %6d",
|
V(sc_if.if_ibytes),
|
||||||
V(STATS.if_ibytes),
|
V(sc_if.if_ipackets),
|
||||||
V(STATS.if_ipackets),
|
V(sc_comp.sls_compressedin),
|
||||||
V(COMP.sls_compressedin),
|
V(sc_comp.sls_uncompressedin),
|
||||||
V(COMP.sls_uncompressedin),
|
V(sc_comp.sls_errorin));
|
||||||
V(COMP.sls_errorin));
|
|
||||||
if (vflag)
|
if (vflag)
|
||||||
printf(" %6d %6d",
|
printf(" %6u %6u",
|
||||||
V(COMP.sls_tossed),
|
V(sc_comp.sls_tossed),
|
||||||
V(STATS.if_ipackets) - V(COMP.sls_compressedin) -
|
V(sc_if.if_ipackets) -
|
||||||
V(COMP.sls_uncompressedin) - V(COMP.sls_errorin));
|
V(sc_comp.sls_compressedin) -
|
||||||
printf(" | %6d %6d %6d %6d %6d",
|
V(sc_comp.sls_uncompressedin) -
|
||||||
V(STATS.if_obytes),
|
V(sc_comp.sls_errorin));
|
||||||
V(STATS.if_opackets),
|
printf(" | %8u %6d %6u %6u %6u",
|
||||||
V(COMP.sls_compressed),
|
V(sc_if.if_obytes),
|
||||||
V(COMP.sls_packets) - V(COMP.sls_compressed),
|
V(sc_if.if_opackets),
|
||||||
V(STATS.if_opackets) - V(COMP.sls_packets));
|
V(sc_comp.sls_compressed),
|
||||||
|
V(sc_comp.sls_packets) - V(sc_comp.sls_compressed),
|
||||||
|
V(sc_if.if_opackets) - V(sc_comp.sls_packets));
|
||||||
if (vflag)
|
if (vflag)
|
||||||
printf(" %6d %6d",
|
printf(" %6u %6u",
|
||||||
V(COMP.sls_searches),
|
V(sc_comp.sls_searches),
|
||||||
V(COMP.sls_misses));
|
V(sc_comp.sls_misses));
|
||||||
|
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
|
count--;
|
||||||
|
if (!infinite && !count)
|
||||||
|
break;
|
||||||
oldmask = sigblock(sigmask(SIGALRM));
|
oldmask = sigblock(sigmask(SIGALRM));
|
||||||
if (! signalled) {
|
if (signalled == 0)
|
||||||
sigpause(0);
|
sigpause(0);
|
||||||
}
|
|
||||||
sigsetmask(oldmask);
|
sigsetmask(oldmask);
|
||||||
signalled = 0;
|
signalled = 0;
|
||||||
(void)alarm(interval);
|
(void)alarm(interval);
|
||||||
bcopy((char *)sc, (char *)osc, sizeof(STRUCT));
|
memcpy(osc, sc, sizeof(STRUCT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int
|
||||||
* Called if an interval expires before sidewaysintpr has completed a loop.
|
main(argc, argv)
|
||||||
* Sets a flag to not wait for the alarm.
|
int argc;
|
||||||
*/
|
char *argv[];
|
||||||
void catchalarm(arg)
|
|
||||||
int arg;
|
|
||||||
{
|
{
|
||||||
signalled = 1;
|
char errbuf[_POSIX2_LINE_MAX], tmp[IFNAMSIZ];
|
||||||
|
struct ifreq ifr;
|
||||||
|
char *kernel, *core;
|
||||||
|
int c, s;
|
||||||
|
|
||||||
|
kernel = core = NULL;
|
||||||
|
strcpy(interface, INTERFACE_PREFIX);
|
||||||
|
strcat(interface, "0");
|
||||||
|
if ((progname = strrchr(argv[0], '/')) == NULL)
|
||||||
|
progname = argv[0];
|
||||||
|
else
|
||||||
|
++progname;
|
||||||
|
|
||||||
|
while ((c = getopt(argc, argv, ":c:vw:M:N:")) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'c':
|
||||||
|
count = atoi(optarg);
|
||||||
|
if (count <= 0)
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
++vflag;
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
interval = atoi(optarg);
|
||||||
|
if (interval <= 0)
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
core = optarg;
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
kernel = optarg;
|
||||||
|
break;
|
||||||
|
case ':':
|
||||||
|
fprintf(stderr,
|
||||||
|
"option -%c requires an argument\n", optopt);
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
fprintf(stderr, "unrecognized option: -%c\n", optopt);
|
||||||
|
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) {
|
||||||
|
if (strlen(argv[0]) > sizeof(interface))
|
||||||
|
errx(1, "invalid interface specified %s", interface);
|
||||||
|
strcpy(interface, argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(tmp, INTERFACE_PREFIX);
|
||||||
|
strcat(tmp, "%d");
|
||||||
|
if (sscanf(interface, tmp, &unit) != 1)
|
||||||
|
errx(1, "invalid interface '%s' specified", interface);
|
||||||
|
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (s < 0)
|
||||||
|
err(1, "creating socket");
|
||||||
|
strcpy(ifr.ifr_name, interface);
|
||||||
|
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0)
|
||||||
|
errx(1, "unable to confirm existence of interface '%s'",
|
||||||
|
interface);
|
||||||
|
close(s);
|
||||||
|
|
||||||
|
kd = kvm_openfiles(kernel, core, NULL, O_RDONLY, errbuf);
|
||||||
|
if (kd == NULL)
|
||||||
|
errx(1, "%s", errbuf);
|
||||||
|
if (kvm_nlist(kd, nl) != 0)
|
||||||
|
errx(1, "%s", kvm_geterr(kd));
|
||||||
|
|
||||||
|
intpr();
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
# from: @(#)Makefile 5.6 (Berkeley) 4/23/91
|
# from: @(#)Makefile 5.6 (Berkeley) 4/23/91
|
||||||
# $Id: Makefile,v 1.3 1994/01/28 01:00:24 cgd Exp $
|
# $Id: Makefile,v 1.4 1994/11/15 07:21:40 glass Exp $
|
||||||
|
|
||||||
PROG= slstats
|
PROG= slstats
|
||||||
MAN8= slstats.0
|
SRCS= pppstats.c
|
||||||
|
.PATH: ${.CURDIR}/../pppd/pppstats
|
||||||
|
NOMAN=
|
||||||
DPADD= ${LIBKVM}
|
DPADD= ${LIBKVM}
|
||||||
LDADD= -lkvm
|
LDADD= -lkvm
|
||||||
BINGRP= kmem
|
BINGRP= kmem
|
||||||
|
|
Loading…
Reference in New Issue