1 <?
3 dl("/tmp/php3_rrdtool.so");
5 ##
6 ## demonstration of the rrd_fetch() command
7 ##
11 $opts = array ( "AVERAGE", "--start", "-1h" );
13 $ret = rrd_fetch("/dir/router-port2.rrd", $opts, count($opts));
15 ##
16 ## if $ret is an array, rrd_fetch() succeeded
17 ##
18 if ( is_array($ret) )
19 {
20 echo "Start time (epoch): $ret[start]\n";
21 echo "End time (epoch): $ret[end]\n";
22 echo "Step interval (epoch): $ret[step]\n";
24 ##
25 ## names of the DS's (data sources) will be
26 ## contained in the array $ret[ds_namv][..]
27 ##
28 for($i = 0; $i < count($ret[ds_namv]); $i++)
29 {
30 $tmp = $ret[ds_namv][$i];
31 echo "$tmp \n";
32 }
34 ##
35 ## all data will be packed into the
36 ## $ret[data][..] array
37 ##
38 for($i = 0; $i < count($ret[data]); $i++)
39 {
40 $tmp = $ret[data][$i];
41 echo "$hi\n";
42 }
43 }
44 else
45 {
46 $err = rrd_error();
47 echo "fetch() ERROR: $err\n";
48 }
51 ?>