Raspberry Pi monitor: Difference between revisions
mNo edit summary |
m order |
||
| Line 271: | Line 271: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= Make it work with Apache | = Make it work with Apache webserver = | ||
Some tips (nginx | Some tips (assuming you to use nginx webserver): | ||
* https://xavierberger.github.io/RPi-Monitor-docs/35_external.html | * https://xavierberger.github.io/RPi-Monitor-docs/35_external.html | ||
Configure | Configure Apache2 webserver, port 80 virtual directory: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
| Line 289: | Line 289: | ||
</VirtualHost> | </VirtualHost> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Disable the built-in webserver: | Disable the built-in webserver: | ||
| Line 317: | Line 308: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
sudo systemctl restart apache2 | |||
sudo service rpimonitor restart | sudo service rpimonitor restart | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Go to: | |||
* http://<yourserver>/rpimonitor | |||
Revision as of 20:38, 29 October 2018
Links
With RPi-Monitor you can monitor various aspects of your Raspberry Pi. The package has its own simple webserver. It works well for smaller screens (mobile phone) and history can be visualized with some graphs. If it still isn't to your liking it allows for some serious tinkering.
- http://rpi-experiences.blogspot.nl/p/rpi-monitor-installation.html
- https://github.com/XavierBerger/RPi-Monitor
Local webservice, access within the local network with:
Install
echo "deb http://www.giteduberger.fr rpimonitor/" | sudo tee /etc/apt/sources.list.d/rpimonitor.list sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2C0D3C0F sudo apt-get update sudo apt-get install rpimonitor
Remove
Repository:
sudo rm /etc/apt/sources.list.d/rpimonitor.list sudo apt-key del 2C0D3C0F
Monitor package:
sudo apt-get purge rpimonitor rm -fr /etc/rpimonitor rm -fr /usr/share/rpimonitor
Configure
Documentation
man rpimonitord man rpimonitord.conf rpimonitord -i
Main configuration files
Main configuration-file with possible references to the other templates:
sudo nano /etc/rpimonitor/template/raspbian.conf
Configuration of the daemon:
sudo nano /etc/rpimonitor/daemon.conf
Modify interval
Default is 10 seconds, changed it to 150 seconds (2.5min).
sudo nano -l +17 /etc/rpimonitor/daemon.conf
daemon.delay=150
sudo systemctl restart rpimonitor
Network monitoring
Uncomment all lines that are commented and comment the lines that contain the configuration message.
sudo nano /etc/rpimonitor/template/network.conf
Update upgradables
After you upgrade your system:
sudo apt upgrade
The upgradable packages keep being listed, this is only refreshed once a day. You can do this manually with:
sudo /etc/init.d/rpimonitor update
Backup modified files
zip ~/rpi-monitor-files.zip /etc/rpimonitor/daemon.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/raspbian.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/services.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/version.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/uptime.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/cpu.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/temperature.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/memory.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/swap.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/sdcard.conf zip ~/rpi-monitor-files.zip /etc/rpimonitor/template/network.conf zip ~/rpi-monitor-files.zip /usr/share/rpimonitor/web/js/rpimonitor.statistics.js
Tweaking
Edit services.conf to check for running apache webservice
sudo nano /etc/rpimonitor/template/services.conf
dynamic.3.name=http dynamic.3.source=systemctl show -p SubState --value apache2 dynamic.3.regexp=(.*) web.status.1.content.1.line.1= Label(data.http,"=='running'","Apache","success") + Label(data.http,"!='running'","apache","danger")
Edit cpu.conf to include CPU throttling
(Rapberry Pi 3)
sudo nano /etc/rpimonitor/template/cpu.conf
dynamic.1.source=/proc/uptime dynamic.1.regexp=(^\S+) dynamic.1.name=cpu_frequency dynamic.1.source=vcgencmd measure_clock arm | sed -e "s/frequency(45)=//g" dynamic.1.postprocess=$1/1000000 dynamic.1.rrd=
Link from the main page directly to the corresponding graph
- Included in new version v2.13+
Modify the function Start() in "rpimonitor.statistics.js" to read a parameter 'graph':
sudo nano -l +26 /usr/share/rpimonitor/web/js/rpimonitor.statistics.js
// ...
function Start() {
static = getData('static')
graphconf = getData('statistics')
//modified: read activestat from url graph parameter
activestat = GetURLParameter('graph');
if (activestat == null){
activestat = localStorage.getItem('activestat') || 0;
}
// ... unchanged ...
activePage = GetURLParameter('activePage');
// ...
}
// ...
Then modify "uptime.conf" (graph=0) to include a link to the graph. Same for for "cpu.conf" (graph=1), "temperature.conf" (graph=2), etc:
sudo nano /etc/rpimonitor/template/uptime.conf
web.status.1.content.1.name=<a target=_blank href=statistics.html?graph=0>Uptime</a>
RPi Built-in Webserver problem
The Web-server seems to stop regularly. In the Perl code (rpimonitord) there is a "Check if the server is up" part in "Monitor->Run". This is called once every "daemon.delay". With a higher daemon.delay the problem is quite annoying. I changed the code to break-up the delay in 10s parts and check the server every 10s. The problem will still be there but now I only need to wait 10 sec.
sudo nano -l +676 /usr/bin/rpimonitord
My changes:
...
for(;;)
{
...
# tempo before next process
## exit the 'for' loop if the delay-option is not set
$configuration->{'daemon'}->{'delay'} or last;
## disabled the full delay
#sleep $configuration->{'daemon'}->{'delay'};
my $keeplooping = 1;
my $waited = 0;
while($waited < $configuration->{'daemon'}->{'delay'}) {
## sleep in 10 second parts
sleep 10;
$waited = $waited + 10;
## skip if noserver-option is set
if ( !$configuration->{'daemon'}->{'noserver'}) {
## kill will return 'true' if the process is running, it doesn't kill anything
$keeplooping = kill(0,$serverpid);
$this->Debug(2,"Check server active $keeplooping");
## exit the 'while' loop if $keeplooping is 'false'
$keeplooping or last;
}
}
## exit the 'for' loop if $keeplooping is 'false', this will restart the Web-server process
$keeplooping or last;
}
...
The StartServer-code is around line 1335:
sudo nano -l +1335 /usr/bin/rpimonitord
Start RPi-Monitor in a terminal with logging:
sudo systemctl stop rpimonitor sudo rpimonitord -vvvvvv
Make it work with Apache webserver
Some tips (assuming you to use nginx webserver):
Configure Apache2 webserver, port 80 virtual directory:
sudo nano /etc/apache2/sites-available/raspberrypi.conf <VirtualHost _default_:80> Alias /rpimonitor/ /usr/share/rpimonitor/web/ <Directory /usr/share/rpimonitor/web/> AllowOverride None Require all granted </Directory> </VirtualHost>
Disable the built-in webserver:
sudo nano /etc/rpimonitor/daemon.conf daemon.noserver=1
Problem: the rdd files can't be found by apache. We add a symbolic link to point to the right place:
cd /usr/share/rpimonitor/web sudo ln -s /var/lib/rpimonitor/stat stat
Restart:
sudo systemctl restart apache2 sudo service rpimonitor restart
Go to:
- http://<yourserver>/rpimonitor