diff options
author | 2006-08-23 11:18:00 +0000 | |
---|---|---|
committer | 2006-08-23 11:18:00 +0000 | |
commit | db03aeab2d39f1ec36a072b9fa6aafb73d0adc23 (patch) | |
tree | d3ba728dc4b52900583c10f6cd6befa1d5550a66 | |
parent | Add a comment about the empty imsg_event_add() function to make it clear (diff) | |
download | wireguard-openbsd-db03aeab2d39f1ec36a072b9fa6aafb73d0adc23.tar.xz wireguard-openbsd-db03aeab2d39f1ec36a072b9fa6aafb73d0adc23.zip |
allow monitoring sensors with their own status reporting such as ipmi or raid controllers; marco@ ok
-rw-r--r-- | etc/sensorsd.conf | 5 | ||||
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.c | 41 | ||||
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.conf.5 | 20 |
3 files changed, 48 insertions, 18 deletions
diff --git a/etc/sensorsd.conf b/etc/sensorsd.conf index 24f48c17531..242b2609e4e 100644 --- a/etc/sensorsd.conf +++ b/etc/sensorsd.conf @@ -1,4 +1,4 @@ -# $OpenBSD: sensorsd.conf,v 1.1 2003/10/08 20:30:04 grange Exp $ +# $OpenBSD: sensorsd.conf,v 1.2 2006/08/23 11:18:00 mickey Exp $ # # Sample sensorsd.conf file. See sensorsd.conf(5) for details. @@ -18,3 +18,6 @@ # CPU fan (RPM) #hw.sensors.11:low=3000 + +# RAID volume sd0 status +#hw.sensors.18: diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index e61433ea46c..af7649a0699 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.22 2006/04/01 20:09:13 henning Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.23 2006/08/23 11:18:00 mickey Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -45,11 +45,6 @@ int parse_config(char *); int64_t get_val(char *, int, enum sensor_type); void reparse_cfg(int); -enum sensorsd_status { - STATUS_OK, - STATUS_FAIL -}; - struct limits_t { TAILQ_ENTRY(limits_t) entries; u_int8_t watch; @@ -58,7 +53,7 @@ struct limits_t { int64_t lower; /* lower limit */ int64_t upper; /* upper limit */ char *command; /* failure command */ - enum sensorsd_status status; /* last status */ + enum sensor_status status; /* last status */ time_t status_changed; int64_t last_val; }; @@ -179,7 +174,7 @@ check_sensors(void) struct limits_t *limit; size_t len; int mib[3]; - enum sensorsd_status newstatus; + enum sensor_status newstatus; mib[0] = CTL_HW; mib[1] = HW_SENSORS; @@ -192,11 +187,18 @@ check_sensors(void) err(1, "sysctl"); limit->last_val = sensor.value; - if (sensor.value > limit->upper || - sensor.value < limit->lower) - newstatus = STATUS_FAIL; - else - newstatus = STATUS_OK; + newstatus = sensor.status; + /* unknown may as well mean producing valid + * status had failed so warn about it */ + if (newstatus == SENSOR_S_UNKNOWN) + newstatus = SENSOR_S_WARN; + else if (newstatus == SENSOR_S_UNSPEC) { + if (sensor.value > limit->upper || + sensor.value < limit->lower) + newstatus = SENSOR_S_CRIT; + else + newstatus = SENSOR_S_OK; + } if (limit->status != newstatus) { limit->status = newstatus; @@ -234,7 +236,7 @@ report(time_t last_report) syslog(LOG_ALERT, "hw.sensors.%d: %s limits, value: %s", limit->num, - (limit->status == STATUS_FAIL) ? "exceed" : "within", + (limit->status != SENSOR_S_OK) ? "exceed" : "within", print_sensor(limit->type, limit->last_val)); if (limit->command) { int i = 0, n = 0, r; @@ -297,6 +299,11 @@ report(time_t last_report) } } +const char *drvstat[] = { + NULL, "empty", "ready", "powerup", "online", "idle", "active", + "rebuild", "powerdown", "fail", "pfail" +}; + static char * print_sensor(enum sensor_type type, int64_t value) { @@ -323,6 +330,12 @@ print_sensor(enum sensor_type type, int64_t value) case SENSOR_INTEGER: snprintf(fbuf, RFBUFSIZ, "%lld", value); break; + case SENSOR_DRIVE: + if (0 < value && value < sizeof(drvstat)/sizeof(drvstat[0])) { + snprintf(fbuf, RFBUFSIZ, "%s", drvstat[value]); + break; + } + /* FALLTHROUGH */ default: snprintf(fbuf, RFBUFSIZ, "%lld ???", value); } diff --git a/usr.sbin/sensorsd/sensorsd.conf.5 b/usr.sbin/sensorsd/sensorsd.conf.5 index 5b640ba2bdf..c803232a6cf 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.5 2006/03/07 11:14:02 jmc Exp $ +.\" $OpenBSD: sensorsd.conf.5,v 1.6 2006/08/23 11:18:00 mickey Exp $ .\" .\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org> .\" Copyright (c) 2005 Matthew Gream <matthew.gream@pobox.com> @@ -53,6 +53,13 @@ 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. .Pp +Sensors that provide status (such as from +.Xr ipmi 4 +or +.Xr bio 4 ) +do not require boundary values specified (that otherwise will be +ignored) and simply trigger status transitions. +.Pp The command is executed on transitions out of, and back into, given limits. Tokens in the command are substituted as follows: .Pp @@ -78,19 +85,26 @@ if hw.sensors.0 goes above 80C, the command .Pa /etc/sensorsd/log_warning will be executed, with the sensor number and current value passed to it. -Alerts will be sent if hw.sensor.1 goes above 170F; +Alerts will be sent if hw.sensors.1 goes above 170F; if hw.sensors.2 goes below 4.8V or above 5.2V; and if the speed of the fan attached to hw.sensors.3 -goes below 1000RPM or above 8000RPM. +goes below 1000RPM or above 8000RPM; if hw.sensors.4 +that is attached to the raid volume sd0 goes into +other than +.Dq OK +state, such as drive failure, rebuild or a complete failure. .Bd -literal -offset indent # Comments are allowed hw.sensors.0:high=80C:command=/etc/sensorsd/log_warning %1 %2 hw.sensors.1:high=170F hw.sensors.2:low=4.8V:high=5.2V hw.sensors.3:low=1000:high=8000 +hw.sensors.4: # raid volume status changes .Ed .Sh SEE ALSO .Xr getcap 3 , +.Xr bio 4 , +.Xr ipmi 4 , .Xr sensorsd 8 , .Xr sysctl 8 .Sh HISTORY |