
Howto monit temperature with Monit/Mmonit (Cómo monitorizar temperatura con Monit/Mmonit)
04/07/2009In this article i will develop a plugin for mmonit for monitoring the CPU temperature and send alerts (emails) if it detects problems. Althought it seems to have a lot of steps, in 3 minutes you can get it up and running:
1º) Install the Linux package temperature.
After this, running «sensors» will show the temperature:
carlos@WhenIGrowUp:~$ sensors
k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp: -49.0°C
Core1 Temp: +56.0°C
M/B Temp: +55.0°C (low = -1.0°C, high = +127.0°C) sensor = thermistor
CPU Temp: +45.0°C (low = -1.0°C, high = +127.0°C) sensor = thermistor
Temp3: -128.0°C (low = -1.0°C, high = +127.0°C) sensor = disabled
2º) Download, check and install this script in your crontab.
This script will check the temperature, write it in the file /tmp/tempFile and, as Monit can’t read content of files, set the permissions as the following:
if temp is OK, /tmp/tempFile permissions will be 700
if it is a warning temp, /tmp/tempFile permissions will be 710
If it is a danger temp, /tmp/tempFile permissions will be 712
Later, Monit will check the permissions of this file, so it will know if the system is in trouble.
Run the script to test it:
carlos@shirley:~/hardware$ ./monit.temperature.sh
Temperature is: 45
Temp OK
Throubleshooting: if you get no result,
carlos@shirley:~/hardware$ ./monit.temperature.sh
edit the script and change CPU with the name of the line with the info (delete «temp3» and write «CPU» i.e) where you can see the temperature runnning «sensors»:
Temperature is:
Temp OK
carlos@shirley:~/hardware$ nano monit.temperature.sh
temp=$(sensors | grep temp3) <-- Replace temp3 with CPU or a string of the output "sensors".
Now, install it in your crontab to be executed every minute:
# crontab -e
* * * * * /home/carlos/monit.temperature.sh
3º) Install and run Monit (not Mmonit, his commercial brother). Monit is GNU. Here you can see a quick guide.
Monit is an utility for monitoring systems (HD, processes, resources, connectivity, networks…), sending alerts and taking actions . Install it:
# sudo apt-get install monit
(or download last version here)
4º) Add these lines to /etc/monit/monitrc
# sudo nano /etc/monit/monitrc
[...]
check file TemperatureOK with path /tmp/tempFile
if failed permission 700 then alert
check file warningTemperature with path /tmp/tempFile
if failed permission 710 then alert
check file dangerTemperature with path /tmp/tempFile
if failed permission 712 then alert
[...]
for checking the correct syntax of Monit’s control file, run:
# sudo monit -tc /etc/monit/monitrc
Control file syntax OK
And restart it
# sudo /etc/init.d/monit restart
5º) Check Monit’s web interface, you will get something like this:
http://172.26.0.1:2812 (default: admin // monit)
Gracias! estaba tratando de hacer algo parecido… asignando lo permisos fue buena idea para resolver las limitaciones de monit.
Hi there,
Any chance of working link for the script from section 2?
Many thanks