3
# DigiTemp v2.1 RRDB Temperature Graph (single sensor)
5
# Copyright 1997-2001 by Brian C. Lane <bcl@brianlane.com> www.brianlane.com
8
# This program is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by the Free
10
# Software Foundation; either version 2 of the License, or (at your option)
13
# This program is distributed in the hope that it will be useful, but WITHOUT
14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18
# You should have received a copy of the GNU General Public License along
19
# with this program; if not, write to the Free Software Foundation, Inc.,
20
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25
# CGI (comes with perl5)
30
$cgi = new CGI; # Load the CGI routines
32
# Find the RRD executable, look in the standard locations
33
# If your rrdtool is installed someplace else, fill in the proper location
35
if ( -x "/usr/bin/rrdtool")
37
RRDp::start "/usr/bin/rrdtool";
38
} elsif ( -x "/usr/local/bin/rrdtool") {
39
RRDp::start "/usr/local/bin/rrdtool";
40
} elsif ( -x "/usr/local/rrdtool/bin/rrdtool" ) {
41
RRDp::start "/usr/local/rrdtool/bin/rrdtool";
43
die "Could not find rrdtool binary\n";
46
# The RRD database to get the data from
47
$rrd = "/tmp/digitemp.rrd";
50
# Make the variables easier to use and assign defaults if not set
51
if( !$cgi->param('starttime') )
55
$starttime = $cgi->param('starttime');
57
if( !$cgi->param('endtime') )
61
$endtime = $cgi->param('endtime');
63
if( !$cgi->param('width') )
67
$width = $cgi->param('width');
69
if( !$cgi->param('height') )
73
$height = $cgi->param('height');
75
if( !$cgi->param('label') )
79
$label = $cgi->param('label');
81
$var = $cgi->param('var');
83
if( !$cgi->param('color') )
87
$color = $cgi->param('color');
91
#print STDERR "start = $starttime\n";
92
#print STDERR "end = $endtime\n";
93
#print STDERR "width = $width\n";
94
#print STDERR "height = $height\n";
95
#print STDERR "var = $var\n";
96
#print STDERR "label = $label\n";
97
#print STDERR "color = $color\n";
100
# Output a HTML header for the PNG image to follow
101
print $cgi->header('image/png');
104
RRDp::cmd "graph - --imgformat PNG",
105
"--start '$starttime' --end '$endtime'",
106
"--width $width --height $height",
107
"DEF:temp_c=$rrd:$var:AVERAGE",
108
"CDEF:temp_f=temp_c,9,*,5,/,32,+",
109
"LINE1:temp_f#$color:'$label'";