diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 11:36:02 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 11:36:02 +0000 |
commit | 806021be093ad00ce2022a532c0f4cc99b0065ac (patch) | |
tree | c4f374fc66dbd93cdd093f4e1213808e855c8b39 /usr.bin/vmstat | |
parent | 200dde568cd8db5fa9ddc42e6b5388df55a16573 (diff) |
libutil
Diffstat (limited to 'usr.bin/vmstat')
-rw-r--r-- | usr.bin/vmstat/Makefile | 8 | ||||
-rw-r--r-- | usr.bin/vmstat/dkstats.c | 8 | ||||
-rw-r--r-- | usr.bin/vmstat/dkstats.h | 5 | ||||
-rw-r--r-- | usr.bin/vmstat/vmstat.8 | 4 | ||||
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 128 |
5 files changed, 53 insertions, 100 deletions
diff --git a/usr.bin/vmstat/Makefile b/usr.bin/vmstat/Makefile index 9718e67d6f0..83a345f760e 100644 --- a/usr.bin/vmstat/Makefile +++ b/usr.bin/vmstat/Makefile @@ -1,13 +1,9 @@ -# $OpenBSD: Makefile,v 1.2 1996/03/03 02:51:20 tholo Exp $ -# $NetBSD: Makefile,v 1.14 1995/05/07 22:15:57 cgd Exp $ +# $OpenBSD: Makefile,v 1.3 1996/05/22 11:35:41 deraadt Exp $ +# $NetBSD: Makefile,v 1.15 1996/05/10 23:19:25 thorpej Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= vmstat -.if (${MACHINE_ARCH} == "m68k") -CFLAGS+=-D${MACHINE} -.endif -CFLAGS+=-I${.CURDIR}/../../sys/arch SRCS= dkstats.c vmstat.c MAN= vmstat.8 DPADD= ${LIBKVM} diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c index f7cc56f9a91..70796e86afb 100644 --- a/usr.bin/vmstat/dkstats.c +++ b/usr.bin/vmstat/dkstats.c @@ -1,7 +1,7 @@ -/* $OpenBSD: dkstats.c,v 1.1 1996/03/03 02:51:20 tholo Exp $ */ +/* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */ /* - * Copyright (c) 1996 John M. Vinopal (banshee@resort.com) + * Copyright (c) 1996 John M. Vinopal * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,7 @@ char **dr_name; void dkswap __P((void)); void dkreadstats __P((void)); int dkinit __P((int)); -static void deref_kptr __P(( void *, void *, size_t)); +static void deref_kptr __P((void *, void *, size_t)); /* * Take the delta between the present values and the last recorded @@ -265,7 +265,7 @@ deref_kptr(kptr, ptr, len) if (kvm_read(kd, (u_long)kptr, (char *)ptr, len) != len) { bzero(buf, sizeof(buf)); snprintf(buf, (sizeof(buf) - 1), - "can't dereference kptr 0x%x", (uint)kptr); + "can't dereference kptr 0x%lx", (u_long)kptr); KVM_ERROR(buf); } } diff --git a/usr.bin/vmstat/dkstats.h b/usr.bin/vmstat/dkstats.h index d22e84bf37e..bfde443e533 100644 --- a/usr.bin/vmstat/dkstats.h +++ b/usr.bin/vmstat/dkstats.h @@ -1,7 +1,7 @@ -/* $OpenBSD: dkstats.h,v 1.1 1996/03/03 02:51:21 tholo Exp $ */ +/* $NetBSD: dkstats.h,v 1.1 1996/05/10 23:19:28 thorpej Exp $ */ /* - * Copyright (c) 1996 John M. Vinopal (banshee@resort.com) + * Copyright (c) 1996 John M. Vinopal * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,4 +47,3 @@ struct _disk { long tk_nout; /* TTY Chars out. */ long cp_time[CPUSTATES]; /* System timer ticks. */ }; - diff --git a/usr.bin/vmstat/vmstat.8 b/usr.bin/vmstat/vmstat.8 index 119916d11b8..4f5d6234d73 100644 --- a/usr.bin/vmstat/vmstat.8 +++ b/usr.bin/vmstat/vmstat.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: vmstat.8,v 1.11 1995/08/10 23:29:47 jtc Exp $ +.\" $NetBSD: vmstat.8,v 1.12 1996/05/10 23:19:30 thorpej Exp $ .\" .\" Copyright (c) 1986, 1993 .\" The Regents of the University of California. All rights reserved. @@ -190,7 +190,7 @@ Others vary every second and running the output for a while will make it apparent which are recomputed every second. .SH FILES .ta \w'/dev/mem 'u -/bsd default kernel namelist +/netbsd default kernel namelist .br /dev/mem default memory file .SH SEE ALSO diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 9d388064806..86dd3d49bb6 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -1,5 +1,4 @@ -/* $OpenBSD: vmstat.c,v 1.9 1996/04/21 23:44:44 deraadt Exp $ */ -/* $NetBSD: vmstat.c,v 1.28 1996/04/04 00:27:50 cgd Exp $ */ +/* $NetBSD: vmstat.c,v 1.29 1996/05/10 23:19:32 thorpej Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 @@ -44,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)vmstat.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$NetBSD: vmstat.c,v 1.28 1996/04/04 00:27:50 cgd Exp $"; +static char rcsid[] = "$NetBSD: vmstat.c,v 1.29 1996/05/10 23:19:32 thorpej Exp $"; #endif #endif /* not lint */ @@ -107,11 +106,11 @@ struct nlist namelist[] = { { "_bucket" }, #define X_ALLEVENTS 14 { "_allevents" }, -#define X_FORKSTAT 15 - { "_forkstat" }, #ifdef notdef -#define X_DEFICIT 16 +#define X_DEFICIT 15 { "_deficit" }, +#define X_FORKSTAT 16 + { "_forkstat" }, #define X_REC 17 { "_rectime" }, #define X_PGIN 18 @@ -120,15 +119,7 @@ struct nlist namelist[] = { { "_xstats" }, #define X_END 20 #else -#define X_END 16 -#endif -#if defined(hp300) || defined(luna68k) -#define X_HPDINIT (X_END) - { "_hp_dinit" }, -#endif -#ifdef mips -#define X_SCSI_DINIT (X_END) - { "_scsi_dinit" }, +#define X_END 15 #endif #ifdef tahoe #define X_VBDINIT (X_END) @@ -142,19 +133,13 @@ struct nlist namelist[] = { #define X_IVT (X_END) { "_ivt" }, #endif -#if defined(i386) -#define X_INTRHAND (X_END) - { "_intrhand" }, -#define X_INTRSTRAY (X_END+1) - { "_intrstray" }, -#endif { "" }, }; /* Objects defined in dkstats.c */ extern struct _disk cur; -extern char **dr_name; -extern int *dk_select, dk_ndrive; +extern char **dr_name; +extern int *dk_select, dk_ndrive; struct vmmeter sum, osum; int ndrives; @@ -170,12 +155,23 @@ kvm_t *kd; #define TIMESTAT 0x10 #define VMSTAT 0x20 -void cpustats(), dkstats(), dointr(), domem(), dosum(); -void dovmstat(), kread(), usage(); -void dotimes(), doforkst(); +void cpustats __P((void)); +void dkstats __P((void)); +void dointr __P((void)); +void domem __P((void)); +void dosum __P((void)); +void dovmstat __P((u_int, int)); +void kread __P((int, void *, size_t)); +void usage __P((void)); +#ifdef notdef +void dotimes __P((void)); +void doforkst __P((void)); +#endif -char *nlistf = NULL; -char *memf = NULL; +char **choosedrives __P((char **)); + +/* Namelist and memory file names. */ +char *nlistf, *memf; main(argc, argv) register int argc; @@ -186,7 +182,6 @@ main(argc, argv) register int c, todo; u_int interval; int reps; - char *memf, *nlistf; char errbuf[_POSIX2_LINE_MAX]; memf = nlistf = NULL; @@ -196,9 +191,11 @@ main(argc, argv) case 'c': reps = atoi(optarg); break; +#ifndef notdef case 'f': todo |= FORKSTAT; break; +#endif case 'i': todo |= INTRSTAT; break; @@ -214,9 +211,11 @@ main(argc, argv) case 's': todo |= SUMSTAT; break; +#ifndef notdef case 't': todo |= TIMESTAT; break; +#endif case 'w': interval = atoi(optarg); break; @@ -262,7 +261,6 @@ main(argc, argv) } if (todo & VMSTAT) { - char **choosedrives(); struct winsize winsize; dkinit(0); /* Initialize disk stats, no disks selected. */ @@ -289,14 +287,18 @@ main(argc, argv) } else if (reps) interval = 1; +#ifdef notdef if (todo & FORKSTAT) doforkst(); +#endif if (todo & MEMSTAT) domem(); if (todo & SUMSTAT) dosum(); +#ifdef notdef if (todo & TIMESTAT) dotimes(); +#endif if (todo & INTRSTAT) dointr(); if (todo & VMSTAT) @@ -486,28 +488,25 @@ needhdr() hdrcnt = 1; } +#ifdef notdef void dotimes() { u_int pgintime, rectime; -#ifdef NEWVM - pgintime = 0; - rectime = 0; -#else kread(X_REC, &rectime, sizeof(rectime)); kread(X_PGIN, &pgintime, sizeof(pgintime)); -#endif kread(X_SUM, &sum, sizeof(sum)); - (void)printf("%u reactivates, %u total time (usec)\n", - sum.v_reactivated, rectime); - (void)printf("average: %u usec / reclaim\n", rectime / sum.v_reactivated); + (void)printf("%u reclaims, %u total time (usec)\n", + sum.v_pgrec, rectime); + (void)printf("average: %u usec / reclaim\n", rectime / sum.v_pgrec); (void)printf("\n"); (void)printf("%u page ins, %u total time (msec)\n", - sum.v_pageins, pgintime / 10); + sum.v_pgin, pgintime / 10); (void)printf("average: %8.1f msec / page in\n", - pgintime / (sum.v_pageins * 10.0)); + pgintime / (sum.v_pgin * 10.0)); } +#endif pct(top, bot) long top, bot; @@ -595,7 +594,7 @@ dosum() nchstats.ncs_miss + nchstats.ncs_long; (void)printf("%9ld total name lookups\n", nchtotal); (void)printf( - "%9s cache hits (%d%% pos + %d%% neg) system %d%% per-directory\n", + "%9s cache hits (%d%% pos + %d%% neg) system %d%% per-process\n", "", PCT(nchstats.ncs_goodhits, nchtotal), PCT(nchstats.ncs_neghits, nchtotal), PCT(nchstats.ncs_pass2, nchtotal)); @@ -631,6 +630,7 @@ dosum() #endif } +#ifdef notdef void doforkst() { @@ -640,10 +640,9 @@ doforkst() (void)printf("%d forks, %d pages, average %.2f\n", fks.cntfork, fks.sizfork, (double)fks.sizfork / fks.cntfork); (void)printf("%d vforks, %d pages, average %.2f\n", - fks.cntvfork, fks.sizvfork, (double)fks.sizvfork / (fks.cntvfork ? fks.cntvfork : 1)); - (void)printf("%d rforks, %d pages, average %.2f\n", - fks.cntrfork, fks.sizrfork, (double)fks.sizrfork / (fks.cntrfork ? fks.cntrfork : 1)); + fks.cntvfork, fks.sizvfork, (double)fks.sizvfork / fks.cntvfork); } +#endif void dkstats() @@ -722,47 +721,6 @@ dointr() inttotal, inttotal / uptime); } } -#elif defined(i386) -/* To get struct intrhand */ -#define _KERNEL -#include <i386/isa/isa_machdep.h> -#undef _KERNEL -void -dointr() -{ - struct intrhand *intrhand[16], *ihp, ih; - u_long inttotal, uptime; - u_long intrstray[16]; - char iname[17]; - int i; - - iname[16] = '\0'; - uptime = getuptime(); - kread(X_INTRHAND, intrhand, sizeof(intrhand)); - kread(X_INTRSTRAY, intrstray, sizeof(intrstray)); - - (void)printf("interrupt total rate\n"); - inttotal = 0; - for (i = 0; i < 16; i++) { - ihp = intrhand[i]; - while (ihp) { - if (kvm_read(kd, (u_long)ihp, &ih, sizeof(ih)) != sizeof(ih)) - errx(1, "vmstat: ih: %s", kvm_geterr(kd)); - if (kvm_read(kd, (u_long)ih.ih_what, iname, 16) != 16) - errx(1, "vmstat: ih_what: %s", kvm_geterr(kd)); - printf("%-16.16s %8lu %8lu\n", iname, ih.ih_count, ih.ih_count / uptime); - inttotal += ih.ih_count; - ihp = ih.ih_next; - } - } - for (i = 0; i < 16; i++) - if (intrstray[i]) { - printf("Stray irq %-2d %8ld %8ld\n", - i, intrstray[i], intrstray[i] / uptime); - inttotal += intrstray[i]; - } - printf("Total %8lu %8lu\n", inttotal, inttotal / uptime); -} #else void dointr() |