clean up import. that was weird.
This commit is contained in:
parent
5952d4f8bf
commit
4e966414e2
|
@ -1,8 +1,7 @@
|
|||
# from: @(#)Makefile 5.6 (Berkeley) 4/23/91
|
||||
# $Id: Makefile,v 1.4 1994/01/28 00:51:04 cgd Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
PROG= iostat
|
||||
CFLAGS+=-I${DESTDIR}/sys -I${.CURDIR}/../../usr.bin/vmstat
|
||||
CFLAGS+=-I/sys -I${.CURDIR}/../../usr.bin/vmstat
|
||||
MAN8= iostat.0
|
||||
DPADD= ${LIBKVM}
|
||||
LDADD= -lkvm
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" Copyright (c) 1985, 1991 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 1985, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
|
@ -29,15 +29,17 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)iostat.8 6.8 (Berkeley) 4/24/91
|
||||
.\" $Id: iostat.8,v 1.5 1993/10/06 19:34:59 jtc Exp $
|
||||
.\" from: @(#)iostat.8 8.1 (Berkeley) 6/6/93
|
||||
.\" $Id: iostat.8,v 1.6 1994/05/14 21:52:21 cgd Exp $
|
||||
.\"
|
||||
.Dd April 24, 1991
|
||||
.Dd June 6, 1993
|
||||
.Dt IOSTAT 8
|
||||
.Os
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
.Nm iostat
|
||||
.Nd report I/O statistics
|
||||
.Nm iostat
|
||||
.Nd report
|
||||
.Tn I/O
|
||||
statistics
|
||||
.Sh SYNOPSIS
|
||||
.Nm iostat
|
||||
.Op Fl c Ar count
|
||||
|
@ -47,11 +49,13 @@
|
|||
.Op Ar drives
|
||||
.Sh DESCRIPTION
|
||||
.Nm Iostat
|
||||
reports certain kernel statistics kept about terminal, disk and cpu
|
||||
activity.
|
||||
displays kernel
|
||||
.Tn I/O
|
||||
statistics on terminal, disk and cpu
|
||||
operations.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width flag
|
||||
.It Fl c
|
||||
Repeat the display
|
||||
.Ar count
|
||||
|
@ -63,8 +67,8 @@ If no
|
|||
interval is specified, the default is 1 second.
|
||||
.It Fl M
|
||||
Extract values associated with the name list from the specified core
|
||||
instead of the default
|
||||
.Dq Pa /dev/kmem .
|
||||
instead of the default
|
||||
.Dq Pa /dev/kmem .
|
||||
.It Fl N
|
||||
Extract the name list from the specified system instead of the default
|
||||
.Dq Pa /netbsd .
|
||||
|
@ -79,7 +83,7 @@ is specified, the default is infinity.
|
|||
.Pp
|
||||
.Nm Iostat
|
||||
displays its information in the following format:
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width flag
|
||||
.It tty
|
||||
.Bl -tag -width indent -compact
|
||||
.It tin
|
||||
|
@ -104,34 +108,36 @@ sectors transferred per second
|
|||
.It tps
|
||||
transfers per second
|
||||
.It msps
|
||||
milliseconds per average seek (including implied seeks and rotational latency)
|
||||
milliseconds per average seek (including implied
|
||||
seeks and rotational latency)
|
||||
.El
|
||||
.It cpu
|
||||
.Bl -tag -width indent -compact
|
||||
.It us
|
||||
.It \&us
|
||||
% of cpu time in user mode
|
||||
.It ni
|
||||
.It \&ni
|
||||
% of cpu time in user mode running niced processes
|
||||
.It sy
|
||||
.It \&sy
|
||||
% of cpu time in system mode
|
||||
.It id
|
||||
.It \&id
|
||||
% of cpu time in idle mode
|
||||
.El
|
||||
.El
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width 24n -compact
|
||||
.It Pa /dev/kmem
|
||||
default memory file
|
||||
.Bl -tag -width /dev/kmem -compact
|
||||
.It Pa /netbsd
|
||||
default kernel namelist
|
||||
Default kernel namelist.
|
||||
.It Pa /dev/kmem
|
||||
Default memory file.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr fstat 1 ,
|
||||
.Xr netstat 1 ,
|
||||
.Xr nfsstat 1 ,
|
||||
.Xr ps 1 ,
|
||||
.Xr \&ps 1 ,
|
||||
.Xr systat 1 ,
|
||||
.Xr vmstat 1 ,
|
||||
.Xr pstat 8
|
||||
.sp
|
||||
.Pp
|
||||
The sections starting with ``Interpreting system activity'' in
|
||||
.Em "Installing and Operating 4.3BSD" .
|
||||
.%T "Installing and Operating 4.3BSD" .
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*-
|
||||
* Copyright (c) 1986, 1991 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1986, 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -32,31 +32,34 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1986, 1991 The Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1986, 1991, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)iostat.c 5.9 (Berkeley) 6/27/91";*/
|
||||
static char rcsid[] = "$Id: iostat.c,v 1.5 1994/03/16 01:35:27 cgd Exp $";
|
||||
/* from: static char sccsid[] = "@(#)iostat.c 8.2 (Berkeley) 1/26/94"; */
|
||||
static char *rcsid = "$Id: iostat.c,v 1.6 1994/05/14 21:52:22 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/dkstat.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <nlist.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.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 <paths.h>
|
||||
#include <kvm.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct nlist nl[] = {
|
||||
struct nlist namelist[] = {
|
||||
#define X_DK_TIME 0
|
||||
{ "_dk_time" },
|
||||
#define X_DK_XFER 1
|
||||
|
@ -75,15 +78,19 @@ struct nlist nl[] = {
|
|||
{ "_dk_wpms" },
|
||||
#define X_HZ 8
|
||||
{ "_hz" },
|
||||
#define X_PHZ 9
|
||||
{ "_phz" },
|
||||
#define X_STATHZ 9
|
||||
{ "_stathz" },
|
||||
#define X_DK_NDRIVE 10
|
||||
{ "_dk_ndrive" },
|
||||
#define X_END 10
|
||||
#ifdef hp300
|
||||
#if defined(hp300) || defined(luna68k)
|
||||
#define X_HPDINIT (X_END+1)
|
||||
{ "_hp_dinit" },
|
||||
#endif
|
||||
#ifdef mips
|
||||
#define X_SCSI_DINIT (X_END+1)
|
||||
{ "_scsi_dinit" },
|
||||
#endif
|
||||
#ifdef tahoe
|
||||
#define X_VBDINIT (X_END+1)
|
||||
{ "_vbdinit" },
|
||||
|
@ -93,10 +100,6 @@ struct nlist nl[] = {
|
|||
#define X_MBDINIT (X_END+1)
|
||||
{ "_ubdinit" },
|
||||
#define X_UBDINIT (X_END+2)
|
||||
#endif
|
||||
#ifdef i386
|
||||
#define X_ISADEVTAB (X_END+1)
|
||||
{ "_isa_devtab" },
|
||||
#endif
|
||||
{ NULL },
|
||||
};
|
||||
|
@ -111,43 +114,50 @@ struct _disk {
|
|||
long tk_nout;
|
||||
} cur, last;
|
||||
|
||||
double etime;
|
||||
long *dk_wpms;
|
||||
int dk_ndrive, *dr_select, hz, kmemfd, ndrives;
|
||||
char **dr_name;
|
||||
kvm_t *kd;
|
||||
double etime;
|
||||
long *dk_wpms;
|
||||
int dk_ndrive, *dr_select, hz, kmemfd, ndrives;
|
||||
char **dr_name;
|
||||
|
||||
#define nlread(x, v) \
|
||||
kvm_read((void *)nl[x].n_value, (void *)&(v), sizeof(v))
|
||||
kvm_read(kd, namelist[x].n_value, &(v), sizeof(v))
|
||||
|
||||
#include "names.c" /* XXX */
|
||||
|
||||
static void cpustats __P((void)), dkstats __P((void)), phdr __P((int));
|
||||
static void usage __P((void)), err __P((const char *, ...));
|
||||
void cpustats __P((void));
|
||||
void dkstats __P((void));
|
||||
void phdr __P((int));
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
char *argv[];
|
||||
{
|
||||
register int i;
|
||||
long tmp;
|
||||
int ch, hdrcnt, reps, interval, phz, ndrives;
|
||||
char **cp, *memfile, *namelist, buf[30];
|
||||
int ch, hdrcnt, reps, interval, stathz, ndrives;
|
||||
char **cp, *memf, *nlistf, buf[30];
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
|
||||
interval = reps = 0;
|
||||
namelist = memfile = NULL;
|
||||
nlistf = memf = NULL;
|
||||
while ((ch = getopt(argc, argv, "c:M:N:w:")) != EOF)
|
||||
switch(ch) {
|
||||
case 'c':
|
||||
reps = atoi(optarg);
|
||||
if ((reps = atoi(optarg)) <= 0)
|
||||
errx(1, "repetition count <= 0.");
|
||||
break;
|
||||
case 'M':
|
||||
memfile = optarg;
|
||||
memf = optarg;
|
||||
break;
|
||||
case 'N':
|
||||
namelist = optarg;
|
||||
nlistf = optarg;
|
||||
break;
|
||||
case 'w':
|
||||
interval = atoi(optarg);
|
||||
if ((interval = atoi(optarg)) <= 0)
|
||||
errx(1, "interval <= 0.");
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
|
@ -156,15 +166,23 @@ main(argc, argv)
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (kvm_openfiles(namelist, memfile, NULL) == -1)
|
||||
err("kvm_openfiles: %s", kvm_geterr());
|
||||
if (kvm_nlist(nl) == -1)
|
||||
err("kvm_nlist: %s", kvm_geterr());
|
||||
if (nl[X_DK_NDRIVE].n_type == 0)
|
||||
err("dk_ndrive not found in namelist");
|
||||
/*
|
||||
* Discard setgid privileges if not the running kernel so that bad
|
||||
* guys can't print interesting stuff from kernel memory.
|
||||
*/
|
||||
if (nlistf != NULL || memf != NULL)
|
||||
setgid(getgid());
|
||||
|
||||
kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
|
||||
if (kd == 0)
|
||||
errx(1, "kvm_openfiles: %s", errbuf);
|
||||
if (kvm_nlist(kd, namelist) == -1)
|
||||
errx(1, "kvm_nlist: %s", kvm_geterr(kd));
|
||||
if (namelist[X_DK_NDRIVE].n_type == 0)
|
||||
errx(1, "dk_ndrive not found in namelist");
|
||||
(void)nlread(X_DK_NDRIVE, dk_ndrive);
|
||||
if (dk_ndrive <= 0)
|
||||
err("invalid dk_ndrive %d\n", dk_ndrive);
|
||||
errx(1, "invalid dk_ndrive %d\n", dk_ndrive);
|
||||
|
||||
cur.dk_time = calloc(dk_ndrive, sizeof(long));
|
||||
cur.dk_wds = calloc(dk_ndrive, sizeof(long));
|
||||
|
@ -182,12 +200,13 @@ main(argc, argv)
|
|||
(void)sprintf(buf, "dk%d", i);
|
||||
dr_name[i] = strdup(buf);
|
||||
}
|
||||
read_names();
|
||||
if (!read_names())
|
||||
exit(1);
|
||||
(void)nlread(X_HZ, hz);
|
||||
(void)nlread(X_PHZ, phz);
|
||||
if (phz)
|
||||
hz = phz;
|
||||
(void)kvm_read((void *)nl[X_DK_WPMS].n_value, dk_wpms,
|
||||
(void)nlread(X_STATHZ, stathz);
|
||||
if (stathz)
|
||||
hz = stathz;
|
||||
(void)kvm_read(kd, namelist[X_DK_WPMS].n_value, dk_wpms,
|
||||
dk_ndrive * sizeof(dk_wpms));
|
||||
|
||||
/*
|
||||
|
@ -251,19 +270,19 @@ main(argc, argv)
|
|||
phdr(0);
|
||||
hdrcnt = 20;
|
||||
}
|
||||
(void)kvm_read((void *)nl[X_DK_TIME].n_value,
|
||||
(void)kvm_read(kd, namelist[X_DK_TIME].n_value,
|
||||
cur.dk_time, dk_ndrive * sizeof(long));
|
||||
(void)kvm_read((void *)nl[X_DK_XFER].n_value,
|
||||
(void)kvm_read(kd, namelist[X_DK_XFER].n_value,
|
||||
cur.dk_xfer, dk_ndrive * sizeof(long));
|
||||
(void)kvm_read((void *)nl[X_DK_WDS].n_value,
|
||||
(void)kvm_read(kd, namelist[X_DK_WDS].n_value,
|
||||
cur.dk_wds, dk_ndrive * sizeof(long));
|
||||
(void)kvm_read((void *)nl[X_DK_SEEK].n_value,
|
||||
(void)kvm_read(kd, namelist[X_DK_SEEK].n_value,
|
||||
cur.dk_seek, dk_ndrive * sizeof(long));
|
||||
(void)kvm_read((void *)nl[X_TK_NIN].n_value,
|
||||
(void)kvm_read(kd, namelist[X_TK_NIN].n_value,
|
||||
&cur.tk_nin, sizeof(cur.tk_nin));
|
||||
(void)kvm_read((void *)nl[X_TK_NOUT].n_value,
|
||||
(void)kvm_read(kd, namelist[X_TK_NOUT].n_value,
|
||||
&cur.tk_nout, sizeof(cur.tk_nout));
|
||||
(void)kvm_read((void *)nl[X_CP_TIME].n_value,
|
||||
(void)kvm_read(kd, namelist[X_CP_TIME].n_value,
|
||||
cur.cp_time, sizeof(cur.cp_time));
|
||||
for (i = 0; i < dk_ndrive; i++) {
|
||||
if (!dr_select[i])
|
||||
|
@ -304,15 +323,15 @@ main(argc, argv)
|
|||
|
||||
/* ARGUSED */
|
||||
void
|
||||
phdr(notused)
|
||||
int notused;
|
||||
phdr(signo)
|
||||
int signo;
|
||||
{
|
||||
register int i;
|
||||
|
||||
(void)printf(" tty");
|
||||
for (i = 0; i < dk_ndrive; i++)
|
||||
if (dr_select[i])
|
||||
(void)printf(" %5.5s ", dr_name[i]);
|
||||
(void)printf(" %3.3s ", dr_name[i]);
|
||||
(void)printf(" cpu\n tin tout");
|
||||
for (i = 0; i < dk_ndrive; i++)
|
||||
if (dr_select[i])
|
||||
|
@ -371,32 +390,3 @@ usage()
|
|||
"usage: iostat [-c count] [-M core] [-N system] [-w wait] [drives]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
err(const char *fmt, ...)
|
||||
#else
|
||||
err(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "iostat: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue