Module Name: src Committed By: mrg Date: Wed Feb 9 07:34:18 UTC 2022
Modified Files: src/usr.bin/vmstat: vmstat.c Log Message: allow the number of disks displayed in the default output to be controlled. To generate a diff of this commit: cvs rdiff -u -r1.249 -r1.250 src/usr.bin/vmstat/vmstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/vmstat/vmstat.c diff -u src/usr.bin/vmstat/vmstat.c:1.249 src/usr.bin/vmstat/vmstat.c:1.250 --- src/usr.bin/vmstat/vmstat.c:1.249 Tue Feb 1 09:18:07 2022 +++ src/usr.bin/vmstat/vmstat.c Wed Feb 9 07:34:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: vmstat.c,v 1.249 2022/02/01 09:18:07 mrg Exp $ */ +/* $NetBSD: vmstat.c,v 1.250 2022/02/09 07:34:18 mrg Exp $ */ /*- * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020 @@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95"; #else -__RCSID("$NetBSD: vmstat.c,v 1.249 2022/02/01 09:18:07 mrg Exp $"); +__RCSID("$NetBSD: vmstat.c,v 1.250 2022/02/09 07:34:18 mrg Exp $"); #endif #endif /* not lint */ @@ -329,6 +329,8 @@ static const int vmmeter_mib[] = { CTL_V static const int uvmexp2_mib[] = { CTL_VM, VM_UVMEXP2 }; static const int boottime_mib[] = { CTL_KERN, KERN_BOOTTIME }; +int numdisks = 2; + int main(int argc, char *argv[]) { @@ -343,7 +345,7 @@ main(int argc, char *argv[]) reps = todo = verbose = wide = 0; interval.tv_sec = 0; interval.tv_nsec = 0; - while ((c = getopt(argc, argv, "Cc:efh:HilLM:mN:stu:UvWw:")) != -1) { + while ((c = getopt(argc, argv, "Cc:efh:HilLM:mN:n:stu:UvWw:")) != -1) { switch (c) { case 'c': reps = atoi(optarg); @@ -381,6 +383,9 @@ main(int argc, char *argv[]) case 'N': nlistf = optarg; break; + case 'n': + numdisks = atoi(optarg); + break; case 's': todo |= SUMSTAT; break; @@ -595,10 +600,10 @@ choosedrives(char **argv) /* * Pick the most active drives. Must read the stats once before * sorting so that there is current IO data, before selecting - * just the first two drives. + * just the first 'numdisks' (default 2) drives. */ drvreadstats(); - for (i = 0; i < ndrive && ndrives < 2; i++) { + for (i = 0; i < ndrive && ndrives < numdisks; i++) { uint64_t high_bytes = 0, bytes; k = ndrive; @@ -2436,7 +2441,9 @@ usage(void) { (void)fprintf(stderr, - "usage: %s [-CefHiLlmstUvW] [-c count] [-h hashname] [-M core] [-N system]\n" - "\t\t[-u histname] [-w wait] [disks]\n", getprogname()); + "usage: %s [-CefHiLlmstUvW] [-c count] [-h hashname]\n" + "\t\t[-M core] [-N system] [-d diskcount] [-u histname]\n" + "[-w wait] [disks]\n", + getprogname()); exit(1); }