Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Aug 2007 17:02:16 GMT
From:      "Constantine A. Murenin" <cnst@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 125310 for review
Message-ID:  <200708181702.l7IH2Gjd057682@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125310

Change 125310 by cnst@dale on 2007/08/18 17:01:35

	update sensorsd documentation and sync sensor types
	
	I have submitted for review and then committed all of these changes 
	upstream @ OpenBSD.
	
	Whilst here, also change the domain in my copyright, 
	and remove OpenBSD's $Mdocdate$ from .Dd

Affected files ...

.. //depot/projects/soc2007/cnst-sensors/etc/sensorsd.conf#4 edit
.. //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/Makefile#3 edit
.. //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.8#4 edit
.. //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.c#4 edit
.. //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.conf.5#4 edit

Differences ...

==== //depot/projects/soc2007/cnst-sensors/etc/sensorsd.conf#4 (text+ko) ====

@@ -1,6 +1,6 @@
-# $P4: //depot/projects/soc2007/cnst-sensors/etc/sensorsd.conf#3 $
+# $P4: //depot/projects/soc2007/cnst-sensors/etc/sensorsd.conf#4 $
 # $FreeBSD$
-# $OpenBSD: sensorsd.conf,v 1.7 2007/05/30 07:49:37 cnst Exp $
+# $OpenBSD: sensorsd.conf,v 1.8 2007/08/14 19:02:02 cnst Exp $
 
 #
 # Sample sensorsd.conf file. See sensorsd.conf(5) for details.
@@ -31,7 +31,7 @@
 
 # Warn if any temperature sensor is over 70 degC.
 # This entry will match only those temperature sensors
-# that don't have their own entry and don't keep state.
+# that don't have their own entry.
 #temp:high=70C
 
 

==== //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/Makefile#3 (text+ko) ====

@@ -1,4 +1,4 @@
-#	$P4: //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/Makefile#2 $
+#	$P4: //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/Makefile#3 $
 #	$FreeBSD$
 #	$OpenBSD: Makefile,v 1.1 2003/09/24 20:32:49 henning Exp $
 

==== //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.8#4 (text+ko) ====

@@ -1,9 +1,10 @@
-.\"	$P4: //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.8#3 $
+.\"	$P4: //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.8#4 $
 .\"	$FreeBSD$
-.\"	$OpenBSD: sensorsd.8,v 1.13 2007/07/31 08:11:36 jmc Exp $
+.\"	$OpenBSD: sensorsd.8,v 1.16 2007/08/11 20:45:35 cnst Exp $
 .\"
 .\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
 .\" Copyright (c) 2005 Matthew Gream <matthew.gream@pobox.com>
+.\" Copyright (c) 2007 Constantine A. Murenin <cnst@FreeBSD.org>
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above
@@ -17,30 +18,38 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: July 31 2007 $
+.Dd August 11, 2007
 .Dt SENSORSD 8
 .Os
 .Sh NAME
 .Nm sensorsd
-.Nd monitor hardware sensors
+.Nd hardware sensors monitor
 .Sh SYNOPSIS
 .Nm sensorsd
 .Op Fl d
 .Sh DESCRIPTION
 The
 .Nm
-utility retrieves sensor monitoring data like fan speeds,
-temperatures, voltages, and
+utility retrieves sensor monitoring data like fan speed,
+temperature, voltage and
 .Xr ami 4
 logical disk status via
 .Xr sysctl 3 .
-If the data is out of given limits, an alert is sent using
+When the state of any monitored sensor changes, an alert is sent using
 .Xr syslog 3
 and a command, if specified, is executed.
 .Pp
 By default,
 .Nm
-also monitors status changes on all sensors that keep their state.
+monitors status changes on all sensors that keep their state,
+thus sensors that automatically provide status do not require
+any additional configuration.
+In addition, for every sensor,
+no matter whether it automatically provides its state or not,
+custom low and high limits may be set,
+so that a local notion of sensor status can be computed by
+.Nm ,
+indicating whether the sensor is within or is exceeding its limits.
 .Pp
 Limit and command values for a particular sensor may be specified in the
 .Xr sensorsd.conf 5
@@ -72,3 +81,14 @@
 .Nm
 program first appeared in
 .Ox 3.5 .
+.Sh CAVEATS
+Certain sensors may flip status from time to time.
+To guard against false reports,
+.Nm
+implements a state dumping mechanism.
+However, this inevitably introduces
+an additional delay in status reporting and command execution,
+e.g. one may notice that
+.Nm
+makes its initial report about the state of monitored sensors
+not immediately, but either 1 or 2 minutes after it is being started up.

==== //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.c#4 (text+ko) ====

@@ -1,6 +1,6 @@
-/*	$P4: //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.c#3 $ */
+/*	$P4: //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.c#4 $ */
 /*	$FreeBSD$ */
-/*	$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>
@@ -490,11 +490,17 @@
 	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);
@@ -503,11 +509,14 @@
 		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);
 	}
@@ -613,9 +622,15 @@
 	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 */

