* pppstats [-i interval] [-v] [interface] [system] [core]
* Brad Parker (brad@cayman.com) 6/92
* from the original "slstats" by Van Jaconson
* Copyright (c) 1989 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
#include <netinet/in_systm.h>
#include <netinet/ip_var.h>
#include <net/slcompress.h>
char *system
= "/vmunix";
char *system
= "/386bsd";
char *kmemf
= "/dev/kmem";
if (strcmp(argv
[0], "-v") == 0) {
if (strcmp(argv
[0], "-i") == 0 && argv
[1] &&
interval
= atoi(argv
[1]);
if (isdigit(argv
[0][0])) {
if (nlist(system
, nl
) < 0 || nl
[0].n_type
== 0) {
fprintf(stderr
, "%s: no namelist\n", system
);
kmem
= open(kmemf
, O_RDONLY
);
malloc((u_int
)(nl
[N_SYSSIZE
].n_value
* sizeof(struct pte
)));
fputs("netstat: can't get memory for Sysmap.\n", stderr
);
off
= nl
[N_SYSMAP
].n_value
& ~KERNBASE
;
(void)lseek(kmem
, off
, L_SET
);
(void)read(kmem
, (char *)Sysmap
,
(int)(nl
[N_SYSSIZE
].n_value
* sizeof(struct pte
)));
if ((kd
= kvm_open(system
, kmemf
, (char *)0, O_RDONLY
, NULL
)) == NULL
) {
if (kvm_openfiles(system
, kmemf
, (char *)0) == -1) {
fprintf(stderr
, "kvm_openfiles: %s", kvm_geterr());
fprintf(stderr
, "pppstats: can't find symbols in nlist\n");
* Seek into the kernel for a value.
base
= ctob(Sysmap
[btop(base
)].pg_pfnum
) + (base
& PGOFSET
);
return (lseek(fd
, base
, off
));
fprintf(stderr
,"usage: pppstats [-i interval] [-v] [unit] [system] [core]\n");
u_char signalled
; /* set if alarm goes off "early" */
#define V(offset) ((line % 20)? sc->offset - osc->offset : sc->offset)
* 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.
#define STRUCT struct ppp_if_info
#define STRUCT struct ppp_softc
nl
[N_SOFTC
].n_value
+= unit
* sizeof(struct ppp_softc
);
sc
= (STRUCT
*)malloc(sizeof(STRUCT
));
osc
= (STRUCT
*)malloc(sizeof(STRUCT
));
bzero((char *)osc
, sizeof(STRUCT
));
if (klseek(kmem
, (off_t
)nl
[N_SOFTC
].n_value
, 0) < 0)
if (read(kmem
, (char *)sc
, sizeof(STRUCT
)) <= 0)
if (kvm_read(kd
, nl
[N_SOFTC
].n_value
,
if (kvm_read(nl
[N_SOFTC
].n_value
,
(void)signal(SIGALRM
, catchalarm
);
printf("%6.6s %6.6s %6.6s %6.6s %6.6s",
"in", "pack", "comp", "uncomp", "err");
printf(" %6.6s %6.6s", "toss", "ip");
printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s",
"out", "pack", "comp", "uncomp", "ip");
printf(" %6.6s %6.6s", "search", "miss");
printf("%6d %6d %6d %6d %6d",
V(COMP
.sls_compressedin
),
V(COMP
.sls_uncompressedin
),
V(COMP
.sls_compressedin
) -
V(COMP
.sls_uncompressedin
) -
printf(" | %6d %6d %6d %6d %6d",
V(COMP
.sls_packets
) - V(COMP
.sls_compressed
),
V(STATS
.if_opackets
) - V(COMP
.sls_packets
));
oldmask
= sigblock(sigmask(SIGALRM
));
bcopy((char *)sc
, (char *)osc
, sizeof(STRUCT
));
* Called if an interval expires before sidewaysintpr has completed a loop.
* Sets a flag to not wait for the alarm.