[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
internetnet.
My script look like this:
<CODE>
#!/usr/bin/perl
#
# 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",
"DS:out:GAUGE:600:-50:50",
"DS:in:GAUGE:600:-50:50",
"RRA:AVERAGE:0.5:1:600",
"RRA:AVERAGE:0.5:6:700",
"RRA:AVERAGE:0.5:24:775",
"RRA:AVERAGE:0.5:288:797",
"RRA:MIN:0.5:1:600",
"RRA:MIN:0.5:6:700",
"RRA:MIN:0.5:24:775",
"RRA:MIN:0.5:288:797",
"RRA:MAX:0.5:1:600",
"RRA:MAX:0.5:6:700",
"RRA:MAX:0.5:24:775",
"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
chomp($read_out);
chomp($read_in);
# 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",
"N:$read_out";
"-t", "in",
"N:$read_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",
#"--lazy",
"-a", "PNG",
"-h", "200", "-w", "600",
"-E",
"DEF:outside=$rrd/temperature.rrd:out:AVERAGE",
"DEF:basement=$rrd/temperature.rrd:in:AVERAGE",
"COMMENT:\\c",
"COMMENT: MAX MIN AVERAGE
CURRENT\\c",
"LINE2:outside#FF0000:udendørs\\t",
"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",
"LINE2:basement#3333CC:kælder\\t",
"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:\\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"; }
</CODE>
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.
Thanks
--
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