I have decided to include most
of Ian's Howto in this for the sake of completeness.
Most modern mainboards have
sensors to monitor temperature, fan speed, and other items. The sensor
information can normally be seen from the BIOS. This guide shows how to install
lm_sensors which can read the sensor information for you.
Warning:
Running the sensor-detect script can crash your machine, read documentation for
further details.
On my machine there was no problem - but be aware of this possibility.
First you need to install the MRTG
package
[root@e-smith
]# rpm -Uvh
http://sme.swerts-knudsen.dk/downloads/MRTG/mrtg-2.9.17-3.i386.rpm
Then you need to install the LM
Sensor package
[root@e-smith
]# rpm -Uvh
http://sme.swerts-knudsen.dk/downloads/MRTG/lm_sensors-2.6.1-1.i386.rpm
Detect the sensors on your
mainboard, (run as root)
[root@e-smith ]# /usr/sbin/sensors-detect
For
my mainboard, I just hit enter for all questions, which then uses the defaults
which can be seen as CAPs.
Note down the lines
it suggests to put into /etc/modules.conf, for my mainboard
it indicated
#----cut here----
# I2C module options
alias char-major-89 i2c-dev
#----cut here----
Note down the modprobe lines it
suggests, for my mainboard it indicated
#----cut here----
# I2C adapter drivers
modprobe i2c-viapro
modprobe i2c-isa
# I2C chip drivers
modprobe eeprom
modprobe via686a
#----cut here----
Modify /etc/modules.conf via a template fragment. First make the templates-custom directory.
[root@e-smith ]# mkdir -p /etc/e-smith/templates-custom/etc/modules.conf
Create a new template for i2c,
using pico or your favorite editor.
[root@e-smith ]# pico /etc/e-smith/templates-custom/etc/modules.conf/10i2c
Copy the lines from step 3 into
this file, for my mainboard this file contains
{
foreach my $line
(
"alias char-major-89 i2c-dev"
)
{
unless (exists $lines{$line})
{
push @lines, $line;
}
}
"";
}
Now expand the custom template.
[root@e-smith ]# /sbin/e-smith/expand-template /etc/modules.conf
Create a
Initialization file /etc/e-smith/events/local/start_lmsensors,
with permissions 744 root root
This will load the required modules and initialize the sensors whenever your
server boots up. The contents is naturally based on the out of the
"sensors-detect" command issue above.
[root@e-smith
]# pico /etc/e-smith/events/local/start_lmsensors
Now
inserts the correct text and press CTRL-X, Y, to save.
#!/bin/sh
# Boot-up initialization lm_sensors
# I2C adapter drivers
/sbin/modprobe i2c-viapro
/sbin/modprobe i2c-isa
# I2C chip drivers
/sbin/modprobe eeprom
/sbin/modprobe via686a
/usr/bin/sensors -s
Initialize the sensors.
At this point you
can initialize the sensors manually, rather than rebooting.
[root@e-smith
]# chmod 744 /etc/e-smith/events/local/start_lmsensors
[root@e-smith ]# /etc/e-smith/events/local/start_lmsensors
You can now check you sensors by
issuing the sensor command
[root@e-smith
]# sensors
The output from my server is:
w83782d-i2c-0-2d
Adapter: SMBus AMD7X6 adapter at 50e0
Algorithm: Non-I2C SMBus adapter
VCore 1: +1.61 V (min = +1.52 V, max = +1.68 V)
VCore 2: +3.34 V (min = +1.52 V, max = +1.68 V)
+3.3V: +3.36 V (min = +3.13 V, max = +3.45 V)
+5V: +5.11 V (min = +4.72 V, max = +5.24 V)
+12V: +12.20 V (min = +10.79 V, max = +13.19 V)
-12V: -12.13 V (min = -10.90 V, max = -13.21 V)
-5V: -5.07 V (min = -4.76 V, max = -5.26 V)
V5SB: +5.02 V (min = +4.72 V, max = +5.24 V)
VBat: +3.28 V (min = +2.40 V, max = +3.60 V)
fan1: 0 RPM (min = 3000 RPM, div = 2)
fan2: 4141 RPM (min = 3000 RPM, div = 2)
fan3: 0 RPM (min = 750 RPM, div = 8)
temp1: +29.0°C (limit = +60°C, hysteresis = +50°C) sensor = thermistor
temp2: +40°C (limit = +60°C, hysteresis = +50°C) sensor = thermistor
temp3: +128°C (limit = +60°C, hysteresis = +50°C) sensor = PII/Celeron diode
vid: +1.60 V
alarms: Chassis intrusion detection ALARM
beep_enable:
Sound alarm disabled
Now its about time to see some MRTG graphs. I have created a small perl script that provided output the way MRTG wants it. This script is available here. You can test its functionality by simply issuing it from the command line.
[root@e-smith
]# cd /etc/mrtg
[root@e-smith
]# ./mrtg_sensor.pl fan2
I
my case I get an output like:
4141
4141
You
now need to create MRTG config files for your various LM Sensors. First
make sure that the output directory exists. I presume that you have an iBay
called MRTG.
[root@e-smith
]# mkdir -p /home/e-smith/files/ibays/mrtg/html/lm_sensors
[root@e-smith
]# cd /etc/mrtg
[root@e-smith
]# pico
lm_sensors.cfg
Now
inserts the following text (or download from the link above) and press
CTRL-X, Y, to save.
workdir: /home/e-smith/files/ibays/mrtg/html/lm_sensors
#---------------------------------------------------------------
#
# MRTG Configuration file for LM Sensors
# By Jesper Knudsen
#
Target[temp1]: `/etc/mrtg/mrtg_sensor.pl temp1`
MaxBytes[temp1]: 200
Options[temp1]: gauge,nopercent
Title[temp1]: System Temperature
PageTop[temp1]: <H1> System Temperature</H1>
WithPeak[temp1]: dwmy
YLegend[temp1]: Temperature
ShortLegend[temp1]: Celcius
LegendI[temp1]: Temp:
LegendO[temp1]:
Target[temp2]: `/etc/mrtg/scripts/mrtg_sensor.pl temp2`
MaxBytes[temp2]: 200
Options[temp2]: gauge,nopercent
Title[temp2]: System Temperature
PageTop[temp2]: <H1> System 1 Temperature</H1>
WithPeak[temp2]: dwmy
YLegend[temp2]: Temperature
ShortLegend[temp2]: Celcius
LegendI[temp2]: Temp:
LegendO[temp2]:
Target[temp3]: `/etc/mrtg/scripts/mrtg_sensor.pl temp3`
MaxBytes[temp3]: 200
Options[temp3]: gauge,nopercent
Title[temp3]: CPU Temperature
PageTop[temp3]: <H1> CPU Temperature</H1>
WithPeak[temp3]: dwmy
YLegend[temp3]: Temperature
ShortLegend[temp3]: Celcius
LegendI[temp3]: Temp:
LegendO[temp3]:
Target[fan2]: `/etc/mrtg/scripts/mrtg_sensor.pl fan2`
MaxBytes[fan2]: 5000
Options[fan2]: gauge,nopercent
Title[fan2]: System Fan Speed
PageTop[fan2]: <H1> System Fan Speed</H1>
WithPeak[fan2]: dwmy
YLegend[fan2]: RPM
ShortLegend[fan2]: RPM
LegendI[fan2]: Speed:
LegendO[fan2]:
Now we just need to make sure this new
MRTG config file is run every 5 minutes. Inserts a new line in the all-ip
file crated by during the "
How
to Install MRTG system monitoring with SNMP Support" Howto.
[root@e-smith
]# pico
all-ip
Insert
the following line in the bottom and press CTRL-X, Y, to save:
/usr/bin/mrtg /etc/mrtg/lm_sensors.cfg;
Now
wait 5 minutes and then try to look at
http://server.domain.com/mrtg/lm_sensors
An example of MRTG can be seen
here