[rrd-users] debian, digitemp, rrdtool

perhansen perhansen79 at gmail.com
Tue Nov 10 06:00:19 CET 2009

Hi All,

I am using rrdtool version 1.4.1 on Debian Lenny.

I'am new to rrdtool and scriptin, so please be gentle with me.

I wrote my script, after looking through several examples on the

My script look like this:


# copyright Per Hansen 2009
# rrd_tempsensor.pl

use lib qw(/opt/rrdtool-1.4.1/lib/perl);
use RRDs;

# sti til rrdtool databases
my $rrd = '/var/lib/rrd';

# sti til færdige grafer
my $img = '/var/www/rrdtool';

# sti til digitemp
my $digi = '/usr/bin'; 

# hvis rrd-database ikke findes, laves den her
	if (! -e "$rrd/temperature.rrd") 
		print "creating rrd database for sensors ...\n";
		RRDs::create "$rrd/temperature.rrd",
		"-s 300",		
  		"RRA:MAX:0.5:288:797" ;
	if ($ERROR = RRDs::error) { print "$0: failed to create temperature
database file: $ERROR\n"; }
	# aflæs den udendørs-sensor
	my $read_out = `$digi/digitemp -t 0 -q -c /etc/digitemp.conf -o%C`;
	# aflæs kælder-sensor
	my $read_in = `$digi/digitemp -t 1 -q -c /etc/digitemp.conf -o%C`;
	# fjerner eol-karaktere i den læste værdi
	# check for fejl i temp-sensorerne
	if (int $read_out eq 85)
		print "failed to read value from outside sensor\n";
		$read_out = "U";
	if (int $read_in eq 85)
		print "failed to read value from basement sensor\n";
		$read_in = "U";
   # indsæt værdier i rrd
	RRDs::update "$rrd/temperature.rrd",
		"-t", "out", 
		"-t", "in", 
	if ($ERROR = RRDs::error) { print "$0: failed to insert data into rrd:
$ERROR\n"; }

my $timestamp = localtime();
	#print"out $read_out";
	#print"in $read_in";  

# generer graf
RRDs::graph "$img/temp-day.png",
"-t Temperaturer i Auning, Danmark °C", 
"-a", "PNG",
"-h", "200", "-w", "600", 
"COMMENT:             MAX            MIN            AVERAGE         
"GPRINT:outside:MAX:%4.2lf °C\t",
"GPRINT:outside:MIN:%4.2lf °C\t",
"GPRINT:outside:AVERAGE:%4.2lf °C\t",
"GPRINT:outside:LAST:%4.2lf °C\\c",
"GPRINT:basement:MAX:%6.2lf °C\t",
"GPRINT:basement:MIN:%6.2lf °C\t",
"GPRINT:basement:AVERAGE:%6.2lf °C\t",
"GPRINT:basement:LAST:%6.2lf °C\\c",
"COMMENT:Copyright Per Hansen\\c";
#"COMMENT:Last update $timestamp\\c";

 if ($ERROR = RRDs::error) { print "$0: unable to generate sensor $_[0]
$_[1] graph: $ERROR\n"; }


My script is currently getting temperatures from digitemp. Digitemp reads
two temperatures, outside and basement.
Eighterway rrdtool should create one graph with both temperatures. But i can
only get one plottet on the graph, no matter what i do. Can someone please
help me and point me in the right direction.


View this message in context: http://n2.nabble.com/debian-digitemp-rrdtool-tp3977831p3977831.html
Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.

More information about the rrd-users mailing list