For Linux OS users. raspberrypi_tempmon is a python 3 program Make sure that:
Have been installed on your machine,
Then Install with:
sudo pip3 install rpi_tempmon.py
Program is a python 3 package.
Run in a terminal by typing rpi_tempmon.py or python3 rpi_tempmon.py:
Options list (Note: Options are standalone, not designed to be combined):
|-h||Print help information and exit|
|-v||Print version information and exit|
|-c||Enters continuous mode, optional number of seconds as a argument eg (-c 5)|
|-l||Creates and/or appends to log file at output folder|
|-L||Creates a sub-folder at output folder with date/time stamp and puts a log file in it|
|-m||Sends the log file to an email account|
|-g||graph mode, Generate a menu where 11 types of graphs can be selected|
|-a||parse log file and produces a data report in terminal|
|-n||send notifications to desktop, Number argument to define behaviour|
|-s||CSV mode , parses log.txt and converts it to log.csv, CSV file|
|-ST||Stress test CPU and measures temperature output to graph and csv file , optional number of test runs as a argument eg (-ST 5)|
rpi_tempmon files needed are listed below:
|rpi_tempmon.py||The main python script|
|RpiTempmonWork.py||python module containing various utility functions used by main|
|RpiTempmonGraph.py||python module dealing with graph output by matplotlib|
|$HOME/.config/rpi_tempmon/rpi_tempmon.cfg||config file, user made, NOT installed|
Config file: The user MUST create a config file at path in table above. The config file is NOT installed by setup. A dummy config file is available in documentation folder at repositry , used for -m mail option, GPIO/LED feature and the alarm function.
The setting "RPI_AuthUser" the is email address destination of data from -m option.
Mail_Alert(one: mail alert on with -l option, zero: off)
The other settings are ALARM_MODE which should be set to one or zero(one: alarm on, zero: off)
CPU_UPPERLIMIT is the temperature limit of CPU in Centigrade, should be a positive integer. If alarm mode is on when CPU temperature goes above this limit, the alarm function will activate.
LED_MODE which should be set to one or zero(one: LED mode on, zero: off) if on an GPIO pin will swicth on during an alarm state in continuous and normal mode. The RPI GPIO pin as defined by GPIO_LED number. You can connect an LED or another electronic component to this pin.
Make sure to include the [MAIN] header and all settings just as below or copy from the example file.
MAIL_ALERT = 1
ALARM_MODE = 1
CPU_UPPERLIMIT = 60
LED_MODE = 0
GPIO_LED = 26
Screenshots, example config/log files are also available in documentation.
The output folder for log files is currently fixed at:
$ sudo apt install msmtp msmtp-mta mailutils mpack
$ sudo apt install sysbench.
$ sudo apt install libnotify-bin
matplotlib - Version: 2.2.2 - Python plotting package. matplotlib help The graph modules requires python module matplotlib to draw graphs, This is for -g and -ST options. Installed by rpi_tempmon setup.py during installation in theory, if this fails install with pip.
psutil - Version (2.1.1) - Library for retrieving info on PC. psutil Used to retrieve some CPU and memory information. Installed by setup.py during installation.
RPi.GPIO - version0.6.4) - This package controls the GPIO on a Raspberry Pi. rpi.gpio Should be installed by default on most OS, like Raspibian.
For a raspberry pi the official operating temperature limit is 85°C, and as a result the Raspberry Pi should start to thermally throttle performance around 82°C. The GPU and CPU are closely correlated to within a degree usually.
The program calculates the ARM CPU and GPU temperature of a Raspberry Pi and outputs them in Centigrade together with datetime stamp. Also shows CPU, RAM memory usage .
The program has ten features
1. normal mode
Normal mode is run by running program with no command line arguments. In normal mode output, Data is sent to the terminal with prompt to repeat or quit. The GPIO pin in config file will be turned on and Data in red is displayed in screen for an Alarm state, if setup in config file.
2. Continuous mode
Same as normal mode except in continuous mode. The program enters a delay between scan. This delay is set by positive integer argument placed after -c. For example "-c 30" will wait 30 seconds between scans. Data is sent to terminal screen. The GPIO pin in config file will be turned on and Data in red is displayed in screen for an Alarm state, if setup in config file.
3. & 4. Log modes
In logfile mode the data is appended into a file log.txt at output folder. With optional mail setup if alarm mode setup. For mode 3 an email is sent using mode 5 function, but with warning in title.
Sample output of logfile:
TS = 18-04-22 14:19:42 EP = 1524403183.0 GPU temperature = 48.3'C CPU temperature = 48.3 Cpu usage = 40.4 RAM usage = 45.0 Swap usage = 98.6 Raspberry pi temperature monitor: raspberrypi
The log file is appended with "Warning:" text message if alarm state entered.
In logfolder mode in the output folder, a new sub-folder is created each time it is ran and a new log-file put in here. The sub-folder has following syntax 1250-02Jul17_RPIT HHMM-DDMMMYY_XXXX. This folder mode does not work with mail or graph mode at present.
Logging modes are designed to be used with UNIX automation like crontab. For example this crontab entry will run logfile mode once an hour, Note: The path to executable may differ on each users system.
0 * * * * /usr/local/bin/rpi_tempmon.py -l >/dev/null 2>&1
5. Mail mode
In mail mode an email is sent using msmtp. The mail contains the data from logfile mode only, it will NOT work with sub-folders from logfolder mode.
msmtp is used rather than than python inbuilt smtplib module as this program was originally a bash program and this a legacy of that, also allows access to msmtp config file for greater portability and security. The program originally used ssmtp but this is now obsolete in latest raspbian software.
In order to get mail mode working you must complete 3-4 steps.
6. graph mode
In graph mode, the program using matplotlib (plotting library) creates a plot of various data versus time. The logfile.txt created by logfile mode 3 is used for data for graph 1-8. graphs 1-4 use time-date stamp as yaxis value graphs 5-8 use Unix Epoch stamp as yaxis value, this is better for irregular data points across multiple dates. The graphs 9-11 are live plots sampled every two seconds for 150 points, so five minutes of live data.
Sample graph screenshot, screenshots of all others are in screenshot folder of repo.
7. CSV(comma-separated values) convert
New in Version 2.0. Run with -s on the CLI. Parses log.txt and creates log.csv. This csv file can be then used by user in another app. A comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. This file can then be loaded into libreoffice calc. for further processing, for example.
sample output = time-data, CPU temp, GPU temp, CPU usage , RAM usage , swap usage
8. data mode
Parses log file created by logfile mode 3 and produces a data report on console.
9. notify mode
Send notifications to desktop, Numbered argument to define behaviour
After installing notify-send, Additional packages or steps
may be required to get notify-send working,
depending on system. for example
10. Stress test mode
This mode uses the sysbench benchmarking tool. The test request consists in calculation of prime numbers up to a value of 20000. All calculations are performed using 64-bit integers. 4 worker threads are created. The number of test runs is passed on command line as integer max 50 min 2. CPU temperature and freq are recorded for each test run and are outputed to a csv file, called stresslog.csv . sample output = test run num, CPU temp, CPU usage.
At the end of test, there is an option to display results in a graph.
Stress data carried out by rpi_tempmon for a RPi 3 can be found in repo here