Hämtat från: http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.htmlOnly generate the graph if the current graph is out of date or not existent. Note, that all the calculations will happen regardless so that the output of PRINT and graphv will be complete regardless. Note that the behavior of lazy in this regard has seen several changes over time. The only thing you can really rely on before RRDtool 1.3.7 is that lazy will not generate the graph when it is already there and up to date, and also that it will output the size of the graph.
Kod: Markera allt
$filnamn = "graph/" . $_GET["rrd"] . time() . ".png";
Kod: Markera allt
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset="utf-8" />
<title><?php echo $_GET["r"] ?> </title>
</head>
<body>
<?php
$filnamn = "graph/" . $_GET["rrd"] . time() . ".png";
// variabler: start title width height rrd Color
create_graph($_GET["t"], $_GET["r"], $_GET["w"], $_GET["h"], $_GET["rrd"], $_GET["c"], $filnamn);
echo "<img src='" . $filnamn . "' alt='Generated RRD image'>";
exit;
function create_graph($start, $title, $width, $height, $rrd, $color, $output) {
$path = "/var/rrddata/temp_"; // Sökvägen till rrd-databasen.
$options = array(
"--slope-mode",
"--start", $start,
"--title=$title",
"--width=$width",
"--height=$height",
"--vertical-label=Temperatur",
"DEF:temp=$path$rrd.rrd:temp_value:AVERAGE",
"LINE1:temp#$color:$rrd",
"GPRINT:temp:LAST:Temperatur %0.2lf\\n",
"GPRINT:temp:MIN:Min\: %0.2lf%s",
"GPRINT:temp:AVERAGE:Medel\: %0.2lf%s",
"GPRINT:temp:MAX:Max\: %0.2lf%s\\n",
"COMMENT:Tid\: $now"
);
$ret = rrd_graph($output, $options, count($options));
if (! $ret) {
echo "<b>Graph error: </b>".rrd_error()."\n";
}
}
?>
</body>
</html>