==== //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.conf.5#4 (text+ko) ====

@@ -1,9 +1,10 @@
-.\"	$P4: //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.conf.5#3 $
+.\"	$P4: //depot/projects/soc2007/cnst-sensors/usr.sbin.sensorsd/sensorsd.conf.5#4 $
 .\"	$FreeBSD$
-.\"	$OpenBSD: sensorsd.conf.5,v 1.15 2007/06/05 04:10:56 jmc 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>
+.\" Copyright (c) 2007 Constantine A. Murenin <cnst@FreeBSD.org>
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above
@@ -17,21 +18,19 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate$
+.Dd August 14, 2007
 .Dt SENSORSD.CONF 5
 .Os
 .Sh NAME
 .Nm sensorsd.conf
 .Nd configuration file for sensorsd
-.Sh SYNOPSIS
-.Nm sensorsd.conf
 .Sh DESCRIPTION
 The
 .Nm
 file is read by
 .Xr sensorsd 8
 to configure hardware sensor monitoring.
-Each valid sensor registered in the system
+Each sensor registered in the system
 is matched by at most one entry in
 .Nm ,
 which may specify high and low limits,
@@ -59,7 +58,7 @@
 .Pp
 .Bl -tag -width "commandXX" -offset indent -compact
 .It Li command
-Specify a command to be executed if limits are crossed.
+Specify a command to be executed on state change.
 .It Li high
 Specify an upper limit.
 .It Li low
@@ -71,16 +70,26 @@
 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 from
+Sensors that provide status (such as those from
 .Xr bio 4 ,
 .Xr esm 4 ,
 or
 .Xr ipmi 4 )
-do not require boundary values specified (that otherwise will be
-ignored) and simply trigger on status transitions.
+do not require boundary values specified
+and simply trigger on status transitions.
+If boundaries are specified nonetheless,
+then they are used in addition to automatic status monitoring,
+unless the
+.Dq istatus
+attribute is specified to ignore status values that are provided by the drivers.
 .Pp
-The command is executed on transitions out of, and back into, given limits.
+The command is executed when there is any change in sensor state.
 Tokens in the command are substituted as follows:
 .Pp
 .Bl -tag -width Ds -offset indent -compact
@@ -114,18 +123,23 @@
 .El
 .Sh EXAMPLES
 In the following configuration file,
-if hw.sensors.ipmi0.temp0 goes above 80C, the command
+if hw.sensors.ipmi0.temp0 transitions 80C or
+if its status as provided by
+.Xr ipmi 4
+changes, the command
 .Pa /etc/sensorsd/log_warning
 will be executed,
 with the sensor type, number and current value passed to it.
-Alerts will be sent if hw.sensors.ipmi0.temp1 goes above 170F;
-if hw.sensors.lm0.volt3 goes below 4.8V or above 5.2V;
+Alerts will be sent
+if hw.sensors.lm0.volt3 transitions to being within or outside
+a range of 4.8V and 5.2V;
 if the speed of the fan attached to hw.sensors.lm0.fan1
-goes below 1000RPM or above 8000RPM;
+transitions to being below or above 1000RPM;
 if any RAID volume drive
-goes into a state other than
+changes its status from, for example,
 .Dq OK ,
-such as drive failure, rebuild, or a complete failure, the command
+such as in the case of drive failure, rebuild, or a complete failure,
+the command
 .Pa /etc/sensorsd/drive
 will be executed, with the sensor number passed to it; however,
 no alerts will be generated for status changes on timedelta sensors.
@@ -135,9 +149,8 @@
 .Bd -literal -offset indent
 # Comments are allowed
 hw.sensors.ipmi0.temp0:high=80C:command=/etc/sensorsd/log_warning %t %n %2
-hw.sensors.ipmi0.temp1:high=170F
 hw.sensors.lm0.volt3:low=4.8V:high=5.2V
-hw.sensors.lm0.fan1:low=1000:high=8000
+hw.sensors.lm0.fan1:low=1000
 drive:command=/etc/sensorsd/drive %n
 timedelta:istatus	#ignore status changes for timedelta
 .Ed
@@ -153,3 +166,22 @@
 .Nm
 file format first appeared in
 .Ox 3.5 .
+The format was altered in
+.Ox 4.1
+to accommodate hierarchical device-based sensor addressing.
+The
+.Dq istatus
+attribute was introduced in
+.Ox 4.2 .
+.Sh CAVEATS
+Alert functionality is triggered every time there is a change in sensor state;
+for example, when
+.Xr sensorsd 8
+is started,
+the status of each monitored sensor changes
+from undefined to whatever it is.
+One must keep this in mind when using commands
+that may unconditionally perform adverse actions (e.g.\&
+.Xr shutdown 8 ) ,
+as they will be executed even when all sensors perform to specification.
+If this is undesirable, then a wrapper shell script should be used instead.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708181702.l7IH2Gjd057682>