Wednesday, May 26, 2010

Sensorsd config for OpenBSD ( sensorsd.conf )

Sensord is a daemon which watches the "sysctl" values for specified directives and can execute a job if specified values are exceeded. Normally sensorsd is used to watch a systems temperature and voltages being reported by a compatible motherboard chipset.

Getting Started

The first thing you need to do is see if the chipset on the motherboard you are using is supported by OpenBSD. Execute "sysctl hw.sensors" and you should see something similar to this output. What we are looking for are the volt, temp and fan lines.
# sysctl hw.sensors

  hw.sensors.lm0.temp0=26.00 degC
  hw.sensors.lm0.temp1=31.00 degC
  hw.sensors.lm0.fan1=1607 RPM
  hw.sensors.lm0.fan2=1308 RPM
  hw.sensors.lm0.volt0=1.10 VDC (VCore)
  hw.sensors.lm0.volt1=11.31 VDC (+12V)
  hw.sensors.lm0.volt2=3.23 VDC (+3.3V)
  hw.sensors.lm0.volt3=4.85 VDC (+5V)
  hw.sensors.lm0.volt4=6.07 VDC (-12V)
  hw.sensors.lm0.volt5=5.12 VDC (5VSB)
  hw.sensors.lm0.volt6=0.58 VDC (VBAT)


Verify the output

If your output is similar, though it might not look exactly the same, then you have a compatible chip set and you can use sensorsd. If you did not get any output then check to make sure you typed in the commands correctly. If the command was correct then check at the bottom of this page for any help.


Checking the devices

Next, you need to make sure the sensors listed from the sysctl command correspond to the correct device. The voltages are easy as they have a label on them. The temps and fans are a little harder. As a rule, the CPU temp will be higher then the chip set temp. The fans will normally be listed with the CPU fan being first and the power supply fan second. These are not rules, but a guide to go by.
Once you have identified the correct hw.sensors.lm0 line with the correct device then it is time to make sure the sensorsd.conf reflects the correct settings. On some mother boards the devices will be in a different order than shown in the example above. For example, in the example above the +3.3V sensor corresponds to sensor "hw.sensors.lm0.volt2" but on your motherboard the +3.3V might be linked to "hw.sensors.lm0.volt4". Just take a moment to compare your "sysctl hw.sensors" with the sensorsd.conf file below.
The follwoing config will monitor:
1. Voltages on the 3.3V, 5V and 12V busses.

2. Tempatures from the motherboard chipset and the CPU.

3. Fan speeds of the CPU and power supply.



If any of these values are exceeded mail will be sent to root with the result as well as the preset high and low limits.


#######################################################
###  Calomel.org  sensord.conf  BEGIN
#######################################################

# +3.3 voltage (volts)
hw.sensors.lm0.volt2=low=3.0V:high=4.0V:command=echo "%2 \( low=%3 high=%4 \)" \
   | mail -s "`hostname` sensorsd WARNING \(+3.3V\)" root

# +5 voltage (volts)
hw.sensors.lm0.volt3:low=4.79V:high=5.2V:command=echo "%2 \( low=%3 high=%4 \)" \
   | mail -s "`hostname` sensorsd WARNING \(+5V\)" root

# +12 voltage (volts)
hw.sensors.lm0.volt1:low=11.2V:high=12.5V:command=echo "%2 \( low=%3 high=%4 \)" \
   | mail -s "`hostname` sensorsd WARNING \(+12V\)" root

# Chipset temperature (degrees Celsius)
hw.sensors.lm0.temp0:high=29C:command=echo "%2 \( high=%4 \)" \
   | mail -s "`hostname` sensorsd WARNING \(chipset temp\)" root

# CPU temperature (degrees Celsius)
hw.sensors.lm0.temp1:high=36C:command=echo "%2 \( high=%4 \)" \
   | mail -s "`hostname` sensorsd WARNING \(cpu temp\)" root

# CPU fan (RPM)
hw.sensors.lm0.fan1:low=1000:high=3000:command=echo "%2 \( low=%3 high=%4 \)" \
   | mail -s "`hostname` sensorsd WARNING \(cpu fan\)" root

# Power Supply fan (RPM)
hw.sensors.lm0.fan2:low=1000:high=3000:command=echo "%2 \( low=%3 high=%4 \)" \
   | mail -s "`hostname` sensorsd WARNING \(psu fan\)" root

#######################################################
###  Calomel.org  sensord.conf  END
#######################################################






Executing the daemon

With the sensorsd.conf file in place and all of the sensors verified we can now test out the sensorsd daemon. You can start the daemon manually by typing "/usr/sbin/sensorsd". You should see a few emails from sensorsd reporting a change. No worries.
Lastly, we need to make sure sensorsd will start on the next reboot. You can edit the /etc/rc.conf file directly and change the line sensorsd_flags=NO to sensorsd_flags="" . Or you can edit the /etc/rc.conf.local file and add the line sensorsd_flags="" and this will also start the daemon on boot.

NUT (Network UPS Tools) will monitor your UPS (uninteruptable power supply) and can send you mail or log power events. For more information about OpenBSD's install of NUT check out our NUT UPS monitor on OpenBSD "how to".

No comments: