Code

make sure gcc-4.0 does not optimize our tests away :-)
[rrdtool-all.git] / contrib / php3 / examples / rrd_graph.php
1 <?
3  dl("/tmp/php3_rrdtool.so");
5  ##
6  ## demonstration of the rrd_graph() command
7  ##
9    $opts = array( "--start", "-4d", 
10                   "DEF:in=/dir/router-port2.rrd:input:AVERAGE",
11                   "DEF:out=/dir/router-port2.rrd:output:AVERAGE",
12                   "LINE2:in#0000ff:Incoming Traffic Avg.",
13                   "PRINT:in:AVERAGE:incoming\: %1.2lf b/s",
14                   "PRINT:in:AVERAGE:incoming2\: %1.2lf b/s"
15                 );
18    $ret = rrd_graph("/some-dir/router-port2.gif", $opts, count($opts));
20    ##
21    ## if $ret is an array, then rrd_graph was successful
22    ##
23    if ( is_array($ret) )
24    {
25        echo "Image size:  $ret[xsize] x $ret[ysize]\n";
26        
28        ##
29        ## all results from any PRINT commands will be
30        ## in the array $ret[calcpr][..]
31        ##
32        echo "rrd_graph1 print results: \n";
34        for ($i = 0; $i < count($ret[calcpr]); $i++)
35            echo $ret[calcpr][$i] . "\n";
36    }
37    else
38    {
39        $err = rrd_error();
40        echo "rrd_graph() ERROR: $err\n";
41    }
43 ?>