diff options
-rw-r--r-- | sbin/sysctl/sysctl.c | 11 | ||||
-rw-r--r-- | share/snmp/OPENBSD-SENSORS-MIB.txt | 10 | ||||
-rw-r--r-- | sys/sys/sensors.h | 8 | ||||
-rw-r--r-- | usr.bin/systat/sensors.c | 11 | ||||
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.c | 14 | ||||
-rw-r--r-- | usr.sbin/snmpd/mib.c | 10 |
6 files changed, 56 insertions, 8 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 0090989fc5e..076b0815d23 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.183 2012/04/12 12:33:04 deraadt Exp $ */ +/* $OpenBSD: sysctl.c,v 1.184 2012/09/20 20:11:58 yuo Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -2546,6 +2546,15 @@ print_sensor(struct sensor *s) case SENSOR_ANGLE: printf("%3.4f degrees", s->value / 1000000.0); break; + case SENSOR_DISTANCE: + printf("%.2f mm", s->value / 1000.0); + break; + case SENSOR_PRESSURE: + printf("%.2f Pa", s->value / 1000.0); + break; + case SENSOR_ACCEL: + printf("%2.4f m/s^2", s->value / 1000000.0); + break; default: printf("unknown"); } diff --git a/share/snmp/OPENBSD-SENSORS-MIB.txt b/share/snmp/OPENBSD-SENSORS-MIB.txt index b478a58beab..98210c17c1d 100644 --- a/share/snmp/OPENBSD-SENSORS-MIB.txt +++ b/share/snmp/OPENBSD-SENSORS-MIB.txt @@ -1,4 +1,4 @@ --- $OpenBSD: OPENBSD-SENSORS-MIB.txt,v 1.3 2012/02/09 16:50:18 sthen Exp $ +-- $OpenBSD: OPENBSD-SENSORS-MIB.txt,v 1.4 2012/09/20 20:11:58 yuo Exp $ -- -- Copyright (c) 2006-2007 Joel Knight <knight.joel@gmail.com> -- @@ -127,7 +127,13 @@ sensorType OBJECT-TYPE percent(11), illuminance(12), drive(13), - timedelta(14) + timedelta(14), + humidity(15), + freq(16), + angle(17), + distance(18), + pressure(19), + accel(20) } MAX-ACCESS read-only STATUS current diff --git a/sys/sys/sensors.h b/sys/sys/sensors.h index 9e7828faa5e..71a9299ac97 100644 --- a/sys/sys/sensors.h +++ b/sys/sys/sensors.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.h,v 1.31 2011/09/16 15:44:31 yuo Exp $ */ +/* $OpenBSD: sensors.h,v 1.32 2012/09/20 20:11:58 yuo Exp $ */ /* * Copyright (c) 2003, 2004 Alexander Yurchenko <grange@openbsd.org> @@ -49,6 +49,9 @@ enum sensor_type { SENSOR_HUMIDITY, /* humidity (m%RH) */ SENSOR_FREQ, /* frequency (muHz) */ SENSOR_ANGLE, /* angle (mudegrees) */ + SENSOR_DISTANCE, /* distance (muMeter) */ + SENSOR_PRESSURE, /* pressure (mPa) */ + SENSOR_ACCEL, /* acceleration (mu m/s^2) */ SENSOR_MAX_TYPES }; @@ -72,6 +75,9 @@ static const char * const sensor_type_s[SENSOR_MAX_TYPES + 1] = { "humidity", "frequency", "angle", + "distance", + "pressure", + "acceleration", "undefined" }; #endif /* !_KERNEL */ diff --git a/usr.bin/systat/sensors.c b/usr.bin/systat/sensors.c index ab187b074dc..f57efd7967c 100644 --- a/usr.bin/systat/sensors.c +++ b/usr.bin/systat/sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.c,v 1.26 2011/09/16 20:52:48 yuo Exp $ */ +/* $OpenBSD: sensors.c,v 1.27 2012/09/20 20:11:58 yuo Exp $ */ /* * Copyright (c) 2007 Deanna Phillips <deanna@openbsd.org> @@ -278,6 +278,15 @@ showsensor(struct sensinfo *s) case SENSOR_ANGLE: tbprintf("%3.4f degrees", s->sn_value / 1000000.0); break; + case SENSOR_DISTANCE: + printf("%.2f mm", s->sn_value / 1000.0); + break; + case SENSOR_PRESSURE: + printf("%.2f Pa", s->sn_value / 1000.0); + break; + case SENSOR_ACCEL: + printf("%2.4f m/s^2", s->sn_value / 1000000.0); + break; default: tbprintf("%10lld", s->sn_value); break; diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index 77da0922e58..c84e0399504 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.51 2011/09/16 17:45:06 yuo Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.52 2012/09/20 20:11:58 yuo Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -671,6 +671,15 @@ print_sensor(enum sensor_type type, int64_t value) case SENSOR_ANGLE: snprintf(fbuf, RFBUFSIZ, "%lld", value); break; + case SENSOR_DISTANCE: + snprintf(fbuf, RFBUFSIZ, "%.2f mm", value / 1000.0); + break; + case SENSOR_PRESSURE: + snprintf(fbuf, RFBUFSIZ, "%.2f Pa", value / 1000.0); + break; + case SENSOR_ACCEL: + snprintf(fbuf, RFBUFSIZ, "%2.4f m/s^2", value / 1000000.0); + break; default: snprintf(fbuf, RFBUFSIZ, "%lld ???", value); } @@ -781,12 +790,15 @@ get_val(char *buf, int upper, enum sensor_type type) case SENSOR_AMPHOUR: case SENSOR_LUX: case SENSOR_FREQ: + case SENSOR_ACCEL: rval = val * 1000 * 1000; break; case SENSOR_TIMEDELTA: rval = val * 1000 * 1000 * 1000; break; case SENSOR_HUMIDITY: + case SENSOR_DISTANCE: + case SENSOR_PRESSURE: rval = val * 1000.0; break; default: diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index 734b6056f59..68ddc7c2f20 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.59 2012/09/18 08:29:09 reyk Exp $ */ +/* $OpenBSD: mib.c,v 1.60 2012/09/20 20:11:58 yuo Exp $ */ /* * Copyright (c) 2012 Joel Knight <joel@openbsd.org> @@ -2580,7 +2580,8 @@ static const char * const sensor_drive_s[SENSOR_DRIVE_STATES] = { static const char * const sensor_unit_s[SENSOR_MAX_TYPES + 1] = { "degC", "RPM", "V DC", "V AC", "Ohm", "W", "A", "Wh", "Ah", - "", "", "%", "lx", "", "sec", "%RH", "Hz", "degree", "" + "", "", "%", "lx", "", "sec", "%RH", "Hz", "degree", + "mm", "Pa", "m/s^2", "" }; const char * @@ -2611,6 +2612,7 @@ mib_sensorvalue(struct sensor *s) case SENSOR_AMPHOUR: case SENSOR_LUX: case SENSOR_FREQ: + case SENSOR_ACCEL: ret = asprintf(&v, "%.2f", s->value / 1000000.0); break; case SENSOR_INDICATOR: @@ -2620,6 +2622,10 @@ mib_sensorvalue(struct sensor *s) case SENSOR_HUMIDITY: ret = asprintf(&v, "%.2f%%", s->value / 1000.0); break; + case SENSOR_DISTANCE: + case SENSOR_PRESSURE: + ret = asprintf(&v, "%.2f", s->value / 1000.0); + break; case SENSOR_TIMEDELTA: ret = asprintf(&v, "%.6f", s->value / 1000000000.0); break; |