Monitoring Linux CPU Temperature and Sending Data to VizIoT

In this example, we will set up monitoring for the processor temperature of your server, PC, or mining rig running Linux, and automatically send the data to VizIoT.

This article is suitable for:

  • system administrators;
  • miners;
  • home server owners;
  • anyone who wants to remotely monitor CPU temperature.

What You'll Need

  • A computer with Linux
  • Utilities:
    • nano — a text editor
    • grep — for filtering text in the command line
    • curl — for sending HTTP requests
    • lm_sensors — for getting CPU and sensor temperatures
    • cron — for automatic task execution

Creating the Device in VizIoT

  1. Create a new device named "Test CPU Temperature".
  2. Add parameters (example for a quad-core CPU):
    • phys0 — CPU Temperature
    • core0 — Core 0 Temperature
    • core1 — Core 1 Temperature
    • core2 — Core 2 Temperature
    • core3 — Core 3 Temperature
  3. In "General Settings", copy:
    • Access Key
    • Access Password

This data will be needed in the script.


Installing Required Utilities

Usually, lm_sensors and curl are already installed, but if not, install them manually.

RedHat / CentOS

sudo yum install lm_sensors curl

Debian / Ubuntu / Linux Mint

sudo apt-get install lm-sensors curl

Configuring lm_sensors

After installation, run the automatic configuration:

sudo sensors-detect

You can press Enter for all questions, accepting the default options.

Now, display the temperatures:

sensors

Example output:

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +29.0°C  (high = +80.0°C, crit = +100.0°C)
Core 0:         +23.0°C  
Core 1:         +26.0°C  
Core 2:         +24.0°C  
Core 3:         +24.0°C  

Extracting Temperature via grep

For example, to get the temperature of Core 0:

sensors | grep -Eo '^Core 0: +\+[0-9]+\.[0-9]+' | grep -Eo '[0-9]+\.[0-9]+'

Sending Data to VizIoT

Manual request example:

curl --silent "http://VizIoT.com:48656/update?key=_____&pass=_____&core0=23" > /dev/null

Creating an Automated Script

Open a file:

nano /var/viziot.sh

Paste the content:

#!/bin/bash
key='_____________'
pass='_________________'

phys0=$(sensors | grep -Eo '^Physical id 0: +\+[0-9]+\.[0-9]+' | grep -Eo '[0-9]+\.[0-9]+')
core0=$(sensors | grep -Eo '^Core 0: +\+[0-9]+\.[0-9]+' | grep -Eo '[0-9]+\.[0-9]+')
core1=$(sensors | grep -Eo '^Core 1: +\+[0-9]+\.[0-9]+' | grep -Eo '[0-9]+\.[0-9]+')
core2=$(sensors | grep -Eo '^Core 2: +\+[0-9]+\.[0-9]+' | grep -Eo '[0-9]+\.[0-9]+')
core3=$(sensors | grep -Eo '^Core 3: +\+[0-9]+\.[0-9]+' | grep -Eo '[0-9]+\.[0-9]+')

curl --silent "http://VizIoT.com:48656/update?key=$key&pass=$pass&phys0=$phys0&core0=$core0&core1=$core1&core2=$core2&core3=$core3" > /dev/null

Save the file and make it executable:

chmod +x /var/viziot.sh

Automatic Execution via cron

Open crontab:

crontab -e

Add a job to run the script every minute:

*/1 * * * * /var/viziot.sh

Now the data will be updated automatically.


Adding a Widget in the VizIoT Dashboard

  1. Create a dashboard named "Test Server".
  2. Add a "CPU Temperature" widget:
    • type: "Graph"
    • device: "Test CPU Temperature"
    • parameters: phys0, core0, core1, core2, core3

All Set!

Now your server automatically sends its processor temperature to VizIoT, where you can:

  • observe graphs,
  • build analytics,
  • monitor for overheating,
  • get a history of CPU and core temperatures.