Wednesday, November 29, 2006

temp sensors and mrtg

Temperature monitoring using openbsd's sensor framework and mrtg.

  1. Locate sensors on main board:
    $ dmesg | grep lm
    lm0 at isa0 port 0x290/8: LM79
  2. Locate number of CPU temperature sensor:
    $ sysctl hw.sensors | grep temp
    hw.sensors.7=lm0, Temp1, temp, 36.00 degC / 96.80 degF
  3. Write a simple script for passing temperature to mrtg:
    #!/bin/sh
    sysctl hw.sensors.7 | awk '{ print $4 }'
    sysctl hw.sensors.7 | awk '{ print $4 }'
  4. Add the following lines to your mrtg config:
    Target[Temp1]: `/root/temp.sh`
    MaxBytes[Temp1]: 70
    Options[Temp1]: gauge, noinfo, nopercent
    YLegend[Temp1]: Celsius
    LegendI[Temp1]: Temp
    LegendO[Temp1]: Temp
    Title[Temp1]: CPU temp
    ShortLegend[Temp1]: C
    PageTop[Temp1]: <h1>CPU temp</h1>
  5. Have fun!

No comments: