File: rrd_graph.php

package info (click to toggle)
php4-rrdtool 1.04-11
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,168 kB
  • ctags: 85
  • sloc: sh: 9,365; ansic: 356; php: 102; makefile: 72; awk: 43
file content (47 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?

 ## the following line is only needed if built as a self-contained
 ## extension.  If you build the rrdtool module as an embedded
 ## extension, the rrd_* functions will always be available, so you
 ## do not need the dl() call.
 dl("rrdtool.so");

 ##
 ## demonstration of the rrd_graph() command
 ##

   $opts = array( "--start", "-4d", 
                  "DEF:in=/dir/router-port2.rrd:input:AVERAGE",
                  "DEF:out=/dir/router-port2.rrd:output:AVERAGE",
                  "LINE2:in#0000ff:Incoming Traffic Avg.",
                  "PRINT:in:AVERAGE:incoming\: %1.2lf b/s",
                  "PRINT:in:AVERAGE:incoming2\: %1.2lf b/s"
                );


   $ret = rrd_graph("/some-dir/router-port2.gif", $opts, count($opts));

   ##
   ## if $ret is an array, then rrd_graph was successful
   ##
   if ( is_array($ret) )
   {
       echo "Image size:  $ret[xsize] x $ret[ysize]\n";
       

       ##
       ## all results from any PRINT commands will be
       ## in the array $ret[calcpr][..]
       ##
       echo "rrd_graph1 print results: \n";

       for ($i = 0; $i < count($ret[calcpr]); $i++)
           echo $ret[calcpr][$i] . "\n";
   }
   else
   {
       $err = rrd_error();
       echo "rrd_graph() ERROR: $err\n";
   }

?>