diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2024-11-08 08:45:48 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2024-11-08 08:45:48 +0000 |
commit | 5f64f3553ccef70f3e4561f07ea7a0cc75632238 (patch) | |
tree | 1400542b89300de33fd9193a85aa4d1bd37995ee /usr.bin | |
parent | 7a5e859ee7240f673e89e95c811ce0d4ed779539 (diff) |
Make CPU frequencies human readable with -h in `systat sensors`.
ok miod@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/systat/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/systat/sensors.c | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile index 097a755496f..d8e8aaab908 100644 --- a/usr.bin/systat/Makefile +++ b/usr.bin/systat/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.28 2018/05/30 13:43:50 krw Exp $ +# $OpenBSD: Makefile,v 1.29 2024/11/08 08:45:47 matthieu Exp $ PROG= systat @@ -12,6 +12,6 @@ SRCS= dkstats.c engine.c if.c inetname.c iostat.c main.c mbufs.c netstat.c \ pool.c malloc.c cpu.c uvm.c DPADD= ${LIBCURSES} ${LIBM} ${LIBKVM} -LDADD= -lcurses -lm -lkvm +LDADD= -lcurses -lm -lkvm -lutil .include <bsd.prog.mk> diff --git a/usr.bin/systat/sensors.c b/usr.bin/systat/sensors.c index d1bba1017d6..a6341da0494 100644 --- a/usr.bin/systat/sensors.c +++ b/usr.bin/systat/sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.c,v 1.32 2020/07/15 07:13:56 kettenis Exp $ */ +/* $OpenBSD: sensors.c,v 1.33 2024/11/08 08:45:47 matthieu Exp $ */ /* * Copyright (c) 2007 Deanna Phillips <deanna@openbsd.org> @@ -29,6 +29,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <util.h> #include "systat.h" struct sensor sensor; @@ -274,7 +275,12 @@ showsensor(struct sensinfo *s) tbprintf("%3.2f%%", s->sn_value / 1000.0); break; case SENSOR_FREQ: - tbprintf("%11.2f Hz", s->sn_value / 1000000.0); + if (humanreadable) { + char buf[FMT_SCALED_STRSIZE]; + fmt_scaled(s->sn_value / 1000000.0, buf); + tbprintf("%sHz", buf); + } else + tbprintf("%11.2f Hz", s->sn_value / 1000000.0); break; case SENSOR_ANGLE: tbprintf("%3.4f degrees", s->sn_value / 1000000.0); |