summaryrefslogtreecommitdiffstats
path: root/usr.bin/vmstat
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2003-10-28 05:02:03 +0000
committerjmg <jmg@FreeBSD.org>2003-10-28 05:02:03 +0000
commit2a6886b3659ead29aa41196cf836bf8a9c43c03c (patch)
treec9934641f71b88fc2c5bf8ee97e98aeb10ec655f /usr.bin/vmstat
parent7742522f996f5bdf6e9c631b5ad498c10190ff51 (diff)
downloadFreeBSD-src-2a6886b3659ead29aa41196cf836bf8a9c43c03c.zip
FreeBSD-src-2a6886b3659ead29aa41196cf836bf8a9c43c03c.tar.gz
take mux's fix to the next level, scan the names and make the field larger
as necessary... on sparcs where: atapci0 vec1996 is a bit too long
Diffstat (limited to 'usr.bin/vmstat')
-rw-r--r--usr.bin/vmstat/vmstat.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 0cfbbc0..730dee9 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -729,7 +729,9 @@ dointr()
u_long *intrcnt, uptime;
u_int64_t inttotal;
int nintr, inamlen;
- char *intrname;
+ int i, istrnamlen;
+ size_t clen;
+ char *intrname, *tintrname;
uptime = getuptime();
nintr = namelist[X_EINTRCNT].n_value - namelist[X_INTRCNT].n_value;
@@ -741,17 +743,26 @@ dointr()
errx(1, "malloc");
kread(X_INTRCNT, intrcnt, (size_t)nintr);
kread(X_INTRNAMES, intrname, (size_t)inamlen);
- (void)printf("%-14s %20s %10s\n", "interrupt", "total", "rate");
+ tintrname = intrname;
+ istrnamlen = 14;
+ for (i = 0; i < nintr; i++) {
+ clen = strlen(tintrname);
+ if (clen > istrnamlen)
+ istrnamlen = clen;
+ tintrname += clen + 1;
+ }
+ (void)printf("%-*s %20s %10s\n", istrnamlen, "interrupt", "total",
+ "rate");
inttotal = 0;
nintr /= sizeof(long);
while (--nintr >= 0) {
if (*intrcnt)
- (void)printf("%-14s %20lu %10lu\n", intrname,
+ (void)printf("%-*s %20lu %10lu\n", istrnamlen, intrname,
*intrcnt, *intrcnt / uptime);
intrname += strlen(intrname) + 1;
inttotal += *intrcnt++;
}
- (void)printf("%-14s %20llu %10llu\n", "Total", inttotal,
+ (void)printf("%-*s %20llu %10llu\n", istrnamlen, "Total", inttotal,
inttotal / (u_int64_t) uptime);
}
OpenPOWER on IntegriCloud