aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Zhilin <mizhka@FreeBSD.org>2024-08-04 08:31:06 +0000
committerMichael Zhilin <mizhka@FreeBSD.org>2024-08-11 19:31:13 +0000
commitd81b0f5e43f0778f8c44a2d5ef2ac211362d8dd0 (patch)
treedf3b2192123b9eb7c896e10f1e1bfa4f267f047d
parentc576a4c57d961e9c463e6c5946d33ef96a5e8093 (diff)
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)
-rw-r--r--usr.sbin/gstat/gstat.c36
1 files 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]);
}