git: d81b0f5e43f0 - stable/13 - usr.sbin/gstat: add microsecond precision for disk latency
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 11 Aug 2024 19:31:31 UTC
The branch stable/13 has been updated by mizhka: URL: https://cgit.FreeBSD.org/src/commit/?id=d81b0f5e43f0778f8c44a2d5ef2ac211362d8dd0 commit d81b0f5e43f0778f8c44a2d5ef2ac211362d8dd0 Author: Michael Zhilin <mizhka@FreeBSD.org> AuthorDate: 2024-08-04 08:31:06 +0000 Commit: Michael Zhilin <mizhka@FreeBSD.org> CommitDate: 2024-08-11 19:31:13 +0000 usr.sbin/gstat: add microsecond precision for disk latency This patch makes gstat to show latency in microseconds if actual latency is less than 1ms. It affects only "ms/r" and "ms/w" columns. Before patch: L(q) ops/s r/s kBps ms/r w/s kBps ms/w %busy Name 0 922 0 0 0.0 922 35809 0.0 2.8| nda0 0 928 2 34 0.1 926 35809 0.0 3.1| nda1 After patch: L(q) ops/s r/s kBps ms/r w/s kBps ms/w %busy Name 0 496 1 31 0.156 495 16020 0.040 1.5| nda0 0 492 0 0 0.000 492 16020 0.042 1.5| nda1 Reviewed by: imp Sponsored by: Postgres Professional Differential Revision: https://reviews.freebsd.org/D41999 (cherry picked from commit d471b4f71dd3b09ada5bf58912dfb1266dd47750) --- usr.sbin/gstat/gstat.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c index 37ca7b18c373..8aee21c6f4f3 100644 --- a/usr.sbin/gstat/gstat.c +++ b/usr.sbin/gstat/gstat.c @@ -406,16 +406,20 @@ main(int argc, char **argv) PRINTMSG(",%.0f", (double)ld[2] * 1024); if (ld[3] > 1e3) PRINTMSG(",%.0f", (double)ld[3]); - else + else if (ld[3] > 1e0) PRINTMSG(",%.1f", (double)ld[3]); + else + PRINTMSG(",%.3f", (double)ld[3]); PRINTMSG(",%.0f", (double)ld[4]); if (flag_s) PRINTMSG(",%.0f", (double)ld[14]); PRINTMSG(",%.0f", (double)ld[5] * 1024); if (ld[6] > 1e3) PRINTMSG(",%.0f", (double)ld[6]); - else + else if (ld[6] > 1e0) PRINTMSG(",%.1f", (double)ld[6]); + else + PRINTMSG(",%.3f", (double)ld[6]); if (flag_d) { PRINTMSG(",%.0f", (double)ld[8]); @@ -426,9 +430,12 @@ main(int argc, char **argv) if (ld[10] > 1e3) PRINTMSG(",%.0f", (double)ld[10]); - else + else if (ld[10] > 1e0) PRINTMSG(",%.1f", (double)ld[10]); + else + PRINTMSG(",%.3f", + (double)ld[10]); } if (flag_o) { @@ -436,8 +443,11 @@ main(int argc, char **argv) if (ld[12] > 1e3) PRINTMSG(",%.0f", (double)ld[12]); + else if (ld[12] > 1e0) + PRINTMSG(",%.1f", + (double)ld[12]); else - PRINTMSG(",%.1f", + PRINTMSG(",%.3f", (double)ld[12]); } PRINTMSG(",%.1lf", (double)ld[7]); @@ -450,16 +460,20 @@ main(int argc, char **argv) PRINTMSG(" %6.0f", (double)ld[2] * 1024); if (ld[3] > 1e3) PRINTMSG(" %6.0f", (double)ld[3]); - else + else if (ld[3] > 1e0) PRINTMSG(" %6.1f", (double)ld[3]); + else + PRINTMSG(" %6.3f", (double)ld[3]); PRINTMSG(" %6.0f", (double)ld[4]); if (flag_s) PRINTMSG(" %6.0f", (double)ld[14]); PRINTMSG(" %6.0f", (double)ld[5] * 1024); if (ld[6] > 1e3) PRINTMSG(" %6.0f", (double)ld[6]); - else + else if (ld[6] > 1e0) PRINTMSG(" %6.1f", (double)ld[6]); + else + PRINTMSG(" %6.3f", (double)ld[6]); if (flag_d) { PRINTMSG(" %6.0f", (double)ld[8]); @@ -471,9 +485,12 @@ main(int argc, char **argv) if (ld[10] > 1e3) PRINTMSG(" %6.0f", (double)ld[10]); - else + else if (ld[10] > 1e0) PRINTMSG(" %6.1f", (double)ld[10]); + else + PRINTMSG(" %6.3f", + (double)ld[10]); } if (flag_o) { @@ -481,8 +498,11 @@ main(int argc, char **argv) if (ld[12] > 1e3) PRINTMSG(" %6.0f", (double)ld[12]); + else if (ld[12] > 1e0) + PRINTMSG(" %6.1f", + (double)ld[12]); else - PRINTMSG(" %6.1f", + PRINTMSG(" %6.3f", (double)ld[12]); }