slstats for FBSD 2.0. Copied in the repository from 1.1.5, and then applied
patches from John Hay. Submitted by: John Hay
This commit is contained in:
parent
a8a4ffd402
commit
1cf7789777
@ -1,10 +1,10 @@
|
||||
# from: @(#)Makefile 5.6 (Berkeley) 4/23/91
|
||||
# $Id: Makefile,v 1.1 1993/11/16 04:16:46 brezak Exp $
|
||||
# $Id: Makefile,v 1.1.1.1 1994/06/17 06:42:36 rich Exp $
|
||||
|
||||
PROG= slstat
|
||||
MAN8= slstat.8
|
||||
DPADD= ${LIBUTIL}
|
||||
LDADD= -lutil
|
||||
LDADD= -lkvm
|
||||
BINGRP= kmem
|
||||
BINMODE=2555
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: slstat.c,v 1.1 1993/11/16 04:16:48 brezak Exp $";
|
||||
static char rcsid[] = "$Id: slstat.c,v 1.1.1.1 1994/06/17 06:42:39 rich Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -32,6 +32,7 @@ static char rcsid[] = "$Id: slstat.c,v 1.1 1993/11/16 04:16:48 brezak Exp $";
|
||||
|
||||
#define INET
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/types.h>
|
||||
@ -51,12 +52,13 @@ static char rcsid[] = "$Id: slstat.c,v 1.1 1993/11/16 04:16:48 brezak Exp $";
|
||||
struct nlist nl[] = {
|
||||
#define N_SOFTC 0
|
||||
{ "_sl_softc" },
|
||||
"",
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
char *system = _PATH_UNIX;
|
||||
const char *system = NULL;
|
||||
char *kmemf = NULL;
|
||||
|
||||
kvm_t *kvm_h;
|
||||
int kflag;
|
||||
int rflag;
|
||||
int vflag;
|
||||
@ -71,6 +73,10 @@ main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
int c;
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
|
||||
system = getbootfile();
|
||||
|
||||
--argc; ++argv;
|
||||
while (argc > 0) {
|
||||
if (strcmp(argv[0], "-v") == 0) {
|
||||
@ -110,13 +116,14 @@ main(argc, argv)
|
||||
kflag++;
|
||||
}
|
||||
}
|
||||
if (kvm_openfiles(system, kmemf, NULL) < 0) {
|
||||
kvm_h = kvm_openfiles(system, kmemf, NULL, O_RDONLY, errbuf);
|
||||
if (kvm_h == 0) {
|
||||
(void)fprintf(stderr,
|
||||
"slstat: kvm_openfiles(%s,%s,0): %s\n",
|
||||
system, kmemf, kvm_geterr());
|
||||
system, kmemf, errbuf);
|
||||
exit(1);
|
||||
}
|
||||
if ((c = kvm_nlist(nl)) != 0) {
|
||||
if ((c = kvm_nlist(kvm_h, nl)) != 0) {
|
||||
if (c > 0) {
|
||||
(void)fprintf(stderr,
|
||||
"slstat: undefined symbols in %s:", system);
|
||||
@ -126,14 +133,15 @@ main(argc, argv)
|
||||
(void)fputc('\n', stderr);
|
||||
} else
|
||||
(void)fprintf(stderr, "slstat: kvm_nlist: %s\n",
|
||||
kvm_geterr());
|
||||
kvm_geterr(kvm_h));
|
||||
exit(1);
|
||||
}
|
||||
intpr();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define V(offset) ((line % 20)? ((sc->offset - osc->offset) / (rflag ? interval : 1)) : sc->offset)
|
||||
#define V(offset) ((line % 20)? ((sc->offset - osc->offset) / \
|
||||
(rflag ? interval : 1)) : sc->offset)
|
||||
#define AMT (sizeof(*sc) - 2 * sizeof(sc->sc_comp.tstate))
|
||||
|
||||
usage()
|
||||
@ -167,7 +175,7 @@ intpr()
|
||||
bzero((char *)osc, AMT);
|
||||
|
||||
while (1) {
|
||||
if (kread(addr, (char *)sc, AMT) < 0)
|
||||
if (kvm_read(kvm_h, addr, (char *)sc, AMT) < 0)
|
||||
perror("kmem read");
|
||||
(void)signal(SIGALRM, catchalarm);
|
||||
signalled = 0;
|
||||
@ -187,7 +195,7 @@ intpr()
|
||||
putchar('\n');
|
||||
}
|
||||
printf("%8u %6d %6u %6u %6u",
|
||||
V(sc_bytesrcvd),
|
||||
V(sc_if.if_ibytes),
|
||||
V(sc_if.if_ipackets),
|
||||
V(sc_comp.sls_compressedin),
|
||||
V(sc_comp.sls_uncompressedin),
|
||||
@ -201,7 +209,7 @@ intpr()
|
||||
V(sc_comp.sls_errorin),
|
||||
V(sc_if.if_ierrors));
|
||||
printf(" | %8u %6d %6u %6u %6u",
|
||||
V(sc_bytessent) / (rflag ? interval : 1),
|
||||
V(sc_if.if_obytes) / (rflag ? interval : 1),
|
||||
V(sc_if.if_opackets),
|
||||
V(sc_comp.sls_compressed),
|
||||
V(sc_comp.sls_packets) - V(sc_comp.sls_compressed),
|
||||
@ -236,6 +244,8 @@ catchalarm()
|
||||
signalled = 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
#include <kvm.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@ -285,3 +295,5 @@ kread(addr, buf, size)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user