Download raw body.
sysctl cpu hz
My CPU is too fast and I have trouble counting the zeros in sysctl hw.sensors.
For a frequency sensor greater than 10 MHz, display in Mhz instead.
Keep the old format when using -n, in case somebody scripted this.
hw.sensors.cpu0.frequency0=650.00 MHz
hw.sensors.cpu2.frequency0=700.00 MHz
hw.sensors.cpu4.frequency0=650.00 MHz
Index: sysctl.c
===================================================================
RCS file: /home/cvs/src/sbin/sysctl/sysctl.c,v
diff -u -p -r1.264 sysctl.c
--- sysctl.c 6 Apr 2025 17:36:22 -0000 1.264
+++ sysctl.c 25 Apr 2025 19:13:43 -0000
@@ -2751,6 +2751,7 @@ void
print_sensor(struct sensor *s)
{
const char *name;
+ double v;
if (s->flags & SENSOR_FUNKNOWN)
printf("unknown");
@@ -2841,7 +2842,12 @@ print_sensor(struct sensor *s)
printf("%.2f%%", s->value / 1000.0);
break;
case SENSOR_FREQ:
- printf("%.2f Hz", s->value / 1000000.0);
+ v = s->value / 1000000.0;
+ if (!nflag && v > 10000000.0) {
+ printf("%.2f MHz", v / 1000000);
+ } else {
+ printf("%.2f Hz", v);
+ }
break;
case SENSOR_ANGLE:
printf("%3.4f degrees", s->value / 1000000.0);
sysctl cpu hz