diff options
author | 2007-08-14 17:10:02 +0000 | |
---|---|---|
committer | 2007-08-14 17:10:02 +0000 | |
commit | 3c73614c6fb3d3e44d11103649d6ee765d625c0c (patch) | |
tree | 0e89204e08d94572a7f9755646ea83c58bdfb5bb | |
parent | Commentary in the examples section was wrong from the start, because it gave (diff) | |
download | wireguard-openbsd-3c73614c6fb3d3e44d11103649d6ee765d625c0c.tar.xz wireguard-openbsd-3c73614c6fb3d3e44d11103649d6ee765d625c0c.zip |
sync printing w/ sysctl(8) and add missing sensor types to conf parser;
document how values are parsed in sensorsd.conf(5).
ok deraadt@; man-page ok/help jmc@
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.c | 27 | ||||
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.conf.5 | 7 |
2 files changed, 27 insertions, 7 deletions
diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index 1d2ee1950d0..41bd50a0200 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.33 2007/06/01 22:41:12 cnst Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.34 2007/08/14 17:10:02 cnst Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -483,11 +483,17 @@ print_sensor(enum sensor_type type, int64_t value) case SENSOR_AMPS: snprintf(fbuf, RFBUFSIZ, "%.2f A", value / 1000000.0); break; + case SENSOR_WATTHOUR: + snprintf(fbuf, RFBUFSIZ, "%.2f Wh", value / 1000000.0); + break; + case SENSOR_AMPHOUR: + snprintf(fbuf, RFBUFSIZ, "%.2f Ah", value / 1000000.0); + break; case SENSOR_INDICATOR: snprintf(fbuf, RFBUFSIZ, "%s", value? "On" : "Off"); break; case SENSOR_INTEGER: - snprintf(fbuf, RFBUFSIZ, "%lld raw", value); + snprintf(fbuf, RFBUFSIZ, "%lld", value); break; case SENSOR_PERCENT: snprintf(fbuf, RFBUFSIZ, "%.2f%%", value / 1000.0); @@ -496,11 +502,14 @@ print_sensor(enum sensor_type type, int64_t value) snprintf(fbuf, RFBUFSIZ, "%.2f lx", value / 1000000.0); break; case SENSOR_DRIVE: - if (0 < value && value < sizeof(drvstat)/sizeof(drvstat[0])) { + if (0 < value && value < sizeof(drvstat)/sizeof(drvstat[0])) snprintf(fbuf, RFBUFSIZ, "%s", drvstat[value]); - break; - } - /* FALLTHROUGH */ + else + snprintf(fbuf, RFBUFSIZ, "%lld ???", value); + break; + case SENSOR_TIMEDELTA: + snprintf(fbuf, RFBUFSIZ, "%.6f secs", value / 1000000000.0); + break; default: snprintf(fbuf, RFBUFSIZ, "%lld ???", value); } @@ -606,9 +615,15 @@ get_val(char *buf, int upper, enum sensor_type type) case SENSOR_DRIVE: rval = val; break; + case SENSOR_AMPS: + case SENSOR_WATTHOUR: + case SENSOR_AMPHOUR: case SENSOR_LUX: rval = val * 1000 * 1000; break; + case SENSOR_TIMEDELTA: + rval = val * 1000 * 1000 * 1000; + break; default: errx(1, "unsupported sensor type"); /* not reached */ diff --git a/usr.sbin/sensorsd/sensorsd.conf.5 b/usr.sbin/sensorsd/sensorsd.conf.5 index dddb225525f..2f98b4b7e57 100644 --- a/usr.sbin/sensorsd/sensorsd.conf.5 +++ b/usr.sbin/sensorsd/sensorsd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sensorsd.conf.5,v 1.17 2007/08/14 16:52:22 cnst Exp $ +.\" $OpenBSD: sensorsd.conf.5,v 1.18 2007/08/14 17:10:02 cnst Exp $ .\" .\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org> .\" Copyright (c) 2005 Matthew Gream <matthew.gream@pobox.com> @@ -68,6 +68,11 @@ Ignore status provided by the driver. The values for temperature sensors can be given in degrees Celsius or Fahrenheit, for voltage sensors in volts, and fan speed sensors take a unit-less number representing RPM. +Values for all other types of sensors can be specified +in the same units as they appear under the +.Xr sysctl 8 +.Va hw.sensors +tree. .Pp Sensors that provide status (such as those from .Xr bio 4 , |