Monit: Motherboard temperature monitoring

Motherboard temperature monitoring with Monit allows you to keep a check on your server for adequate cooling. Monit is an automatic monitoring, maintenance, and repair utility for Unix systems. If the motherboard temperature is high Monit will send you an email alert. You can then examine and resolve any issues. In this Monit tutorial, I will show you how to monitor motherboard temperature with Monit on your home server. By Motherboard temperature monitoring I mean the temperature as detected by the sensors in your motherboard. I am assuming that you have already installed and configured Monit following my previous guide.

Monitor your home server with Monit:

Install lm-sensors to Detect Temperature

First, you need a software called lm-sensors installed on your system. lm-sensors detects the components in your system and loads the right pieces of code to monitor various temperatures: motherboard temperature, CPU temperature, auxiliary temperature, fan speed, voltages, PCI adapter temperature, and more. Use the following command to install lm-sensors.

sudo apt-get install lm-sensors

Once lm-sensors is installed you will have to go through some diagnostics to detect your hardware. Run the following command:

sudo sensors-detect

You will be asked to say "yes" to go through various stages of detection. There are several warnings along the way. Be sure to read them before proceeding. In my case, I said "yes" to all steps and completed the sensor detection process without any issues. Also note that not all motherboards and processors are compatible with such monitoring software. You need a working lm-sensors instance for Monit system temperature monitoring.

If you complete the detection process successfully, you can verify if lm-sensors is working correctly using the following command:

sensors

You should see an output like the one in the picture below.

Motherboard Temperature Monitoring With Monit
Lm-Sensors Temperature, Fan Speed, And Voltage Output

At the time of taking this screenshot my AMD CPU was at 35 degree C (CPUTIN) and ASROCK motherboard was at 31 degree C (SYSTIN). I have not been able to figure out what AUXTIN measures. In this guide we are only going to monitor Motherboard temperature with Monit. If you see an output as above with temperature readings listed, then you are good to proceed and configure Monit.

Create Monit Motherboard Temperature Monitoring Scripts

Before, we can monitor motherboard temperature with Monit, we will need to create a script that will check Motherboard temperature and reports it to Monit. If it does not exist already, create a folder called "scripts" inside /etc/monit using the command below:

sudo mkdir /etc/monit/scripts

Next, create a new motherboard temperature monitoring script:

sudo nano /etc/monit/scripts/mbtemp.sh

Copy the following contents to it, save, and exit (press Ctrl X, press Y, and press ENTER).

#!/bin/sh
MBT=`sensors | egrep SYSTIN | cut -c18-19`
#echo $MBT
exit $MBT

Next, give execute privileges to the script using the following command:

sudo chmod 755 /etc/monit/scripts/mbtemp.sh

Finally, verify that the script works and outputs the motherboard temperature. To do this, temporarily remove the # in front of line 3, save, exit, and run the command below. Motherboard temperature should appear in the next line as shown below:

$ sudo ./etc/monit/scripts/mbtemp.sh
31

If you see the temperature printed then you are good to go. Reopen the /etc/monit/scripts/mbtemp.sh, add the # in front of line 3 and make it look like the code block above, save, and exit.

Motherboard Temperature Monitoring with Monit

Next, it is required that you have a working Monit instance with a proper /etc/monit/monitrc file. Monit configurations for various services are loaded from /etc/monit/conf.d folder. For motherboard temperature monitoring with Monit, create a Monit configuration file using the following command.

sudo /etc/monit/conf.d/mbtemp

Copy the following contents to it, save, and exit (press Ctrl X, press Y, and press ENTER).

# set the trigger temperature
check program MB-Temp with path "/etc/monit/scripts/mbtemp.sh"
    if status > 42 then alert

This code will help monitor motherboard temperature with Monit. If the cooling is not adequate or if one of the fan fails and the motherboard heats up Monit will send you and email alert. An example of Monit alert is shown below.

Monit System Monitoring Email Alert
Monit System Monitoring Email Alert

I looked at the average temperature of my Motherboard using the sensors command and added 10 C to it to set the target of 42 degree C. My HTPC-NAS Combo setup does not generate much heat. Don't be alarmed if your temperature is much higher than the numbers listed here.

Test and Reload Monit

Once you make any changes you have to test Monit configuration:

sudo monit -t

You should see the following message: Control File Syntax OK. Then, check to see if Monit is already running using the following command:

sudo /etc/init.d/monit status

If Monit is running, reload Monit configurations using the following command:

sudo /etc/init.d/monit reload

If Monit is not running, then start it using sudo monit command instead. The whole sequence of commands for testing and reloading Monit is shown in the picture below.

Monit Test And Reload
Monit Test And Reload

Now, fire up your web browser and visit one of the following URLs depending on how your Monit is configured (be sure to use the correct port number):

  • http://localhost:2812
  • http://IPADDRESS:2812 (local network IP)
  • http://domain.com:2812 (if you have domain name pointing to your server)

You should see the motherboard temperature listed in your Monit WebUI as shown in the picture below (see MB-Temp).

Monitor Motherboard Temperature With Monit
Monit Motherboard Temperature Monitoring

That is it for Motherboard temperature monitoring with Monit. As you can see Monit allows for automatic system temperature monitoring, which can be a big help for administrators. Monit Wiki page has several examples. More home server specific Monit examples to follow, so keep checking back.

Be the 1 in 200,000. Help us sustain what we do.
120 / 150 by Dec 31, 2024
Join Us (starting from just $1.67/month)

Anand

Anand is a self-learned computer enthusiast, hopeless tinkerer (if it ain't broke, fix it), a part-time blogger, and a Scientist during the day. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs.

Try Deployarr