Home | History | Annotate | only in /src/usr.sbin/envstat
History log of /src/usr.sbin/envstat
RevisionDateAuthorComments
 1.11 01-Apr-2025  brad New features for envstat(8).

o The usual output of envstat(8) is meant for human consumption and it
is harder than it needs to be to extract the data and process it with
or for other systems or programs. There is a '-x' flag to output the
raw XML from the envsys(4) framework, but that doesn't run the data
though the conversions that envstat(8) does in the human output case.
So, provide a '-j' flag that outputs in JSON. Each execution of
envstat(8) will produce consistent JSON that can be piped directly
into the 'jq' command, for example. When used with the interval flag,
'-i', each interval will be consistent JSON with a separator string to
make it easier to split the input.

(as an aside, there is a '-n' option too, that just extracts the
current value from each sensor, but that is a little too terse for the
cases where a device provides multiple sensors or if you ask for
multiple devices, as you lose the ability to know what each value is
associated with)

o Provide a '-t' flag that will time stamp the output with the time
that the extraction was executed. This is only provided for the human
output, or JSON output. In the human output case, the first line is a
human readable date and time. In the JSON case, an object is included
in the output that contains the human readable date and time, and
another object that contains the Unix epoch version of the same. This
makes it possible to extract the data and have the data tell you when
it was executed.


I have been using this for a little while and it seems to work quite
well when one needs to pull a lot of sensors from the envsys(4)
framework at one time. It has ended up being much faster and less
error prone in a lot of cases then parsing the human output of
envstat(8) with regexs.
 1.10 14-Dec-2010  pooka branches: 1.10.58;
Use a consistent approach for rump kernel calls made by libs.
Should investigate a dynamic approach in the future.
 1.9 13-Dec-2010  pooka RUMP_ACTION -> RUMPPRG
 1.8 05-Nov-2010  pooka support rump client mode
 1.7 29-Oct-2009  christos option noinput nounput
 1.6 22-Apr-2009  lukem Enable WARNS=4 by default, except for:
cpuctl dumplfs hprop ipf iprop-log kadmin kcm kdc kdigest
kimpersonate kstash ktutil makefs ndbootd ntp pppd quot
racoon racoonctl rtadvd sntp sup tcpdchk tcpdmatch tcpdump
traceroute traceroute6 user veriexecgen wsmoused zic
(Mostly third-party applications)
 1.5 20-Apr-2009  drochner define YY_NO_INPUT where appropriate, from Kurt J. Lidl per PR misc/41160
 1.4 07-Oct-2007  xtraeme branches: 1.4.14;
Pass -I${.CURDIR} -I. like others do.
 1.3 07-Oct-2007  xtraeme New configuration file format for the envsys framework:

foo0 {
#
# CPU Temperature
#
sensor0 {
critical-max = 70C;
critical-min = 20C;
}
...
}
...

Removed the -m flag that was previously used to set properties for
sensors. Now the -c flag will process all properties specified in
the file (accepted as argument).

To remove all properties that were set, the new -S flag can be used.
This will restore default values for all devices.
 1.2 01-Jul-2007  xtraeme branches: 1.2.4;
Imported envsys 2, a brief description of the new features:
(Part 3: userland)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.1 10-Mar-2000  groo Add envstat(8) for displaying sensor readings from any envsys(4)
compatible device.
 1.2.4.1 06-Nov-2007  matt sync with HEAD
 1.4.14.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.10.58.1 02-Aug-2025  perseant Sync with HEAD
 1.15 06-Oct-2024  rillig envstat: remove redundant local variables

This fixes the lint warnings about "effectively discards 'const'".

No binary change.
 1.14 14-Nov-2020  mlelstv branches: 1.14.8;
For raw output (-x) allow to extract individual properties like drvctl -p.
E.g.

# envstat -x /vcmbox0/0/cur-value
328150000
 1.13 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.12 31-Aug-2011  joerg Use __dead
 1.11 08-Jun-2011  pgoyette Instead of relying on the want-percent attribute, use the sensor
type to restrict value-based limits from Battery-capacity sensors.
 1.10 05-Oct-2010  pgoyette branches: 1.10.4;
Apply proper conversion (which is _no_ conversion) when setting limit
values for sensors of type ENVSYS_INTEGER.
 1.9 15-Feb-2010  pgoyette Update userland envstat(8) to handle new {high,maximum}-capacity limits.
 1.8 22-Aug-2008  pgoyette 1. provide for warning-min and warning-max alarm levels in addition to
critical-min and critical-max; also, a battery warning-capacity is
added in addition to a critical-capacity.

2. usr.sbin/envstat is modified to introduce a -W command line switch to
display the warning-* values instead of the critical-* values, and
envstat(8) and envsys.conf(5) man pages are updated appropriately.

3. Treat user-defined limits as a single continuum and generate a single
event regardless of how many boundaries a change in sensor value
crosses; ditto for driver-defined limits.

Fixes my PR/39021
Fixes my PR/39022

OK'd by christos@ bouyer@ cube@
 1.7 02-Feb-2008  xtraeme branches: 1.7.6;
Fix a bug in the 'refresh-timeout' device property that was giving
the same value to all devices even if the configuration file was
changed.
 1.6 16-Nov-2007  xtraeme Implement the 'refresh-timeout' property in device blocks for the
configuration files. This sets the timeout value that will be used
to check for critical limits.

The value can be viewed by the 'envstat -D' command.
 1.5 09-Oct-2007  xtraeme branches: 1.5.2;
- Do not allow a 'critical-{max,min}' property in battery
sensors (those that contain the 'want-percentage' object on its
dictionary), the 'critical-capacity' prop must be used instead.

- When setting a 'critical-{max,min}' property check if the value is
higher than the 'max-value' or lower than the 'min-value' on its
dictionary, raise an error if it's true.
 1.4 09-Oct-2007  xtraeme Fix a typo that prevented a 'critical-capacity' property to
be added.
 1.3 07-Oct-2007  xtraeme If a critical-capacity property is found, make sure that the
'monitoring-supported' object is true.
 1.2 07-Oct-2007  xtraeme Use two global dictionaries rather than only one:

- use one for temporary sensor dictionaries.
- use one as the dictionary that will be returned to send_dictionary().

This fixes multiple settings in multiple devices.
 1.1 07-Oct-2007  xtraeme New configuration file format for the envsys framework:

foo0 {
#
# CPU Temperature
#
sensor0 {
critical-max = 70C;
critical-min = 20C;
}
...
}
...

Removed the -m flag that was previously used to set properties for
sensors. Now the -c flag will process all properties specified in
the file (accepted as argument).

To remove all properties that were set, the new -S flag can be used.
This will restore default values for all devices.
 1.5.2.4 23-Mar-2008  matt sync with HEAD
 1.5.2.3 09-Jan-2008  matt sync with HEAD
 1.5.2.2 06-Nov-2007  matt sync with HEAD
 1.5.2.1 09-Oct-2007  matt file config.c was added on branch matt-armv6 on 2007-11-06 23:36:23 +0000
 1.7.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.10.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14.8.1 02-Aug-2025  perseant Sync with HEAD
 1.8 15-Mar-2012  joerg Add __printflike attribution to use vprintf and friends with an argument
as format string.
 1.7 15-Feb-2010  pgoyette branches: 1.7.6;
Update userland envstat(8) to handle new {high,maximum}-capacity limits.
 1.6 29-Oct-2009  christos option noinput nounput
 1.5 28-Oct-2009  christos no unput
 1.4 22-Aug-2008  pgoyette 1. provide for warning-min and warning-max alarm levels in addition to
critical-min and critical-max; also, a battery warning-capacity is
added in addition to a critical-capacity.

2. usr.sbin/envstat is modified to introduce a -W command line switch to
display the warning-* values instead of the critical-* values, and
envstat(8) and envsys.conf(5) man pages are updated appropriately.

3. Treat user-defined limits as a single continuum and generate a single
event regardless of how many boundaries a change in sensor value
crosses; ditto for driver-defined limits.

Fixes my PR/39021
Fixes my PR/39022

OK'd by christos@ bouyer@ cube@
 1.3 16-Nov-2007  xtraeme branches: 1.3.8;
Implement the 'refresh-timeout' property in device blocks for the
configuration files. This sets the timeout value that will be used
to check for critical limits.

The value can be viewed by the 'envstat -D' command.
 1.2 07-Oct-2007  xtraeme branches: 1.2.2;
Accept '+' or '-' characters at the start of SP_STRING.
 1.1 07-Oct-2007  xtraeme New configuration file format for the envsys framework:

foo0 {
#
# CPU Temperature
#
sensor0 {
critical-max = 70C;
critical-min = 20C;
}
...
}
...

Removed the -m flag that was previously used to set properties for
sensors. Now the -c flag will process all properties specified in
the file (accepted as argument).

To remove all properties that were set, the new -S flag can be used.
This will restore default values for all devices.
 1.2.2.3 09-Jan-2008  matt sync with HEAD
 1.2.2.2 06-Nov-2007  matt sync with HEAD
 1.2.2.1 07-Oct-2007  matt file config_lex.l was added on branch matt-armv6 on 2007-11-06 23:36:24 +0000
 1.3.8.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.6.1 17-Apr-2012  yamt sync with head
 1.6 22-Apr-2020  joerg Externalize yytext, it belongs to the lexer
 1.5 15-Mar-2012  joerg Add __printflike attribution to use vprintf and friends with an argument
as format string.
 1.4 17-Jul-2008  drochner branches: 1.4.2;
include <stdlib.h> explicitely, for exit(), getprogname() etc.
(it happens to be pulled in by the yacc skeleton, but we shouldn't
rely on this)
 1.3 16-Nov-2007  xtraeme branches: 1.3.8;
Implement the 'refresh-timeout' property in device blocks for the
configuration files. This sets the timeout value that will be used
to check for critical limits.

The value can be viewed by the 'envstat -D' command.
 1.2 07-Oct-2007  xtraeme branches: 1.2.2;
Use another main rule to avoid a conflict in the grammar.
Suggestion from martin@.
 1.1 07-Oct-2007  xtraeme New configuration file format for the envsys framework:

foo0 {
#
# CPU Temperature
#
sensor0 {
critical-max = 70C;
critical-min = 20C;
}
...
}
...

Removed the -m flag that was previously used to set properties for
sensors. Now the -c flag will process all properties specified in
the file (accepted as argument).

