Maintain 5-character width of MB/s column by dynamically adjusting the
decimal precision. This should work until disk transfer rates exceed 99999 MB/s.
This commit is contained in:
parent
6b82d481ea
commit
5637a88e80
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.23 2006/04/21 13:46:37 yamt Exp $
|
||||
# $NetBSD: Makefile,v 1.24 2011/01/07 03:12:27 jakllsch Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
.include <bsd.own.mk>
|
||||
@ -13,7 +13,7 @@ CPPFLAGS+=-I${NETBSDSRCDIR}/usr.bin/vmstat
|
||||
# drvstats.c pulled in from ../../usr.bin/vmstat
|
||||
SRCS= drvstats.c iostat.c
|
||||
|
||||
DPADD= ${LIBKVM}
|
||||
LDADD= -lkvm
|
||||
DPADD= ${LIBKVM} ${LIBM}
|
||||
LDADD= -lkvm -lm
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: iostat.c,v 1.53 2009/04/15 10:05:41 lukem Exp $ */
|
||||
/* $NetBSD: iostat.c,v 1.54 2011/01/07 03:12:27 jakllsch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 John M. Vinopal
|
||||
@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 1991, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)iostat.c 8.3 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: iostat.c,v 1.53 2009/04/15 10:05:41 lukem Exp $");
|
||||
__RCSID("$NetBSD: iostat.c,v 1.54 2011/01/07 03:12:27 jakllsch Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -87,6 +87,7 @@ __RCSID("$NetBSD: iostat.c,v 1.53 2009/04/15 10:05:41 lukem Exp $");
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "drvstats.h"
|
||||
|
||||
@ -99,6 +100,8 @@ static int defdrives;
|
||||
static int winlines = 20;
|
||||
static int wincols = 80;
|
||||
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
#define ISSET(x, a) ((x) & (a))
|
||||
#define SHOW_CPU (1<<0)
|
||||
#define SHOW_TTY (1<<1)
|
||||
@ -339,7 +342,9 @@ drive_stats(double etime)
|
||||
(double)(1024 * 1024);
|
||||
else
|
||||
mbps = 0;
|
||||
(void)printf(" %5.2f ", mbps / etime);
|
||||
mbps /= etime;
|
||||
(void)printf(" %5.*f ",
|
||||
MAX(0,3-(int)floor(log10(fabs(fmax(1.0,mbps))))), mbps);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user