After very long time I had some time to do smth with my raspberry pi.
I always wanted to have small server in home to monitor all of my network devices in home. Raspberry pi is almost ideal for it. However I cannot run Zabbix on it, because Zabbix is not adopted to such small devices. So I decided to use cacti. After digging google I spotted this link:
Cacti Pi
There is nice tutorial how to intall and optimize cacti to run on raspberry pi. I followed it and after about 15 minutes I had full setup of cacti.
However I wanted to monitor my raspberry pi’s temperature. It can be done from CLI:
/opt/vc/bin/vcgencmd measure_temp |
So I’ve writed small script:
#!/usr/bin/perl open(PROCESS, "/opt/vc/bin/vcgencmd measure_temp |"); $avg = <PROCESS>; close(PROCESS); $avg =~ s/^.*=(\d{2}\.\d)'?C?$//; print "$1"; |
Here is some edit:
#!/usr/bin/perl delete @ENV{qw(PATH)}; $ENV{PATH} = "/usr/bin:/bin"; $path = $ENV{'PATH'}; open(PROCESS, "/opt/vc/bin/vcgencmd measure_temp |"); $avg = <PROCESS>; close(PROCESS); $avg =~ s/^.*=(\d{2}\.\d)'?C?$//; print "$1"; |
And put it to:
/var/www/cacti/scripts/temp_rpi.pl |
Of course You need to:
chown pi:users /var/www/cacti/scripts/temp_rpi.pl |
After that create new data input method in cacti:
Then added cacti templates and data sources (files to import to cacti 0.8.8a are attached to this post), but graphs didn’t show. After digging google, I’ve found the problem: www-data user must be added to video and plugdev group.
After that You will have nice graphs of temperature on your raspberry pi:
And that’s all.
Files to import in cacti:
Cacti data template
Cacti graph template