Thu Jul 9 13:26:52 2015 UTC ()
support fnmatch(3) patterns for disknames.  eg, "iostat wd*" works now.
update the default disk number selection to note that it uses the current
terminal size to fit disks, not hard coded 4.


(mrg)
diff -r1.23 -r1.24 src/usr.sbin/iostat/iostat.8
diff -r1.61 -r1.62 src/usr.sbin/iostat/iostat.c

cvs diff -r1.23 -r1.24 src/usr.sbin/iostat/iostat.8 (expand / switch to unified diff)

--- src/usr.sbin/iostat/iostat.8 2014/06/11 17:01:04 1.23
+++ src/usr.sbin/iostat/iostat.8 2015/07/09 13:26:52 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: iostat.8,v 1.23 2014/06/11 17:01:04 joerg Exp $ 1.\" $NetBSD: iostat.8,v 1.24 2015/07/09 13:26:52 mrg Exp $
2.\" 2.\"
3.\" Copyright (c) 1985, 1991, 1993 3.\" Copyright (c) 1985, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors 14.\" 3. Neither the name of the University nor the names of its contributors
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE. 28.\" SUCH DAMAGE.
29.\" 29.\"
30.\" from: @(#)iostat.8 8.1 (Berkeley) 6/6/93 30.\" from: @(#)iostat.8 8.1 (Berkeley) 6/6/93
31.\" 31.\"
32.Dd June 11, 2014 32.Dd July 9, 2015
33.Dt IOSTAT 8 33.Dt IOSTAT 8
34.Os 34.Os
35.Sh NAME 35.Sh NAME
36.Nm iostat 36.Nm iostat
37.Nd report 37.Nd report
38.Tn I/O 38.Tn I/O
39statistics 39statistics
40.Sh SYNOPSIS 40.Sh SYNOPSIS
41.Nm 41.Nm
42.Op Fl CdDITx 42.Op Fl CdDITx
43.Op Fl c Ar count 43.Op Fl c Ar count
44.Op Fl w Ar wait 44.Op Fl w Ar wait
45.Op Ar drives 45.Op Ar drives
@@ -132,33 +132,36 @@ Additionally, separate read and write st @@ -132,33 +132,36 @@ Additionally, separate read and write st
132.Nm 132.Nm
133displays its information in the following format: 133displays its information in the following format:
134.Bl -tag -width flag 134.Bl -tag -width flag
135.It tty 135.It tty
136.Bl -tag -width indent -compact 136.Bl -tag -width indent -compact
137.It tin 137.It tin
138characters read from terminals 138characters read from terminals
139.It tout 139.It tout
140characters written to terminals 140characters written to terminals
141.El 141.El
142.It disks 142.It disks
143Disk operations. 143Disk operations.
144The header of the field is the disk name and unit number. 144The header of the field is the disk name and unit number.
145If more than four disk drives are configured in the system, 145If more drives are configured in the system that fit across the
 146current display,
146.Nm 147.Nm
147displays only the first four drives. 148displays only those drives that fit on the display.
148To force 149To force
149.Nm 150.Nm
150to display specific drives, their names may be supplied on the command 151to display specific drives, they may be supplied on the command
151line. 152line, either as names or
 153.Fn fnmatch
 154patterns.
152.Pp 155.Pp
153.Bl -tag -width indent -compact 156.Bl -tag -width indent -compact
154.It KB/t 157.It KB/t
155Kilobytes transferred per disk transfer 158Kilobytes transferred per disk transfer
156.It t/s 159.It t/s
157transfers per second 160transfers per second
158.It MB/s 161.It MB/s
159Megabytes transferred per second 162Megabytes transferred per second
160.Pp 163.Pp
161.El 164.El
162The alternative display format, (selected with 165The alternative display format, (selected with
163.Fl D ) , 166.Fl D ) ,
164presents the following values. 167presents the following values.
@@ -179,25 +182,26 @@ Seconds spent in disk activity @@ -179,25 +182,26 @@ Seconds spent in disk activity
179.It \&sy 182.It \&sy
180% of CPU time in system mode 183% of CPU time in system mode
181.It \&id 184.It \&id
182% of CPU time in idle mode 185% of CPU time in idle mode
183.El 186.El
184.El 187.El
185.Sh SEE ALSO 188.Sh SEE ALSO
186.Xr fstat 1 , 189.Xr fstat 1 ,
187.Xr netstat 1 , 190.Xr netstat 1 ,
188.Xr nfsstat 1 , 191.Xr nfsstat 1 ,
189.Xr \&ps 1 , 192.Xr \&ps 1 ,
190.Xr systat 1 , 193.Xr systat 1 ,
191.Xr vmstat 1 , 194.Xr vmstat 1 ,
 195.Xr fnmatch 3 ,
192.Xr pstat 8 196.Xr pstat 8
193.Pp 197.Pp
194The sections starting with ``Interpreting system activity'' in 198The sections starting with ``Interpreting system activity'' in
195.%T "Installing and Operating 4.3BSD" . 199.%T "Installing and Operating 4.3BSD" .
196.Sh HISTORY 200.Sh HISTORY
197.Nm 201.Nm
198appeared in 202appeared in
199.At v6 . 203.At v6 .
200The 204The
201.Fl x 205.Fl x
202option was added in 206option was added in
203.Nx 1.4 . 207.Nx 1.4 .

cvs diff -r1.61 -r1.62 src/usr.sbin/iostat/iostat.c (expand / switch to unified diff)

--- src/usr.sbin/iostat/iostat.c 2014/06/11 17:01:04 1.61
+++ src/usr.sbin/iostat/iostat.c 2015/07/09 13:26:52 1.62
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: iostat.c,v 1.61 2014/06/11 17:01:04 joerg Exp $ */ 1/* $NetBSD: iostat.c,v 1.62 2015/07/09 13:26:52 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 John M. Vinopal 4 * Copyright (c) 1996 John M. Vinopal
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -61,43 +61,44 @@ @@ -61,43 +61,44 @@
61 * SUCH DAMAGE. 61 * SUCH DAMAGE.
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65#ifndef lint 65#ifndef lint
66__COPYRIGHT("@(#) Copyright (c) 1986, 1991, 1993\ 66__COPYRIGHT("@(#) Copyright (c) 1986, 1991, 1993\
67 The Regents of the University of California. All rights reserved."); 67 The Regents of the University of California. All rights reserved.");
68#endif /* not lint */ 68#endif /* not lint */
69 69
70#ifndef lint 70#ifndef lint
71#if 0 71#if 0
72static char sccsid[] = "@(#)iostat.c 8.3 (Berkeley) 4/28/95"; 72static char sccsid[] = "@(#)iostat.c 8.3 (Berkeley) 4/28/95";
73#else 73#else
74__RCSID("$NetBSD: iostat.c,v 1.61 2014/06/11 17:01:04 joerg Exp $"); 74__RCSID("$NetBSD: iostat.c,v 1.62 2015/07/09 13:26:52 mrg Exp $");
75#endif 75#endif
76#endif /* not lint */ 76#endif /* not lint */
77 77
78#include <sys/types.h> 78#include <sys/types.h>
79#include <sys/ioctl.h> 79#include <sys/ioctl.h>
80#include <sys/sched.h> 80#include <sys/sched.h>
81#include <sys/time.h> 81#include <sys/time.h>
82 82
83#include <err.h> 83#include <err.h>
84#include <ctype.h> 84#include <ctype.h>
85#include <signal.h> 85#include <signal.h>
86#include <stdio.h> 86#include <stdio.h>
87#include <stdlib.h> 87#include <stdlib.h>
88#include <string.h> 88#include <string.h>
89#include <unistd.h> 89#include <unistd.h>
90#include <math.h> 90#include <math.h>
 91#include <fnmatch.h>
91 92
92#include "drvstats.h" 93#include "drvstats.h"
93 94
94int hz; 95int hz;
95static int reps, interval; 96static int reps, interval;
96static int todo = 0; 97static int todo = 0;
97static int defdrives; 98static int defdrives;
98static int winlines = 20; 99static int winlines = 20;
99static int wincols = 80; 100static int wincols = 80;
100 101
101#define MAX(a,b) (((a)>(b))?(a):(b)) 102#define MAX(a,b) (((a)>(b))?(a):(b))
102 103
103#define ISSET(x, a) ((x) & (a)) 104#define ISSET(x, a) ((x) & (a))
@@ -501,27 +502,27 @@ selectdrives(int argc, char *argv[]) @@ -501,27 +502,27 @@ selectdrives(int argc, char *argv[])
501 * 502 *
502 * The backward compatibility #ifdefs permit the syntax: 503 * The backward compatibility #ifdefs permit the syntax:
503 * iostat [ drives ] [ interval [ count ] ] 504 * iostat [ drives ] [ interval [ count ] ]
504 */ 505 */
505 506
506#define BACKWARD_COMPATIBILITY 507#define BACKWARD_COMPATIBILITY
507 for (tried = ndrives = 0; *argv; ++argv) { 508 for (tried = ndrives = 0; *argv; ++argv) {
508#ifdef BACKWARD_COMPATIBILITY 509#ifdef BACKWARD_COMPATIBILITY
509 if (isdigit((unsigned char)**argv)) 510 if (isdigit((unsigned char)**argv))
510 break; 511 break;
511#endif 512#endif
512 tried++; 513 tried++;
513 for (i = 0; i < (int)ndrive; i++) { 514 for (i = 0; i < (int)ndrive; i++) {
514 if (strcmp(cur.name[i], *argv)) 515 if (fnmatch(*argv, cur.name[i], 0))
515 continue; 516 continue;
516 cur.select[i] = 1; 517 cur.select[i] = 1;
517 ++ndrives; 518 ++ndrives;
518 } 519 }
519 520
520 } 521 }
521 522
522 if (ndrives == 0 && tried == 0) { 523 if (ndrives == 0 && tried == 0) {
523 /* 524 /*
524 * Pick up to defdrives (or all if -x is given) drives 525 * Pick up to defdrives (or all if -x is given) drives
525 * if none specified. 526 * if none specified.
526 */ 527 */
527 maxdrives = (ISSET(todo, SHOW_STATS_X) || 528 maxdrives = (ISSET(todo, SHOW_STATS_X) ||