diff options
author | Chris Kuethe <ckuethe@cvs.openbsd.org> | 2008-03-13 21:24:46 +0000 |
---|---|---|
committer | Chris Kuethe <ckuethe@cvs.openbsd.org> | 2008-03-13 21:24:46 +0000 |
commit | ffbd9674da40ed4679b50c5ed25ab9a2e5c95e38 (patch) | |
tree | ca3b44756457876bbf6b7533d3ee8a3325a4db92 | |
parent | 0b213e60440b7473a8e82be82f3b92a6bc8c03b1 (diff) |
Allow a program invoked on state change to receive sensor status. Perhaps
you might want to toggle an error light when a sensor is not OK. Perhaps
you might want to schedule a shutdown if a sensor is reporting bad news.
Now you can do this, and cancel that pending shutdown (or turn off the error
light) if the sensor decides all is well.
ok mbalmer (who came up with an almost identical diff months ago)
useful feedback and generally positive responses from deraadt, henning, msf
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.c | 33 | ||||
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.conf.5 | 4 |
2 files changed, 30 insertions, 7 deletions
diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index e15666c53b1..b24ab1f3723 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.36 2007/12/05 17:28:06 cnst Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.37 2008/03/13 21:24:45 ckuethe Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -259,7 +259,7 @@ check_sdlim(struct sdlim_t *sdlim) TAILQ_FOREACH(limit, &sdlim->limits, entries) { if ((limit->flags & SENSORSD_L_ISTATUS) && - !(limit->flags & SENSORSD_L_USERLIMIT)) + !(limit->flags & SENSORSD_L_USERLIMIT)) continue; mib[3] = limit->type; @@ -282,7 +282,7 @@ check_sdlim(struct sdlim_t *sdlim) } } } - + if (limit->flags & SENSORSD_L_USERLIMIT) { enum sensorsd_s_status newustatus; @@ -331,7 +331,7 @@ void report(time_t last_report) { struct sdlim_t *sdlim; - + TAILQ_FOREACH(sdlim, &sdlims, entries) report_sdlim(sdlim, last_report); } @@ -434,6 +434,29 @@ report_sdlim(struct sdlim_t *sdlim, time_t last_report) r = snprintf(&buf[n], len - n, "%d", limit->numt); break; + case 's': + { + char *s; + switch(limit->astatus){ + case SENSOR_S_UNSPEC: + s = "UNSPEC"; + break; + case SENSOR_S_OK: + s = "OK"; + break; + case SENSOR_S_WARN: + s = "WARNING"; + break; + case SENSOR_S_CRIT: + s = "CRITICAL"; + break; + default: + s = "UNKNOWN"; + } + r = snprintf(&buf[n], len - n, "%s", + s); + } + break; case '2': r = snprintf(&buf[n], len - n, "%s", print_sensor(limit->type, @@ -556,7 +579,7 @@ parse_config_sdlim(struct sdlim_t *sdlim, char **cfa) char node[48]; TAILQ_FOREACH(p, &sdlim->limits, entries) { - snprintf(node, sizeof(node), "hw.sensors.%s.%s%d", + snprintf(node, sizeof(node), "hw.sensors.%s.%s%d", sdlim->dxname, sensor_type_s[p->type], p->numt); p->flags = 0; if (cgetent(&buf, cfa, node) != 0) diff --git a/usr.sbin/sensorsd/sensorsd.conf.5 b/usr.sbin/sensorsd/sensorsd.conf.5 index 2f98b4b7e57..f66c8c78a0a 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.18 2007/08/14 17:10:02 cnst Exp $ +.\" $OpenBSD: sensorsd.conf.5,v 1.19 2008/03/13 21:24:45 ckuethe Exp $ .\" .\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org> .\" Copyright (c) 2005 Matthew Gream <matthew.gream@pobox.com> @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 14 2007 $ +.Dd $Mdocdate: March 13 2008 $ .Dt SENSORSD.CONF 5 .Os .Sh NAME |