Monitoring temperature of a Raspberry Pi with Cacti and perl

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
lulu62
Posts: 1
Joined: Sun Mar 06, 2016 10:22 am

Monitoring temperature of a Raspberry Pi with Cacti and perl

Post by lulu62 »

Hello All,

My Pi2 is running Raspbian and I've installed Cacti 0.8.8b with apt-get.
Cacti works well with the default graphs and some others I've added later on (I'm monitoring my Ubiquiti EdgeRouter).
Now I'm trying to monitor the Pi's temperature with the following perl script:

Code: Select all

#!/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";
I found the script here: http://sq4ind.eu/cacti-template-to-moni ... ment-22154

I followed the installation steps very carefully but I'm still not able to get the temperature data in the graph.
When I run the perl script,

Code: Select all

sudo perl temp_rpi.pl
I get a good temperature value in return however when the cacti poller does it, it returns an error:

Code: Select all

CMDPHP: Poller[0] Host[1] DS[8] WARNING: Result from CMD not valid. Partial Result: U
If I change the last line of the script:

Code: Select all

print “$1”;
to

Code: Select all

print “40”;
It works, the temperature data is inserted in the graph.

What should I do?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests