summaryrefslogtreecommitdiffstats
path: root/usr.sbin/iostat
diff options
context:
space:
mode:
authorsbruno <sbruno@FreeBSD.org>2010-05-21 17:10:52 +0000
committersbruno <sbruno@FreeBSD.org>2010-05-21 17:10:52 +0000
commitd60c486b8837161509dbd904a6a44af49249ef8a (patch)
tree56522a4131784ea7422f6a54a563401513353b18 /usr.sbin/iostat
parentec26a9488b14e8d1ed236fc5c08772c155ea9ce8 (diff)
downloadFreeBSD-src-d60c486b8837161509dbd904a6a44af49249ef8a.zip
FreeBSD-src-d60c486b8837161509dbd904a6a44af49249ef8a.tar.gz
Allow sub-second interval timings for iostat and vmstat.
e.g. vmstat -w.5 iostat -w.5 Reviewed by: jhb Approved by: scottl (mentor) Obtained from: Yahoo Inc. MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/iostat')
-rw-r--r--usr.sbin/iostat/iostat.83
-rw-r--r--usr.sbin/iostat/iostat.c15
2 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/iostat/iostat.8 b/usr.sbin/iostat/iostat.8
index e7ceb62..5952209 100644
--- a/usr.sbin/iostat/iostat.8
+++ b/usr.sbin/iostat/iostat.8
@@ -239,6 +239,9 @@ seconds between each display.
If no repeat
.Ar count
is specified, the default is infinity.
+The
+.Nm
+command will accept and honor a non-integer number of seconds.
.It Fl x
Show extended disk statistics.
Each disk is displayed on a line of its own with all available statistics.
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 9831f84..dfa5ebc 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -184,6 +184,7 @@ main(int argc, char **argv)
long select_generation;
char **specified_devices;
devstat_select_mode select_mode;
+ float f;
int havelast = 0;
matches = NULL;
@@ -239,9 +240,10 @@ main(int argc, char **argv)
break;
case 'w':
wflag++;
- waittime = atoi(optarg);
+ f = atof(optarg);
+ waittime = f * 1000;
if (waittime < 1)
- errx(1, "wait time is < 1");
+ errx(1, "wait time is < 1ms");
break;
case 'x':
xflag++;
@@ -378,12 +380,13 @@ main(int argc, char **argv)
* Look for the traditional wait time and count arguments.
*/
if (*argv) {
- waittime = atoi(*argv);
+ f = atof(*argv);
+ waittime = f * 1000;
/* Let the user know he goofed, but keep going anyway */
if (wflag != 0)
warnx("discarding previous wait interval, using"
- " %d instead", waittime);
+ " %g instead", waittime / 1000.0);
wflag++;
if (*++argv) {
@@ -401,7 +404,7 @@ main(int argc, char **argv)
* to an interval of 1 second.
*/
if ((wflag == 0) && (cflag > 0))
- waittime = 1;
+ waittime = 1 * 1000;
/*
* If the user specified a wait time, but not a count, we want to
@@ -602,7 +605,7 @@ main(int argc, char **argv)
if (count >= 0 && --count <= 0)
break;
- sleep(waittime);
+ usleep(waittime * 1000);
havelast = 1;
}
OpenPOWER on IntegriCloud