From 10cc51ce3039bc14a039a1526b003151750cf7d1 Mon Sep 17 00:00:00 2001 From: ken Date: Wed, 10 Feb 1999 00:46:27 +0000 Subject: Fix vmstat display problems. The header printout wasn't quite right, and the display wrapped around. This decreases the default maximum number of disks shown to 2, so things don't wrap around so easily. Also, it fixes the header display issues. Submitted by: Bruce Evans --- usr.bin/vmstat/vmstat.8 | 4 ++-- usr.bin/vmstat/vmstat.c | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'usr.bin/vmstat') diff --git a/usr.bin/vmstat/vmstat.8 b/usr.bin/vmstat/vmstat.8 index 6c06202..7b58608 100644 --- a/usr.bin/vmstat/vmstat.8 +++ b/usr.bin/vmstat/vmstat.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)vmstat.8 8.1 (Berkeley) 6/6/93 -.\" $Id: vmstat.8,v 1.9 1997/08/25 06:40:05 charnier Exp $ +.\" $Id: vmstat.8,v 1.10 1998/09/15 08:16:43 gibbs Exp $ .\" .Dd June 6, 1996 .Dt VMSTAT 8 @@ -89,7 +89,7 @@ instead of the default Report on the usage of kernel dynamic memory listed first by size of allocation and then by type of usage. .It Fl n -Change the maximum number of disks to display from the default of 3. +Change the maximum number of disks to display from the default of 2. .It Fl p Specify which types of devices to display. There are three different categories of devices: diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 067d6d7..d2b77b5 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -189,7 +189,7 @@ main(argc, argv) memf = nlistf = NULL; interval = reps = todo = 0; - maxshowdevs = 3; + maxshowdevs = 2; while ((c = getopt(argc, argv, "c:fiM:mN:n:p:stw:")) != -1) { switch (c) { case 'c': @@ -539,18 +539,15 @@ dovmstat(interval, reps) void printhdr() { - register int i; + int i, num_shown; + num_shown = (num_selected < maxshowdevs) ? num_selected : maxshowdevs; (void)printf(" procs memory page%*s", 19, ""); - if (num_selected > 1) - (void)printf("disks %*s faults cpu\n", - ((num_selected < maxshowdevs) ? num_selected : - maxshowdevs ) * 4 - 7, ""); - else if (num_selected == 1) - (void)printf("disk faults cpu\n"); - else - (void)printf("%*s faults cpu\n", num_selected * 4, ""); - + if (num_shown > 1) + (void)printf(" disks %*s", num_shown * 4 - 7, ""); + else if (num_shown == 1) + (void)printf("disk"); + (void)printf(" faults cpu\n"); (void)printf(" r b w avm fre flt re pi po fr sr "); for (i = 0; i < num_devices; i++) if ((dev_select[i].selected) -- cgit v1.1