Monit: Processor or CPU temperature monitoring

CPU temperature monitoring with Monit allows you to keep a check on your server for adequate cooling, especially on a passively cooled system. Monit is an automatic monitoring, maintenance, and repair utility for Unix systems. If the Processor 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 CPU temperature with Monit on your home server. By CPU temperature monitoring I mean the processor temperature as detected by the sensors in your motherboard and not the core temperatures reported by some CPUs. 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.

Now, how to check CPU temperature?If you complete the detection process successfully, you can verify if lm-sensors is working correctly using the following command:


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

Cpu 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 CPU 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 CPU Temperature Monitoring Scripts

Before, we can monitor processor temperature with Monit, we will need to create a script that will check CPU 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 processor temperature monitoring script:

sudo nano /etc/monit/scripts/

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

CPUT=`sensors | egrep SYSTIN | cut -c18-19`
#echo $CPUT
exit $CPUT

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

sudo chmod 755 /etc/monit/scripts/

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

$ sudo ./etc/monit/scripts/

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

Processor 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 CPU temperature monitoring with Monit, create a Monit configuration file using the following command.

sudo /etc/monit/conf.d/cputemp

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

# set the trigger temperature
check program AMD-Temp with path "/etc/monit/scripts/"
    if status > 45 then alert

This code will help monitor CPU temperature with Monit. You may change the word AMD-Temp to CPU-Temp or something else. If the cooling is not adequate or if one of the fan fails and the CPU 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 rating for my AMD 5350 processor and the average temperature using the sensors command and added 10 C to it to set the target of 45 degree C. This is well below its maximum temperature rating of 90 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)
  • (if you have domain name pointing to your server)

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

Monitor Cpu Temperature With Monit
Monit Processor Temperature Monitoring

That is it for CPU 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.

Did this post help you?
SmartHomeBeginner brings in-depth tutorials easy enough to understand even for beginners. If you are reading this, please consider buying us a coffee (or two) as a token of appreciation.


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.