diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2005-11-30 15:46:33 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2005-11-30 15:46:33 +0000 |
commit | a61f492a823444eaf689ddffb3e017e24d04e02c (patch) | |
tree | 64b9269640e747b1518a8cebd72ff7724a0f9364 | |
parent | 9e31f1cf952e40d5ebbe6bc8729bc4f5d66a9a20 (diff) |
add a sensor type for drive status and hook esm up with it.
ok marco@ grange@ deraadt@
-rw-r--r-- | sbin/sysctl/sysctl.c | 45 | ||||
-rw-r--r-- | sys/arch/i386/i386/esm.c | 6 | ||||
-rw-r--r-- | sys/sys/sensors.h | 16 |
3 files changed, 60 insertions, 7 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index d12c6bb7dde..bb6844c5d77 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.132 2005/11/15 22:12:07 kettenis Exp $ */ +/* $OpenBSD: sysctl.c,v 1.133 2005/11/30 15:46:32 dlg Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95"; #else -static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.132 2005/11/15 22:12:07 kettenis Exp $"; +static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.133 2005/11/30 15:46:32 dlg Exp $"; #endif #endif /* not lint */ @@ -2123,6 +2123,8 @@ sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep) void print_sensor(struct sensor *s) { + const char *name; + printf("%s, %s, ", s->device, s->desc); switch (s->status) { case SENSOR_S_OK: @@ -2169,6 +2171,45 @@ print_sensor(struct sensor *s) case SENSOR_LUX: printf("lux, %.2f lx", s->value / 1000000.0); break; + case SENSOR_DRIVE: + switch (s->value) { + case SENSOR_DRIVE_EMPTY: + name = "empty"; + break; + case SENSOR_DRIVE_READY: + name = "ready"; + break; + case SENSOR_DRIVE_POWERUP: + name = "powering up"; + break; + case SENSOR_DRIVE_ONLINE: + name = "online"; + break; + case SENSOR_DRIVE_IDLE: + name = "idle"; + break; + case SENSOR_DRIVE_ACTIVE: + name = "active"; + break; + case SENSOR_DRIVE_REBUILD: + name = "rebuilding"; + break; + case SENSOR_DRIVE_POWERDOWN: + name = "powering down"; + break; + case SENSOR_DRIVE_FAIL: + name = "failed"; + break; + case SENSOR_DRIVE_PFAIL: + name = "pfailed"; + break; + default: + name = "unknown"; + break; + } + printf("drive, %s", name); + break; + default: printf("unknown"); } diff --git a/sys/arch/i386/i386/esm.c b/sys/arch/i386/i386/esm.c index d778ba9ccd9..075e121e40b 100644 --- a/sys/arch/i386/i386/esm.c +++ b/sys/arch/i386/i386/esm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esm.c,v 1.23 2005/11/30 13:40:33 dlg Exp $ */ +/* $OpenBSD: esm.c,v 1.24 2005/11/30 15:46:32 dlg Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -72,8 +72,8 @@ enum sensor_type esm_typemap[] = { SENSOR_INTEGER, SENSOR_INTEGER, SENSOR_INDICATOR, - SENSOR_INTEGER, - SENSOR_INTEGER, + SENSOR_DRIVE, + SENSOR_DRIVE, SENSOR_INTEGER, SENSOR_INDICATOR }; diff --git a/sys/sys/sensors.h b/sys/sys/sensors.h index fcae096c56b..aaa8b678bb1 100644 --- a/sys/sys/sensors.h +++ b/sys/sys/sensors.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.h,v 1.11 2005/11/21 13:47:52 dlg Exp $ */ +/* $OpenBSD: sensors.h,v 1.12 2005/11/30 15:46:32 dlg Exp $ */ /* * Copyright (c) 2003, 2004 Alexander Yurchenko <grange@openbsd.org> @@ -42,9 +42,21 @@ enum sensor_type { SENSOR_INDICATOR, /* boolean indicator */ SENSOR_INTEGER, /* generic integer value */ SENSOR_PERCENT, /* percent */ - SENSOR_LUX /* illuminance (mulx) */ + SENSOR_LUX, /* illuminance (mulx) */ + SENSOR_DRIVE /* disk */ }; +#define SENSOR_DRIVE_EMPTY 1 +#define SENSOR_DRIVE_READY 2 +#define SENSOR_DRIVE_POWERUP 3 +#define SENSOR_DRIVE_ONLINE 4 +#define SENSOR_DRIVE_IDLE 5 +#define SENSOR_DRIVE_ACTIVE 6 +#define SENSOR_DRIVE_REBUILD 7 +#define SENSOR_DRIVE_POWERDOWN 8 +#define SENSOR_DRIVE_FAIL 9 +#define SENSOR_DRIVE_PFAIL 10 + /* Sensor states */ enum sensor_status { SENSOR_S_UNSPEC, /* status is unspecified */ |