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:
nano — a text editorgrep — for filtering text in the command linecurl — for sending HTTP requestslm_sensors — for getting CPU and sensor temperaturescron — for automatic task executionphys0 — CPU Temperaturecore0 — Core 0 Temperaturecore1 — Core 1 Temperaturecore2 — Core 2 Temperaturecore3 — Core 3 TemperatureThis data will be needed in the script.
Usually, lm_sensors and curl are already installed, but if not, install them manually.
sudo yum install lm_sensors curl
sudo apt-get install lm-sensors curl
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
For example, to get the temperature of Core 0:
sensors | grep -Eo '^Core 0: +\+[0-9]+\.[0-9]+' | grep -Eo '[0-9]+\.[0-9]+'
Manual request example:
curl --silent "http://VizIoT.com:48656/update?key=_____&pass=_____&core0=23" > /dev/null
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
Open crontab:
crontab -e
Add a job to run the script every minute:
*/1 * * * * /var/viziot.sh
Now the data will be updated automatically.
phys0, core0, core1, core2, core3Now your server automatically sends its processor temperature to VizIoT, where you can: