{{Short description|Hardware monitoring sensors framework}} {{lowercase}} {{Use dmy dates |date=April 2019|cs1-dates= yy }} {{Infobox software | name = Environmental Systems framework (version 2) | author = Juan Romero Pardines (2007) | developer = The NetBSD Foundation, Inc. | released = {{Start date and age|2007|07|01|df=yes}} | discontinued = no | repo = {{URL|http://bxr.su/n/sys/sys/envsys.h|/sys/sys/envsys.h}} | programming language = C | operating system = NetBSD since 5.0 | genre = system monitoring | licence = BSD licence#4-clause | website = {{URL|http://mdoc.su/n/envsys.4|envsys(4)}} }} {{Infobox software | name = Environmental Systems API | author = Tim Rightnour and Bill Squier (2000) | developer = The NetBSD Foundation, Inc. | released = {{Start date and age|1999|12|15|df=yes}} | discontinued = yes | latest release version = NetBSD 4.0.1 | latest release date = {{Start date and age|2008|10|14|df=yes}} | repo = {{URL|http://bxr.su/n/sys/sys/envsys.h|/sys/sys/envsys.h}} | programming language = C | operating system = NetBSD 1.5 to 4.0.1 | genre = system monitoring | licence = BSD licence#4-clause | website = {{URL|http://mdoc.su/n40/envsys.4|envsys(4) in NetBSD 4.0}} }} The '''envsys''' framework is a kernel-level hardware monitoring sensors framework in NetBSD. {{As of|2019|03|04}}, the framework is used by close to 85 device drivers to export various environmental monitoring sensors, as evidenced by references of the <code>sysmon_envsys_register</code><ref name=sysmon_envsys_register/> symbol within the <code>sys</code> path of NetBSD; with temperature sensors, <code>ENVSYS_STEMP</code>,<ref name=ENVSYS_STEMP/> being the most likely type to be exported by any given driver.{{r|sensors-mmath|p=32|q=Chart VIII. Sensor unit popularity in NetBSD 5.0.1 based on the number of drivers using each envsys unit.}} Sensors are registered with the kernel through <code>'''sysmon_envsys(9)'''</code> API.{{r|sysmon_envsys.9}} Consumption and monitoring of sensors from the userland is performed with the help of '''<code>envstat</code>''' utility through <code>proplib(3)</code> through <code>ioctl(2)</code> against the '''<code>/dev/sysmon</code>''' pseudo-device file,{{r|/dev/sysmon}} the <code>'''powerd'''</code> power management daemon that responds to kernel events by running scripts from <code>/etc/powerd/scripts/</code>,{{r|powerd|powerd/scripts}} as well as third-party tools like <code>symon</code> and GKrellM from pkgsrc.

== Features ==

The framework allows the user to amend the monitoring limits specified by the driver, and for the driver to perform monitoring of the sensors in kernel space, or even to programme a hardware chip to do the monitoring for the system automatically.{{r|sensors-mmath|p=§7.1}} Two levels of limits are defined: ''critical'' and ''warning'', both of which additionally extend to an ''over'' and an ''under'' categorisation.{{r|sensors-mmath|p=§7.1}} If limit thresholds are crossed, a kernel event may be generated, which can be caught in the userland by <code>powerd</code> to execute a pre-defined user script.{{r|powerd|powerd/scripts}} By comparison, in OpenBSD's hw.sensors, the monitoring of user-defined values is performed in userspace by <code>sensorsd</code>.

{{As of|2019}}, the framework itself does not facilitate computer fan control, although the drivers could still implement interfacing with the fan-controlling capabilities of their chips through other means, for example, through a driver-specific sysctl interface, which is the approach taken by the <code>dbcool(4)</code> driver.{{r|dbcool}} However, the drivers for the most popular Super I/O chips like <code>lm(4)</code> and <code>itesio(4)</code> do not implement any fan control at all (in fact, historically, in all of OpenBSD, NetBSD and DragonFly, these drivers don't even report the duty cycle of the fans — only the actual RPM values are reported).{{r|lm|it}}

== History ==

The framework undergone two major revisions: the first version of <code>envsys.h</code> was committed on {{Start date and age|1999|12|15|df=yes}}; with <code>envsys.4</code> man page following on {{Start date and age|2000|02|27|df=yes}}. Between 2000 and 2007, the manual page for envsys(4) in NetBSD stated that the "API is experimental", and that the "entire API should be replaced by a sysctl(8)", "should one be developed";<ref name="n40/envsys.4"/><ref name=ieee07/> it can be noted that in 2003 this was the exact approach taken by OpenBSD with sysctl hw.sensors when some of the envsys(4) drivers were ported to OpenBSD.{{r|sensors-mmath|p=§6.1|q=6.1. Framework timeline}}

The second revision came about on {{Start date and age|2007|07|01|df=yes}}. The serialisation with userland was reimplemented using property lists with the help of NetBSD's new proplib(3) library (the underlying transport layer between the kernel and userland still being done through ioctl).{{r|feyrer|sensors-mmath}}

The envsys framework was the precursor to OpenBSD's sysctl hw.sensors framework in 2003, and many drivers, as well as some sensor types, have been ported back and forth between NetBSD and OpenBSD. Support for sensors of <code>drive</code> type has been added to NetBSD on {{dts|2007|05|01|format=dmy}}, similar to <code>drive</code> type in OpenBSD, which was at the same time when bio(4) and bioctl were ported from OpenBSD to NetBSD.{{r|sensors-mmath|p=§7.1|q=7.1. NetBSD envsys / sysmon}}

== See also == {{Portal|Free and open-source software}} * bioctl * hw.sensors * lm_sensors * SpeedFan

== References == {{Reflist |refs=

<ref name="/dev/sysmon">{{cite web |url= http://bxr.su/n/include/paths.h#_PATH_SYSMON |title= _PATH_SYSMON in paths.h |website=BSD Cross Reference |publisher=NetBSD |quote= <code>#define _PATH_SYSMON "/dev/sysmon"</code> }}</ref>

<ref name=sysmon_envsys_register>{{cite web |url=http://bxr.su/n/sys/dev/sysmon/sysmon_envsys.c#sysmon_envsys_register |title=<code>sysmon_envsys_register()</code> |website=BSD Cross Reference |publisher=NetBSD }}</ref>

<ref name=sysmon_envsys.9>{{cite web |author2= The NetBSD Foundation, Inc. |author2-link= NetBSD |author1= Juan Romero Pardines |date= 2007–2008 |url=http://bxr.su/n/share/man/man9/sysmon_envsys.9 |title=sysmon_envsys(9) — kernel part of the envsys 2 framework |website=BSD Cross Reference |publisher=NetBSD }}</ref>

<ref name=powerd>{{cite web |author= Wasabi Systems, Inc. |date= 2003 |url=http://bxr.su/n/usr.sbin/powerd/ |title=powerd(8) — power management daemon for sysmon |website=BSD Cross Reference |publisher=NetBSD }}</ref>

<ref name="powerd/scripts">{{cite web |url=http://bxr.su/n/etc/powerd/scripts/ |title=/etc/powerd/scripts/ |website=BSD Cross Reference |publisher=NetBSD }}</ref>

<ref name=ENVSYS_STEMP>{{cite web |url=http://bxr.su/n/sys/sys/envsys.h#ENVSYS_STEMP |title=<code>ENVSYS_STEMP</code> |website=BSD Cross Reference |publisher=NetBSD }}</ref>

<ref name="n40/envsys.4">{{cite web |url=http://mdoc.su/n40/envsys.4 |author1=Tim Rightnour |author2=Bill Squier |version = NetBSD 4.0 |date = 2007-12-19 |title= envsys -- Environmental Systems API |quote= This API is experimental and may be deprecated at any time ... This entire API should be replaced by a sysctl(8) interface or a kernel events mechanism, should one be developed. }}</ref>

<!-- drivers: -->

<ref name=dbcool>{{cite web |author2= The NetBSD Foundation, Inc. |author1= Paul Goyette |date= 2008 |url= http://bxr.su/n/sys/dev/i2c/dbcool.c |title= dbcool(4): dev/i2c/dbcool.c |website= BSD Cross Reference |publisher= NetBSD |access-date= 2019-03-25 }}</ref>

<ref name=lm>{{cite web |url= http://bxr.su/n/sys/dev/ic/nslm7x.c |title= lm(4): dev/ic/nslm7x.c |website= BSD Cross Reference |publisher= NetBSD |access-date= 2019-03-25 }}</ref>

<ref name=it>{{cite web |url= http://bxr.su/n/sys/dev/isa/itesio_isa.c |title= itesio(4): dev/isa/itesio_isa.c |website= BSD Cross Reference |publisher= NetBSD |access-date= 2019-03-25 }}</ref>

<!-- / drivers -->

<ref name=ieee07>{{Cite conference |author= Constantine A. Murenin |date= 2007-04-17 |section = 3.5. NetBSD's sysmon(4) |url = http://sensors.cnst.su/IEEE_ICNSC_2007 |title= Generalised Interfacing with Microprocessor System Hardware Monitors |conference= Proceedings of 2007 IEEE International Conference on Networking, Sensing and Control, 15–17 April 2007. |location= London, United Kingdom |publisher=IEEE |pages = 901–906 |doi = 10.1109/ICNSC.2007.372901 |isbn = 978-1-4244-1076-7 |id = IEEE ICNSC 2007, pp. 901—906. }}</ref>

<ref name=feyrer>{{cite web |url = http://www.feyrer.de/NetBSD/bx/blosxom.cgi/nb_20070621_1638.html |title = envsys2 |author = Hubert Feyrer |date = 2007-06-21 |access-date = 2019-03-04 }}</ref>

<ref name=sensors-mmath>{{cite thesis |degree= MMath |author= Constantine A. Murenin |date= 2010-05-21 |section = 7.1. NetBSD envsys / sysmon |title= OpenBSD Hardware Sensors — Environmental Monitoring and Fan Control. |location= University of Waterloo |publisher= UWSpace |url = http://cnst.su/MMathCS |hdl = 10012/5234 |id = Document ID: ab71498b6b1a60ff817b29d56997a418. }}</ref>

}}

== External links == * {{URL|http://bxr.su/n/sys/sys/envsys.h|/sys/sys/envsys.h}}

{{NetBSD}}

Category:1999 software Category:2007 software Category:BSD software Category:Computer hardware tuning Category:Computer performance Category:Environmental data Category:Environmental monitoring Category:Free software programmed in C Category:Free system software Category:Motherboard Category:NetBSD Category:System administration Category:System monitors Category:Software using the BSD license