[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 (%)”.
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:
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.