From nobody Thu Nov 16 03:59:39 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SW5rr0Hhvz516N1; Thu, 16 Nov 2023 03:59:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SW5rq6kN4z4XfM; Thu, 16 Nov 2023 03:59:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700107179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cifpINs0t6oR5xmHPNTLA1eQeXuptYzwTF2K3vfvheE=; b=oaBI1tmquJEqDsQ0x/BdnEvmaYMXvfrMTavUUbR4j0yhomoBaPhsT8XU5j83A2FK0T917P +RVxoQxCzTP7+P6c4pzBHE9Owr0SHpbrgYGA5hZ7fcCzLj8vNhP4y6lq6LoWraKoebiZ4b qRQbJi4fZreD+F1C/TmsW2XTV7qK2JJw1RkaEGb19YPAPRHS88lEcKFomfLcQYu8ZzfPPQ AmPl606gcralvrsizJ4s6soiJ7pJvcgRTH0vZGX+jDUwVX+Hs+ODYCbFEQQyoEnZePBzv+ 6TSntH2+gaSWNM7UTdNnLziNQRFWJvZZHImm8723762pnEXE1EDo/TZA3daLng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700107179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cifpINs0t6oR5xmHPNTLA1eQeXuptYzwTF2K3vfvheE=; b=jz4eQqo1z7UUXkGDaP99H/4Wt7jeymBfMdX6nMgbrTKGUxZSVx099Is7rGNzHF3MRp84/A sYJQMv0Q6SVP0/PYFzLHsxNuenBgx15JjZ61qEqJucVzaPV0V8zwdm6pjAtQgFatt9od8F 6ChsEbGruZxEG9effSf2kGdxihYQmeERjxXHZg0VhbTUdc5QHUIgB9A6agGlpL2UlliCGp ach2i+WgLEcC7rrYUHDRMhPVh8rlfajSUqsvPg97IlDTze/f+ITTkY9W+pCE94xeyFiRYD u0Z59wTooGYqg9PjXBTq9YCFgmwCyTIC8icsYaW25D7UbrAU0KzQNhx4V9nlgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700107179; a=rsa-sha256; cv=none; b=Mc4XZ4C3/od3TTHekItD2m13dE1xfE5+LVbGxnjcDNVF09mkJ7dRxMTzV5DgUSxNpJGtH0 40WVg9lUHphNtJy2jFRvX7L77KccVWaZTBUWisw1F6ZpLMCMzQ9GyuDwPzwwMffooXHoRD 03SmG4+yNlqtfMKTTiSxkpFNDv0z6/y0/qmkfBbwRJ2DkucuIfFNv0k/+hJIslvwSXHB2g mDJduWl1n+HtsTg0g/vNw7oPDuE1ssr7YlRf5/3RLrFT/KwCj8lN4E31MfXHPtSMPr95hB IIW7vYN4s5ch4KA9sfwtq09tBSWOWx01PbbrQhW9/FVc04vjHd3lbb7N7DqLLw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SW5rq5blVzkw0; Thu, 16 Nov 2023 03:59:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AG3xdqR050831; Thu, 16 Nov 2023 03:59:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AG3xdrR050828; Thu, 16 Nov 2023 03:59:39 GMT (envelope-from git) Date: Thu, 16 Nov 2023 03:59:39 GMT Message-Id: <202311160359.3AG3xdrR050828@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 7b21c447fb7b - main - vmstat: Make disks reporting some more reasonable List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7b21c447fb7b761f094c3c2ce2e6d6e2c91c285c Auto-Submitted: auto-generated The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=7b21c447fb7b761f094c3c2ce2e6d6e2c91c285c commit 7b21c447fb7b761f094c3c2ce2e6d6e2c91c285c Author: Alexander Motin AuthorDate: 2023-11-16 03:56:51 +0000 Commit: Alexander Motin CommitDate: 2023-11-16 03:56:51 +0000 vmstat: Make disks reporting some more reasonable MFC after: 1 month --- usr.bin/vmstat/vmstat.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index a03c28f19d00..338d7b15bd84 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -221,12 +221,13 @@ main(int argc, char *argv[]) memf = nlistf = NULL; interval = reps = todo = 0; maxshowdevs = 2; - hflag = isatty(1); argc = xo_parse_args(argc, argv); if (argc < 0) return (argc); + hflag = (xo_get_style(NULL) == XO_STYLE_TEXT) && isatty(1); + while ((c = getopt(argc, argv, "ac:fhHiM:mN:n:oPp:sw:z")) != -1) { switch (c) { case 'a': @@ -818,28 +819,30 @@ dovmstat(unsigned int interval, int reps) rate(sum.v_tfree - osum.v_tfree), 5, 0); prthuman("scanned", rate(sum.v_pdpages - osum.v_pdpages), 5, 0); - xo_emit(" "); } else { xo_emit(" "); xo_emit("{:freed/%5lu} ", rate(sum.v_tfree - osum.v_tfree)); - xo_emit("{:scanned/%4lu} ", + xo_emit("{:scanned/%4lu}", rate(sum.v_pdpages - osum.v_pdpages)); } xo_close_container("paging-rates"); devstats(); xo_open_container("fault-rates"); - xo_emit("{:interrupts/%4lu}", rate(sum.v_intr - osum.v_intr)); if (hflag) { + prthuman("interrupts", + rate(sum.v_intr - osum.v_intr), 5, 0); prthuman("system-calls", rate(sum.v_syscall - osum.v_syscall), 5, 0); prthuman("context-switches", rate(sum.v_swtch - osum.v_swtch), 5, 0); } else { xo_emit(" "); - xo_emit("{:system-calls/%5lu} " + xo_emit("{:interrupts/%4lu} " + "{:system-calls/%5lu} " "{:context-switches/%5lu}", + rate(sum.v_intr - osum.v_intr), rate(sum.v_syscall - osum.v_syscall), rate(sum.v_swtch - osum.v_swtch)); } @@ -878,9 +881,9 @@ printhdr(int maxid, u_long cpumask) else xo_emit("{T:procs} {T:memory} {T:/page%*s}", 19, ""); if (num_shown > 1) - xo_emit(" {T:/disks %*s} ", num_shown * 4 - 7, ""); + xo_emit(" {T:/disks %*s} ", num_shown * 5 - 7, ""); else if (num_shown == 1) - xo_emit(" {T:disks}"); + xo_emit(" {T:disks} "); xo_emit(" {T:faults} "); if (Pflag) { for (i = 0; i <= maxid; i++) { @@ -900,8 +903,7 @@ printhdr(int maxid, u_long cpumask) for (i = 0; i < num_devices; i++) if ((dev_select[i].selected) && (dev_select[i].selected <= maxshowdevs)) - xo_emit("{T:/%c%c%d} ", dev_select[i].device_name[0], - dev_select[i].device_name[1], + xo_emit("{T:/%3.3s%d} ", dev_select[i].device_name, dev_select[i].unit_number); xo_emit(" {T:in} {T:sy} {T:cs}"); if (Pflag) { @@ -1154,11 +1156,15 @@ devstats(void) xo_errx(1, "%s", devstat_errbuf); xo_open_instance("device"); - xo_emit("{ekq:name/%c%c%d}{:transfers/%3.0Lf} ", - dev_select[dn].device_name[0], - dev_select[dn].device_name[1], - dev_select[dn].unit_number, - transfers_per_second); + xo_emit("{ekq:name/%s%d}", + dev_select[dn].device_name, + dev_select[dn].unit_number); + if (hflag) { + prthuman("transfers", (uint64_t)transfers_per_second, + 5, HN_DIVISOR_1000); + } else { + xo_emit("{:transfers/%3.0Lf}", transfers_per_second); + } xo_close_instance("device"); } xo_close_list("device");