Hans on IoT

ThingSpeak, MATLAB, and the Internet of Things

[Official Tutorial] Monitoring Linux Server Statistics

ThingSpeak can be used to easily monitor CPU usage %, memory usage %, and disk usage % on any Linux machine connected to the internet.

First, create a new Channel, and fill out the field names as follows: Field 1 = “CPU Usage (%)”, Field2 = “Memory Usage (%)”, Field 3 = “Disk Usage (%)”.

ThingSpeak Channel Settings

Next, add the open-source server statistics script to your server, which can be found at: https://raw.githubusercontent.com/iobridge/thingspeak/master/lib/server_stats.sh

Inside the script there’s an API Key variable, which should be replaced with your specific Channel’s API Key (leave the single quotes, and only replace the X’s): api_key='XXXXXXXXXXXXXXXX'

For the script to work properly, install the “bc” package via: sudo apt-get install bc

Then make the script executable: chmod +x server_stats.sh

Finally, edit your crontab file: crontab -e

Make the script execute every minute by adding this line to your crontab (make sure you use the proper path to the script): * * * * * /path/to/server_stats.sh

The script will then automatically POST server stats to the Channel specified by the API Key every minute.

You can see some of the ThingSpeak server statistics here:

 

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.