To remove all properties that were set, the new -S flag can be used.
This will restore default values for all devices.
 1.2.2.3 09-Jan-2008  matt sync with HEAD
 1.2.2.2 06-Nov-2007  matt sync with HEAD
 1.2.2.1 07-Oct-2007  matt file config_yacc.y was added on branch matt-armv6 on 2007-11-06 23:36:24 +0000
 1.3.8.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.72 01-Apr-2025  uwe envstat(8): use \(aq for literal ASCII single quote in examples

Literal ASCII single quote in the input becomes right single quote in
the PostScript output. While that is the look from the old dead tree
manuals that we know and love, it does the wrong thing when
copy-pasted from a PDF document, so make sure the examples come out
right with the literal ASCII single quotes in them.
 1.71 01-Apr-2025  uwe envstat(8): tweak examples

Drop shell prompt, we don't show any sample output, so we don't need
to mark the command as input. Explicitly split longer commands with a
backslash continuation.
 1.70 01-Apr-2025  uwe envstat(8): use .Bl -column for units
 1.69 01-Apr-2025  uwe envstat(8): brush up markup
 1.68 01-Apr-2025  brad New features for envstat(8).

o The usual output of envstat(8) is meant for human consumption and it
is harder than it needs to be to extract the data and process it with
or for other systems or programs. There is a '-x' flag to output the
raw XML from the envsys(4) framework, but that doesn't run the data
though the conversions that envstat(8) does in the human output case.
So, provide a '-j' flag that outputs in JSON. Each execution of
envstat(8) will produce consistent JSON that can be piped directly
into the 'jq' command, for example. When used with the interval flag,
'-i', each interval will be consistent JSON with a separator string to
make it easier to split the input.

(as an aside, there is a '-n' option too, that just extracts the
current value from each sensor, but that is a little too terse for the
cases where a device provides multiple sensors or if you ask for
multiple devices, as you lose the ability to know what each value is
associated with)

o Provide a '-t' flag that will time stamp the output with the time
that the extraction was executed. This is only provided for the human
output, or JSON output. In the human output case, the first line is a
human readable date and time. In the JSON case, an object is included
in the output that contains the human readable date and time, and
another object that contains the Unix epoch version of the same. This
makes it possible to extract the data and have the data tell you when
it was executed.


I have been using this for a little while and it seems to work quite
well when one needs to pull a lot of sensors from the envsys(4)
framework at one time. It has ended up being much faster and less
error prone in a lot of cases then parsing the human output of
envstat(8) with regexs.
 1.67 21-Nov-2022  brad branches: 1.67.4;


A driver for the Bosch BMP280 / BME280 temperature, humidity and
atmospheric pressure sensor. This is an inexpensive to moderately
expensive chip available from a large number of places. The driver
supports all aspects of the two chips, except for the repeating read
mode which would allow for sub-second queries, such as fall detection
or perhaps even as an altimeter. This driver also only supports the
I2C interface and not the SPI interface.

The BME280, the one with humidity, is not fully tested at this point,
awaiting upon a breakout board and may not show proper humidity.
 1.66 14-Nov-2020  wiz New sentence, new line.
Other whitespace fixes, and some Xr fixes.
 1.65 14-Nov-2020  mlelstv Add option -n to print only the value of a sensor.
If statistics are selected with -T, then also display max, min and average.
The empty line between each display is skipped when one or more sensors are
selected with -s.
 1.64 14-Nov-2020  mlelstv Allow to select raw output for a single device or a list of sensors.
 1.63 14-Nov-2020  mlelstv For raw output (-x) allow to extract individual properties like drvctl -p.
E.g.

# envstat -x /vcmbox0/0/cur-value
328150000
 1.62 18-May-2014  kardel add HYT-221/271/939 humidity/temperature I2C sensor
extend envsys(4) framework by %rH (relative humidity)
 1.61 09-Feb-2012  riz branches: 1.61.6; 1.61.16;
Various English usage, spelling and markup fixes for envstat(4)-related
things, from Snader_LB.
 1.60 07-Jun-2011  wiz branches: 1.60.2;
Sort sections.
 1.59 07-Jun-2011  pgoyette Add a BUGS section to point out that the statistic "average" is an
average only of the current, minimum, and maximum values, and not a
running average of all displayed current values.
 1.58 05-Oct-2010  njoly branches: 1.58.4;
Add option k to synopsis.
 1.57 09-Jul-2010  reed Add brief explanations of unit abbreviations.
Add units(1) to see also.
 1.56 19-Mar-2010  cnst Remove aiboost(4) as obsolete and redundant since the introduction of aibs(4).

http://mail-index.netbsd.org/tech-kern/2010/03/06/msg007458.html

Reviewed by <pgoyette>, <cegger>, <jruoho>, <tech-kern>.
 1.55 15-Feb-2010  pgoyette Update cross-reference to refer to new aibs(4) instead of aiboost(4)
 1.54 09-Feb-2010  cnst New aibs(4) driver for ASUSTeK AI Booster (ACPI ATK0110) hardware monitor
with limit support.

http://thread.gmane.org/gmane.os.netbsd.devel.kernel/35654

Reviewed by <pgoyette>, <jruoho> and <tech-kern>.
 1.53 30-Jan-2010  wiz New sentence, new line.
 1.52 30-Jan-2010  pgoyette Since we never have both a limit value and a limit %capacity value,
remove the Capacity column.

Reduce inter-column spacing, and display all four limits on one page,
rather than using the -W command line option to switch between critical
and warning limits. (The -W option is still permitted, but has no
effect.)

%capacity limits are displayed in the WarnMin and CritMin columns, but
have a trailing % sign.
 1.51 04-May-2009  wiz Add missing apostrophe.
 1.50 15-Feb-2009  wiz New sentence, new line. Bump date for previous.
 1.49 14-Feb-2009  ahoka Add support for showing temperatures in Kelvin.
 1.48 29-Oct-2008  jkunz branches: 1.48.4;
Ported alipm(4) and admtemp(4) from OpenBSD.
 1.47 11-Oct-2008  pgoyette Update cross-references for addition of dbcool(4) and removal of adt7463c(4)
and adt7467c(4).
 1.46 22-Aug-2008  pgoyette 1. provide for warning-min and warning-max alarm levels in addition to
critical-min and critical-max; also, a battery warning-capacity is
added in addition to a critical-capacity.

2. usr.sbin/envstat is modified to introduce a -W command line switch to
display the warning-* values instead of the critical-* values, and
envstat(8) and envsys.conf(5) man pages are updated appropriately.

3. Treat user-defined limits as a single continuum and generate a single
event regardless of how many boundaries a change in sensor value
crosses; ditto for driver-defined limits.

Fixes my PR/39021
Fixes my PR/39022

OK'd by christos@ bouyer@ cube@
 1.45 30-Apr-2008  martin branches: 1.45.2;
Convert TNF licenses to new 2 clause variant
 1.44 26-Apr-2008  xtraeme * Improve default display output by adding a header that will match
current value as well as critical limits set and sensor unit.

* Add a new flag: -T. When it's enabled statistics will be created for
the sensors. Max, min and average statistics as well as sensor unit
will be displayed. Must be used with an interval.

You can see the new code in action here:

http://www.netbsd.org/~xtraeme/envstat_stats.txt

Thanks to jmcneill@ for comments and ideas.
 1.43 22-Apr-2008  cegger amdtemp(4): Driver for AMD CPU Temperature Sensors. Adopted from OpenBSD's kate(4).
Changes beyond OpenBSD's driver:
- Improved support for AMD K8
- Added support for AMD Barcelona, AMD Phenom and AMD Griffin
Tested on various single and multi-socket machines.
Review and OK xtreame
 1.42 17-Apr-2008  xtraeme branches: 1.42.2;
* Add support to show output from specified sensors in multiple devices
via the -s flag (the requirement for -d is not there anymore). [1]

You can do something like the following now:

$ envstat -s "acpibat0:charge,acpibat0:charge state,acpitz0:temperature"
[acpibat0]
charge: 3.015 Ah (79.70%)
charge state: NORMAL
[acpitz0]
temperature: 54.000 degC
$

* As bonus, the code has been modified to use a simple queue for
the sensors, and this has simplified and improved some parts of the
code as well.

[1] Item requested by joerg@ yesterday.
 1.41 03-Apr-2008  xtraeme Mention finsio(4).
 1.40 02-Apr-2008  xtraeme Mention pic16lc(4).
 1.39 02-Apr-2008  xtraeme Mention cac(4).
 1.38 02-Apr-2008  xtraeme Mention adt7463c(4) and thinkpad(4) even if the manpages don't exist.

This is to have a reference about which drivers are using the envsys
framework.
 1.37 29-Feb-2008  xtraeme Xref arcmsr(4).
 1.36 12-Dec-2007  xtraeme branches: 1.36.2;
Xref battery_pmu(4).
 1.35 01-Dec-2007  wiz Sort SEE ALSO.
 1.34 16-Nov-2007  xtraeme Implement the 'refresh-timeout' property in device blocks for the
configuration files. This sets the timeout value that will be used
to check for critical limits.

The value can be viewed by the 'envstat -D' command.
 1.33 29-Oct-2007  xtraeme Mention coretemp(4).
 1.32 07-Oct-2007  xtraeme Another comment that is no more thanks to the new configuration file.
 1.31 07-Oct-2007  xtraeme Modify a comment that is not valid anymore.
 1.30 07-Oct-2007  xtraeme Xref envsys.conf(5)
 1.29 07-Oct-2007  xtraeme New configuration file format for the envsys framework:

foo0 {
#
# CPU Temperature
#
sensor0 {
critical-max = 70C;
critical-min = 20C;
}
...
}
...

Removed the -m flag that was previously used to set properties for
sensors. Now the -c flag will process all properties specified in
the file (accepted as argument).

To remove all properties that were set, the new -S flag can be used.
This will restore default values for all devices.
 1.28 25-Sep-2007  xtraeme Merge a patch from Iain Hibbert (plunky@):

- some unclear language cleaned up
- inconsistent usage of 'device' and 'driver' to refer to the same thing
- difficult error handling

And print the device name if -d flag is not specified for any driver
registered, e.g:

$ envstat
[aiboost0]
CPU Temperature: 36.000 degC max: 70.000 degC min: 15.000 degC
MB Temperature: 38.000 degC max: 50.000 degC min: 15.000 degC
Vcore Voltage: 1.232 V max: 1.350 V min: 1.150 V
+3.3 Voltage: 3.264 V max: 3.500 V min: 3.000 V
+5 Voltage: 5.017 V max: 5.600 V min: 4.500 V
+12 Voltage: 11.932 V max: 13.500 V min: 11.200 V
CPU FAN Speed: 1268 RPM
$
 1.27 20-Sep-2007  plunky replace inadvertently removed N
 1.26 20-Sep-2007  plunky sort options
 1.25 11-Sep-2007  xtraeme Mention aps(4).
 1.24 02-Sep-2007  xtraeme Fix typo in previous.
 1.23 02-Sep-2007  xtraeme Add the -I flag that skips sensors with invalid state. They are shown
by default, but this is for users that don't want to print them.
 1.22 07-Aug-2007  seb branches: 1.22.2;
Fix typo.
Ok'ed by xtraeme@
 1.21 17-Jul-2007  xtraeme Add the -r flag, which is a dummy flag... only added for compatibility
reasons.
 1.20 05-Jul-2007  xtraeme tyop
 1.19 04-Jul-2007  xtraeme Fix the example that used -s without -d, found by hira@.
 1.18 04-Jul-2007  xtraeme Improve description about the -s flag, it must be used with -d.
 1.17 02-Jul-2007  xtraeme Two grammar fixes from Zafer Aydogan.
 1.16 01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 3: userland)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.15 07-May-2007  xtraeme Mention mfi(4), bump date.
 1.14 19-Apr-2007  xtraeme * tctrl(4) -> sparc/tctrl(4)
* Mention sparc64/envctrl(4) (hi tnn)
 1.13 14-Mar-2007  xtraeme Erm add missing char.
 1.12 14-Mar-2007  xtraeme Last one: mention adt7467c(4).
 1.11 14-Mar-2007  xtraeme Mention ipmi(4), nsclpcsio(4), owtemp(4), tctrl(4) and tm121temp(4).
 1.10 14-Mar-2007  xtraeme Mention aiboost(4), it(4), ug(4) and viaenv(4), bump date.
 1.9 23-Dec-2006  wiz Bump date for previous. Remove trailing whitespace.
 1.8 14-Dec-2006  reed Add a useful example.
 1.7 25-Apr-2004  kochi add references to ACPI man pages.
 1.6 02-Jan-2003  augustss branches: 1.6.2;
Add -r to synopsis.
 1.5 02-Jan-2003  wiz New sentence, new line. Bump date for -r description.
 1.4 02-Jan-2003  augustss Document the -r flag.
 1.3 19-Jan-2002  wiz Drop a trailing empty line.
 1.2 24-Jun-2000  thorpej If the `device' argument is not specified, attempt to open /dev/sysmon.
 1.1 10-Mar-2000  groo branches: 1.1.4;
Add envstat(8) for displaying sensor readings from any envsys(4)
compatible device.
 1.1.4.1 30-Jul-2000  bouyer Pull up (requested by thorpej):
envstat.8 1.1->1.2
envstat.c 1.2->1.3

If the `device' argument is not specified, attempt to open /dev/sysmon.
 1.6.2.1 06-May-2004  jmc Pullup rev 1.7 (requested by kochi in ticket #250)

Add references to ACPI man pages.
 1.22.2.3 23-Mar-2008  matt sync with HEAD
 1.22.2.2 09-Jan-2008  matt sync with HEAD
 1.22.2.1 06-Nov-2007  matt sync with HEAD
 1.36.2.1 24-Mar-2008  keiichi sync with head.
 1.42.2.1 18-May-2008  yamt sync with head.
 1.45.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.48.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.58.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.60.2.1 17-Apr-2012  yamt sync with head
 1.61.16.1 10-Aug-2014  tls Rebase.
 1.61.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.67.4.1 02-Aug-2025  perseant Sync with HEAD
 1.105 01-Apr-2025  brad New features for envstat(8).

o The usual output of envstat(8) is meant for human consumption and it
is harder than it needs to be to extract the data and process it with
or for other systems or programs. There is a '-x' flag to output the
raw XML from the envsys(4) framework, but that doesn't run the data
though the conversions that envstat(8) does in the human output case.
So, provide a '-j' flag that outputs in JSON. Each execution of
envstat(8) will produce consistent JSON that can be piped directly
into the 'jq' command, for example. When used with the interval flag,
'-i', each interval will be consistent JSON with a separator string to
make it easier to split the input.

(as an aside, there is a '-n' option too, that just extracts the
current value from each sensor, but that is a little too terse for the
cases where a device provides multiple sensors or if you ask for
multiple devices, as you lose the ability to know what each value is
associated with)

o Provide a '-t' flag that will time stamp the output with the time
that the extraction was executed. This is only provided for the human
output, or JSON output. In the human output case, the first line is a
human readable date and time. In the JSON case, an object is included
in the output that contains the human readable date and time, and
another object that contains the Unix epoch version of the same. This
makes it possible to extract the data and have the data tell you when
it was executed.


I have been using this for a little while and it seems to work quite
well when one needs to pull a lot of sensors from the envsys(4)
framework at one time. It has ended up being much faster and less
error prone in a lot of cases then parsing the human output of
envstat(8) with regexs.
 1.104 19-Jun-2023  rin branches: 1.104.2;
Silence wrong maybe-uninitialized raised by GCC/x86_64 10.4.0 -Os.
 1.103 21-Nov-2022  brad branches: 1.103.2;


A driver for the Bosch BMP280 / BME280 temperature, humidity and
atmospheric pressure sensor. This is an inexpensive to moderately
expensive chip available from a large number of places. The driver
supports all aspects of the two chips, except for the repeating read
mode which would allow for sub-second queries, such as fall detection
or perhaps even as an altimeter. This driver also only supports the
I2C interface and not the SPI interface.

The BME280, the one with humidity, is not fully tested at this point,
awaiting upon a breakout board and may not show proper humidity.
 1.102 28-May-2022  andvar fix various typos, mainly in comments.
 1.101 27-Nov-2021  rillig usr.sbin: remove unnecessary CONSTCOND, lint no longer needs it

Since 2021-01-31, lint no longer requires a CONSTCOND comment in a
do-while-0 statement since this is a common code pattern, especially in
statement-like macros.

sed -i -E 's,} while \(/\* ?CONSTCOND ?\*/ ?0\),} while (0),' */*.[ch]
 1.100 14-Nov-2020  mlelstv Add option -n to print only the value of a sensor.
If statistics are selected with -T, then also display max, min and average.
The empty line between each display is skipped when one or more sensors are
selected with -s.
 1.99 14-Nov-2020  mlelstv Allow to select raw output for a single device or a list of sensors.
 1.98 14-Nov-2020  mlelstv For raw output (-x) allow to extract individual properties like drvctl -p.
E.g.

# envstat -x /vcmbox0/0/cur-value
328150000
 1.97 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.96 27-May-2018  thorpej Add support for light sensors that report Illuminance in lux.
 1.95 18-May-2014  kardel branches: 1.95.22;
add HYT-221/271/939 humidity/temperature I2C sensor
extend envsys(4) framework by %rH (relative humidity)
 1.94 14-Dec-2012  pgoyette branches: 1.94.6;
Since we're no longer making a copy of the option args, we shouldn't
attempt to free it.
 1.93 13-Dec-2012  christos - no point in allocating memory to hold command line arguments.
- allocate memory inside the function used.
 1.92 13-Dec-2012  christos PR/47316: Henning Petersen: Memory leak in envstat with config file.
 1.91 11-May-2012  njoly branches: 1.91.2;
Fix alignment display for temperature, fans and integer units.
 1.90 09-Feb-2012  riz Various English usage, spelling and markup fixes for envstat(4)-related
things, from Snader_LB.
 1.89 04-Dec-2011  jmcneill change printed indicator and battery charge strings from ON and OFF to TRUE
and FALSE, because messages like "battery present: ON" are difficult for my
brain to parse.
 1.88 07-Jun-2011  pgoyette branches: 1.88.2;
Zero is a valid value for some sensors so update statistics code to
handle that.
 1.87 06-Jun-2011  pgoyette 1. Don't print blank for Integer sensors with value of zero
2. Properly print percentages in -T statistics mode
3. Always set Sensor Type (units) to a non-NULL value
4. Enable printing of percentages for Integer sensors
 1.86 04-Jun-2011  pgoyette Since there is no longer a value-avg property, remove the code that
extracts it.
 1.85 16-Dec-2010  pgoyette branches: 1.85.4;
When skipping output for a temperature of absolute zero, don't forget to
skip past the display columns that the value would otherwise occupy.

Fixes display issue when swsensor(4) is used and it has a value of 0K,
as reported by njoly@
 1.84 14-Dec-2010  pooka Use a consistent approach for rump kernel calls made by libs.
Should investigate a dynamic approach in the future.
 1.83 13-Dec-2010  pooka RUMP_ACTION -> RUMPPRG
 1.82 05-Nov-2010  pooka adapt to new rumpclient_init() signature
 1.81 05-Nov-2010  pooka support rump client mode
 1.80 05-Oct-2010  pgoyette Some Integer-type sensors can have limits, so allow them to be displayed.
 1.79 26-Aug-2010  jruoho Use <paths.h>. Remove trailing white space.
 1.78 01-Aug-2010  mlelstv Print the correct value for critmin of a fan sensor.
 1.77 15-Feb-2010  pgoyette Update userland envstat(8) to handle new {high,maximum}-capacity limits.
 1.76 12-Feb-2010  njoly Fix double free, when requesting an invalid sensor.
 1.75 12-Feb-2010  cnst remove the fourth (empty) column from the -T printouts; ok pgoyette
 1.74 09-Feb-2010  cnst fix a typo resulting in warn-max being shown in two columns (one time instead of crit-min); ok pgoyette
 1.73 30-Jan-2010  pgoyette Since we never have both a limit value and a limit %capacity value,
remove the Capacity column.

Reduce inter-column spacing, and display all four limits on one page,
rather than using the -W command line option to switch between critical
and warning limits. (The -W option is still permitted, but has no
effect.)

%capacity limits are displayed in the WarnMin and CritMin columns, but
have a trailing % sign.
 1.72 04-Apr-2009  christos fix pasto: don't print the critcap when the warncap was asked. Also off by
one in length. From Anon-Ymous.
XXX: Should pull up to 5.0
 1.71 14-Feb-2009  ahoka Add support for showing temperatures in Kelvin.
 1.70 22-Aug-2008  pgoyette branches: 1.70.4; 1.70.6;
1. provide for warning-min and warning-max alarm levels in addition to
critical-min and critical-max; also, a battery warning-capacity is
added in addition to a critical-capacity.

2. usr.sbin/envstat is modified to introduce a -W command line switch to
display the warning-* values instead of the critical-* values, and
envstat(8) and envsys.conf(5) man pages are updated appropriately.

3. Treat user-defined limits as a single continuum and generate a single
event regardless of how many boundaries a change in sensor value
crosses; ditto for driver-defined limits.

Fixes my PR/39021
Fixes my PR/39022

OK'd by christos@ bouyer@ cube@
 1.69 09-Aug-2008  christos simplify the code, from xtraeme.
 1.68 25-May-2008  christos remove printf when the sensor has no statistics; requested by xtraeme.
 1.67 24-May-2008  christos Don't code using side-effects (eliminate queue variable). Unconfuses Coverity
CID 5031.
 1.66 24-May-2008  christos Coverity CID 5034: Use after free. Restructure the code to simplify it and
print the error.
 1.65 29-Apr-2008  xtraeme branches: 1.65.2;
Don't show statistics in sensors that will provide a percentage.
 1.64 26-Apr-2008  xtraeme Add missing cast, noticed by Paul Goyette in current-users@.
 1.63 26-Apr-2008  xtraeme Cur -> Current for the header.
 1.62 26-Apr-2008  xtraeme In default display mode, fix up the indentation for the critical
limits so that they appear in the correct column.
 1.61 26-Apr-2008  xtraeme * Improve default display output by adding a header that will match
current value as well as critical limits set and sensor unit.

* Add a new flag: -T. When it's enabled statistics will be created for
the sensors. Max, min and average statistics as well as sensor unit
will be displayed. Must be used with an interval.

You can see the new code in action here:

http://www.netbsd.org/~xtraeme/envstat_stats.txt

Thanks to jmcneill@ for comments and ideas.
 1.60 17-Apr-2008  xtraeme branches: 1.60.2;
Remove the 'dvnprinted' bool member of sensor_t, it's unused.
 1.59 17-Apr-2008  xtraeme * Add support to show output from specified sensors in multiple devices
via the -s flag (the requirement for -d is not there anymore). [1]

You can do something like the following now:

$ envstat -s "acpibat0:charge,acpibat0:charge state,acpitz0:temperature"
[acpibat0]
charge: 3.015 Ah (79.70%)
charge state: NORMAL
[acpitz0]
temperature: 54.000 degC
$

* As bonus, the code has been modified to use a simple queue for
the sensors, and this has simplified and improved some parts of the
code as well.

[1] Item requested by joerg@ yesterday.
 1.58 16-Nov-2007  xtraeme Implement the 'refresh-timeout' property in device blocks for the
configuration files. This sets the timeout value that will be used
to check for critical limits.

The value can be viewed by the 'envstat -D' command.
 1.57 03-Nov-2007  xtraeme - Rename ENVSYS_BATTERY_STATE units to ENVSYS_BATTERY_CAPACITY and
introduce ENVSYS_BATTERY_CHARGE, which is the same than an Indicator and
it's used to know if the battery is currently charging or discharging.

- Require two sensors at least for SME_CLASS_BATTERY to make the low-power
condition work: a ENVSYS_BATTERY_CAPACITY plus ENVSYS_BATTERY_CHARGE.

- Simplify sme_event_check_lowpower() and make it check the required
sensors in the SME_CLASS_ACADAPTER and SME_CLASS_BATTERY classes.
If the acadapter is not ready, trust the state returned by the battery
device.

Based on suggestion from joerg@.
 1.56 07-Oct-2007  xtraeme New configuration file format for the envsys framework:

foo0 {
#
# CPU Temperature
#
sensor0 {
critical-max = 70C;
critical-min = 20C;
}
...
}
...

Removed the -m flag that was previously used to set properties for
sensors. Now the -c flag will process all properties specified in
the file (accepted as argument).

To remove all properties that were set, the new -S flag can be used.
This will restore default values for all devices.
 1.55 25-Sep-2007  xtraeme - Simplify find_sensors().
- Remove a block that is not used anymore in check_sensors().
 1.54 25-Sep-2007  xtraeme Merge a patch from Iain Hibbert (plunky@):

- some unclear language cleaned up
- inconsistent usage of 'device' and 'driver' to refer to the same thing
- difficult error handling

And print the device name if -d flag is not specified for any driver
registered, e.g:

$ envstat
[aiboost0]
CPU Temperature: 36.000 degC max: 70.000 degC min: 15.000 degC
MB Temperature: 38.000 degC max: 50.000 degC min: 15.000 degC
Vcore Voltage: 1.232 V max: 1.350 V min: 1.150 V
+3.3 Voltage: 3.264 V max: 3.500 V min: 3.000 V
+5 Voltage: 5.017 V max: 5.600 V min: 4.500 V
+12 Voltage: 11.932 V max: 13.500 V min: 11.200 V
CPU FAN Speed: 1268 RPM
$
 1.53 20-Sep-2007  plunky sort options
 1.52 10-Sep-2007  xtraeme Another typo in a comment.
 1.51 10-Sep-2007  xtraeme Fix a comment.
 1.50 10-Sep-2007  xtraeme Check argc before calling open(2), and use the out label in another
error case.
 1.49 10-Sep-2007  xtraeme Fix a lint(1) warning and remove oldsize in print_sensors(), it's
not used.
 1.48 10-Sep-2007  xtraeme Don't forget to check if -s was specified without -d, and add a macro
to check it in two places.
 1.47 10-Sep-2007  xtraeme Redo how the arguments are processed, so that arguments not allowed
will call usage(). Also remove an extra free().
 1.46 04-Sep-2007  xtraeme Update to match current kernel code.
 1.45 02-Sep-2007  xtraeme Add the -I flag that skips sensors with invalid state. They are shown
by default, but this is for users that don't want to print them.
 1.44 02-Sep-2007  xtraeme Add a new sensor type to sysmon_envsys(9): ENVSYS_GSTRING.

ENVSYS_GSTRING (aka Generic String) uses the genstr member in
the envsys_data_t struct to add a generic string that envstat(8)
will show as value or state.

It's like the ENVSYS_DRIVER, but doesn't use value_cur. Below
is the dictionary created on these sensors:

<dict>
<key>description</key>
<string>acpibat0 charge state</string>
<key>generic-state-string</key>
<string>NORMAL</string>
<key>monitoring-supported</key>
<false/>
<key>state</key>
<string>valid</string>
<key>type</key>
<string>Generic string</string>
</dict>

Note that it's limited to 32 chars, but we can grow it if needed.

envstat(8) will print ENVSYS_GSTRING sensors as:

$ envstat -dacpibat0 -s"acpibat0 charge state"
acpibat0 charge state: NORMAL
$
 1.43 29-Aug-2007  xtraeme In temperature sensors, do not convert to degC or degF if there's
no value returned.
 1.42 26-Aug-2007  xtraeme branches: 1.42.2;
Check if the dictionary is empty and print a message if it's true.
 1.41 05-Aug-2007  xtraeme branches: 1.41.2;
The caller of prop_dictionary_externalize is responsible to free the
returned buffer... make it so. Reminded by prop_dictionary(3).
 1.40 21-Jul-2007  xtraeme Erm... fix previous.
 1.39 21-Jul-2007  xtraeme Fix a logic bug: report a message and error if -s or -m is being used
without -d.
 1.38 17-Jul-2007  xtraeme Return the value returned by prop_dictionary_recv_ioctl() if the -x flag
is specified too.
 1.37 17-Jul-2007  xtraeme - Return the value returned by prop_dictionary_{recv,send}_ioctl
in all cases.
- Skip sensors that do not have a description object in its dictionary.
 1.36 17-Jul-2007  xtraeme Only allow to use ENVSYS_SETDICTIONARY if the user has write permission
in the /dev/sysmon device.

Use O_RDONLY for ENVSYS_GETDICTIONARY and O_RDWR for ENVSYS_SETDICTIONARY
in envstat(8).

Fixes PR kern/36661 by YAMAMOTO Takashi.
 1.35 17-Jul-2007  xtraeme Add the -r flag, which is a dummy flag... only added for compatibility
reasons.
 1.34 13-Jul-2007  xtraeme Define a set of macros to avoid writting same code many times.
 1.33 12-Jul-2007  xtraeme Add a missing printf in parse_dictionary() and simplify this part to
avoid code duplication in two places.
 1.32 12-Jul-2007  xtraeme Remove a comment that is not valid anymore.
 1.31 12-Jul-2007  xtraeme - Do not refrence memory already freed, thanks to Geoff C. Wing for
the analysis. Closes PR bin/36636.
- Also use the longest string for the column alignment counting all
sensors available from all devices, not per-device.

Thanks to rmind@ for help.
 1.30 05-Jul-2007  xtraeme Align drive state string like other sensor types.
 1.29 05-Jul-2007  xtraeme Before checking sensor type:

- check if if its state is invalid
- print the 'N/A' string and continue

This avoids code duplication.
 1.28 05-Jul-2007  xtraeme Print invalid state with 'N/A' for Indicators, like any other sensors.

We follow the following scheme now:

value_cur set => ON
value_cur not set => OFF
invalid state => N/A
 1.27 05-Jul-2007  xtraeme Print 'N/A' for invalid sensors rather than an asterisk, with the
exception of Indicator sensors.

Indicator sensors now will print "ON" if they are in valid state, or
"OFF" if they are in invalid state.
 1.26 04-Jul-2007  xtraeme By popular demand, do not skip sensors with invalid state. Print them
with an asterisk, as was suggested by Greg. A. Woods.

Example:

$ ./envstat -dlm0 -s "CPU Fan,System Fan,Aux Fan"
System Fan: *
CPU Fan: 1308 RPM
Aux Fan: *
$

Except Integer and Driver sensors, which shouldn't need that.
 1.25 01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 3: userland)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.24 01-May-2007  bouyer Add bio(4) and associated bioctl(8) from OpenBSD, a driver control block
device controllers, and more specifically raid controllers.
Add a new sensor type, ENVSYS_DRIVE, to report drive status. From OpenBSD.
Add bio and sysmon support to mfi(4). This allow userland to query
status for drives and logical volumes attached to a mfi(4) controller. While
there fix some debug printfs in mfi so they compile.
Add bio(4) to amd64 and i386 GENERIC.
 1.23 31-Aug-2006  gson branches: 1.23.2;
In -i mode, flush standard output after each line. This is needed to
make the output appear in a timely fashion when redirected to a file
or pipe.
 1.22 03-Jun-2004  wiz branches: 1.22.2;
One r in the option string is enough; from Jeff Ito.
 1.21 03-Jun-2004  wiz Remove unhandled option letter c from option string, noted by Jeff Ito.
 1.20 03-Jun-2004  wiz Sync usage with man page.
From Kouichirou Hiratsuka in PR 25798.
 1.19 25-Mar-2004  mrg - move the row printing code into it's own function.
- pay attention to interval processing with row printing (-r -iN).

the latter fixes PR#24522.
 1.18 21-Mar-2004  mrg in -r mode, if given "-s sensor_list", only list the given sensors instead
of always listing them all
 1.17 02-Feb-2004  soren As pointed out by Dave Huang, revert back to using 273.15 rather than 273.16
when converting between kelvin and celsius.
 1.16 02-Feb-2004  soren C = K + 273.16.
 1.15 05-Jan-2004  jmmv Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
 1.14 31-Oct-2003  mycroft Don't display data for sensors with ENVSYS_FCURVALID not set.
Clean up a little.
 1.13 21-Feb-2003  martin Not all size_t's are equal to int...
 1.12 20-Feb-2003  christos - pass lint
- use size_t where appropriate
- use err/warn instead of printf, and don't hide the error messages from ioctl.
- keep units in sync (someone added integer in the header file and forgot
to update envsys.c)
 1.11 11-Jan-2003  christos fix usage [add -r]
 1.10 05-Jan-2003  christos exit 0 when -r
 1.9 05-Jan-2003  chris Update -r option to display data in correct units, IE temperature in degC or
degF, fan speed is now correct, and indicators will now show ON/OFF.
 1.8 01-Jan-2003  augustss Include <paths.h>
 1.7 01-Jan-2003  augustss ANSIfy.
 1.6 31-Dec-2002  explorer add ENVSYS_INDICATOR and ENVSYS_INTEGER types
 1.5 19-Feb-2001  cgd convert to use getprogname()
 1.4 02-Jul-2000  augustss Indicate that the device argument is not mandatory.
 1.3 24-Jun-2000  thorpej If the `device' argument is not specified, attempt to open /dev/sysmon.
 1.2 14-Apr-2000  simonb branches: 1.2.4;
Don't declare 'extern opt*' getopt variables.
 1.1 10-Mar-2000  groo Add envstat(8) for displaying sensor readings from any envsys(4)
compatible device.
 1.2.4.1 30-Jul-2000  bouyer Pull up (requested by thorpej):
envstat.8 1.1->1.2
envstat.c 1.2->1.3

If the `device' argument is not specified, attempt to open /dev/sysmon.
 1.22.2.1 15-Oct-2007  riz Pull up following revisions via patch (requested by bouyer in ticket #1838):
distrib/sets/lists/man/mi: revision 1.997
sbin/bioctl/strtonum.c: revision 1.1
sys/dev/Makefile: revision 1.25
sys/arch/amd64/conf/GENERIC: revision 1.139
sbin/bioctl/strtonum.h: revision 1.1
sys/dev/bio.c: revision 1.1
sbin/bioctl/bioctl.c: revision 1.1
share/man/man4/bio.4: revision 1.1
sbin/bioctl/bioctl.8: revision 1.1
sys/sys/envsys.h: revision 1.11
sbin/bioctl/bioctl.8: revision 1.3
sbin/bioctl/bioctl.8: revision 1.4
sys/arch/i386/conf/XEN2_DOM0: revision 1.25
distrib/sets/lists/base/mi: revision 1.704
sys/conf/majors: revision 1.34
share/man/man4/Makefile: revision 1.426
etc/MAKEDEV.tmpl: revision 1.86
sys/arch/i386/conf/GENERIC: revision 1.825
distrib/sets/lists/comp/mi: revision 1.1022
sys/conf/files: revision 1.839
usr.sbin/envstat/envstat.c: revision 1.24
sbin/Makefile: revision 1.105
sys/dev/ic/mfi.c: revision 1.4
sys/dev/biovar.h: revision 1.1
sys/dev/ic/mfivar.h: revision 1.4
sbin/bioctl/Makefile: revision 1.1
Fix typo.
Add bio(4) and associated bioctl(8) from OpenBSD, a driver control block
device controllers, and more specifically raid controllers.
Add a new sensor type, ENVSYS_DRIVE, to report drive status. From OpenBSD.
Add bio and sysmon support to mfi(4). This allow userland to query
status for drives and logical volumes attached to a mfi(4) controller. While
there fix some debug printfs in mfi so they compile.
Add bio(4) to amd64 and i386 GENERIC.
Add bio(4) and associated bioctl(8) from OpenBSD, a driver control block
device controllers, and more specifically raid controllers.
Add a new sensor type, ENVSYS_DRIVE, to report drive status. From OpenBSD.
Add bio and sysmon support to mfi(4). This allow userland to query
status for drives and logical volumes attached to a mfi(4) controller. While
there fix some debug printfs in mfi so they compile.
Add bio(4) to amd64 and i386 GENERIC.
Fix Dd argument (use full month names).
Use more markup.
Comment out references to safte(4) and softraid(4), which don't exist in
NetBSD.
Remove trailing whitespace.
Use macros instead of characters for HTML output (replace ">", "<"
with \*[Gt], \*[Lt]).
Sort sections.
Create /dev/bio
 1.23.2.1 08-May-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #603):
distrib/sets/lists/base/mi: revision 1.704
distrib/sets/lists/comp/mi: revision 1.1022
distrib/sets/lists/man/mi: revision 1.997
doc/CHANGES: revision 1.839
sbin/Makefile: patch
sbin/bioctl/Makefile: revision 1.1
sbin/bioctl/bioctl.8: revision 1.1
sbin/bioctl/bioctl.c: revision 1.1
sbin/bioctl/strtonum.c: revision 1.1
sbin/bioctl/strtonum.h: revision 1.1
share/man/man4/Makefile: revision 1.426
share/man/man4/bio.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.139
sys/arch/i386/conf/GENERIC: revision 1.825
sys/arch/i386/conf/XEN2_DOM0: revision 1.25
sys/conf/files: revision 1.839
sys/conf/majors: patch
sys/dev/Makefile: revision 1.25
sys/dev/bio.c: patch
sys/dev/biovar.h: patch
sys/dev/ic/mfi.c: revision 1.4-1.5
sys/dev/ic/mfivar.h: revision 1.4
sys/sys/envsys.h: revision 1.11
usr.sbin/envstat/envstat.c: revision 1.24
Add bio(4) and associated bioctl(8) from OpenBSD, a driver control block
device controllers, and more specifically raid controllers.
Add a new sensor type, ENVSYS_DRIVE, to report drive status. From OpenBSD.
Add bio and sysmon support to mfi(4). This allow userland to query
status for drives and logical volumes attached to a mfi(4) controller. While
there fix some debug printfs in mfi so they compile.
Add bio(4) to amd64 and i386 GENERIC.

note bio(4), envsys(4) DRIVE, and mfi(4) support for both.

tred->sensor is a u_int.
 1.41.2.2 05-Aug-2007  xtraeme The caller of prop_dictionary_externalize is responsible to free the
returned buffer... make it so. Reminded by prop_dictionary(3).
 1.41.2.1 05-Aug-2007  xtraeme file envstat.c was added on branch matt-mips64 on 2007-08-05 23:20:45 +0000
 1.42.2.2 09-Jan-2008  matt sync with HEAD
 1.42.2.1 06-Nov-2007  matt sync with HEAD
 1.60.2.2 04-Jun-2008  yamt sync with head
 1.60.2.1 18-May-2008  yamt sync with head.
 1.65.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.65.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.70.6.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.70.4.1 04-Apr-2009  snj Pull up following revision(s) (requested by christos in ticket #666):
usr.sbin/envstat/envstat.c: revision 1.72
fix pasto: don't print the critcap when the warncap was asked. Also off by
one in length. From Anon-Ymous.
XXX: Should pull up to 5.0
 1.85.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.88.2.3 23-Jan-2013  yamt sync with head
 1.88.2.2 23-May-2012  yamt sync with head.
 1.88.2.1 17-Apr-2012  yamt sync with head
 1.91.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.91.2.1 25-Feb-2013  tls resync with head
 1.94.6.1 10-Aug-2014  tls Rebase.
 1.95.22.1 25-Jun-2018  pgoyette Sync with HEAD
 1.103.2.1 03-Nov-2023  martin Pull up following revision(s) (requested by rin in ticket #450):

usr.sbin/envstat/envstat.c: revision 1.104

Silence wrong maybe-uninitialized raised by GCC/x86_64 10.4.0 -Os.
 1.104.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 14-Nov-2020  mlelstv For raw output (-x) allow to extract individual properties like drvctl -p.
E.g.

# envstat -x /vcmbox0/0/cur-value
328150000
 1.3 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.2 16-Nov-2007  xtraeme Implement the 'refresh-timeout' property in device blocks for the
configuration files. This sets the timeout value that will be used
to check for critical limits.

The value can be viewed by the 'envstat -D' command.
 1.1 07-Oct-2007  xtraeme branches: 1.1.2;
New configuration file format for the envsys framework:

foo0 {
#
# CPU Temperature
#
sensor0 {
critical-max = 70C;
critical-min = 20C;
}
...
}
...

Removed the -m flag that was previously used to set properties for
sensors. Now the -c flag will process all properties specified in
the file (accepted as argument).

To remove all properties that were set, the new -S flag can be used.
This will restore default values for all devices.
 1.1.2.3 09-Jan-2008  matt sync with HEAD
 1.1.2.2 06-Nov-2007  matt sync with HEAD
 1.1.2.1 07-Oct-2007  matt file envstat.h was added on branch matt-armv6 on 2007-11-06 23:36:25 +0000
 1.2 15-Dec-2010  pooka Don't need prog_ioctl here, it's a leftover of the previous approach.

pointed out by Paul Goyette
 1.1 13-Dec-2010  pooka RUMP_ACTION -> RUMPPRG
 1.2 15-Dec-2010  pooka Don't need prog_ioctl here, it's a leftover of the previous approach.

pointed out by Paul Goyette
 1.1 13-Dec-2010  pooka RUMP_ACTION -> RUMPPRG
 1.15 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.14 09-Feb-2012  riz Various English usage, spelling and markup fixes for envstat(4)-related
things, from Snader_LB.
 1.13 15-Feb-2010  pgoyette branches: 1.13.6;
Document the new {high, maximum}-capacity keywords, and some general
clean-up.
 1.12 13-May-2009  wiz New sentence, new line.
 1.11 23-Sep-2008  reed Fix a typo/mispelling.
Spell out minimum and maximum.
 1.10 10-Sep-2008  reed Remove extra space.
Spell out "maximum" and "minimum".
 1.9 31-Aug-2008  wiz Drop trailing whitespace.
 1.8 22-Aug-2008  pgoyette 1. provide for warning-min and warning-max alarm levels in addition to
critical-min and critical-max; also, a battery warning-capacity is
added in addition to a critical-capacity.

2. usr.sbin/envstat is modified to introduce a -W command line switch to
display the warning-* values instead of the critical-* values, and
envstat(8) and envsys.conf(5) man pages are updated appropriately.

3. Treat user-defined limits as a single continuum and generate a single
event regardless of how many boundaries a change in sensor value
crosses; ditto for driver-defined limits.

Fixes my PR/39021
Fixes my PR/39022

OK'd by christos@ bouyer@ cube@
 1.7 26-Apr-2008  xtraeme branches: 1.7.2;
* Improve default display output by adding a header that will match
current value as well as critical limits set and sensor unit.

* Add a new flag: -T. When it's enabled statistics will be created for
the sensors. Max, min and average statistics as well as sensor unit
will be displayed. Must be used with an interval.

You can see the new code in action here:

http://www.netbsd.org/~xtraeme/envstat_stats.txt

Thanks to jmcneill@ for comments and ideas.
 1.6 16-Nov-2007  xtraeme branches: 1.6.6;
Implement the 'refresh-timeout' property in device blocks for the
configuration files. This sets the timeout value that will be used
to check for critical limits.

The value can be viewed by the 'envstat -D' command.
 1.5 25-Oct-2007  wiz branches: 1.5.2;
Various improvements: typo fixes, wording, formatting.
 1.4 09-Oct-2007  xtraeme - Do not allow a 'critical-{max,min}' property in battery
sensors (those that contain the 'want-percentage' object on its
dictionary), the 'critical-capacity' prop must be used instead.

- When setting a 'critical-{max,min}' property check if the value is
higher than the 'max-value' or lower than the 'min-value' on its
dictionary, raise an error if it's true.
 1.3 07-Oct-2007  xtraeme Provide a more complete syntax example.
 1.2 07-Oct-2007  xtraeme Explain some more about the events that will send to powerd(8)
(if running) in the critical-{capacity,max,min} properties when the
limit has been reached.
 1.1 07-Oct-2007  xtraeme New configuration file format for the envsys framework:

foo0 {
#
# CPU Temperature
#
sensor0 {
critical-max = 70C;
critical-min = 20C;
}
...
}
...

Removed the -m flag that was previously used to set properties for
sensors. Now the -c flag will process all properties specified in
the file (accepted as argument).

To remove all properties that were set, the new -S flag can be used.
This will restore default values for all devices.
 1.5.2.3 09-Jan-2008  matt sync with HEAD
 1.5.2.2 06-Nov-2007  matt sync with HEAD
 1.5.2.1 25-Oct-2007  matt file envsys.conf.5 was added on branch matt-armv6 on 2007-11-06 23:36:26 +0000
 1.6.6.1 18-May-2008  yamt sync with head.
 1.7.2.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.7.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.6.1 17-Apr-2012  yamt sync with head
 1.3 07-Jun-2024  rin envstat(8), powerd(8), traceroute(8): Add support to CRUNCHOPS

Now, all rump-fied programs can be built as crunched binaries.

Thanks ozaki-r@ for discussion.
 1.2 15-Dec-2010  pooka branches: 1.2.56;
Don't need prog_ioctl here, it's a leftover of the previous approach.

pointed out by Paul Goyette
 1.1 13-Dec-2010  pooka RUMP_ACTION -> RUMPPRG
 1.2.56.1 20-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #710):

usr.sbin/traceroute/prog_ops.h: revision 1.3
usr.sbin/powerd/prog_ops.h: revision 1.2
usr.sbin/envstat/prog_ops.h: revision 1.3

envstat(8), powerd(8), traceroute(8): Add support to CRUNCHOPS

Now, all rump-fied programs can be built as crunched binaries.

Thanks ozaki-r@ for discussion.

RSS XML Feed