File: USAGE

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 (166 lines) | stat: -rw-r--r-- 6,118 bytes parent folder | download
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
$Id: USAGE,v 1.1 2000/07/19 17:23:14 joeym Exp $

--------------------------------------------------
Usage:

	Loading the rrdtool module is a little bit different with
PHP4/Zend.  If you build the rrdtool module into PHP4 at compile
time (see INSTALL file), then there is nothing you need to do
in your scripts to use the rrd_* functions. 



	However, if you build the rrdtool module as a 'self-contained'
module (see INSTALL file), you will need to load it for each
php script you intend to use.  To do this, you will need a line 
such as this in your script:

	<? dl("rrdtool.so"); ?>

Note that in PHP4/Zend, you cannot specify the directory where
the module lives.  It restricts the search to a specifc directory
which is defined at compile time.  'make install' will place
this file in the appropriate location.



API:

--------------------------------------------------------------------
string rrd_error()

	rrd_error takes no arguments.

	Use this function to retrieve the error message from
the last rrd_* function that was called and failed.

	If an error was set, a string will be returned.  

	If no error was set, a blank string will be returned.




--------------------------------------------------------------------
int rrd_last(string filename)

	rrd_last takes only one argument, a filename of an RRD
file.  

	If rrd_last is successful in obtaining the last modifiation
time of the file, a date will be returned in the form of the
number of seconds from the unix epoch (Jan 1, 1970, 00:00:00).
You can then use any of php's excellent time functions on this
value.

	If rrd_last is not sucessful, a value of 0 will be returned,
and the internal rrd error will be set.  You can access this error
message via the rrd_error() function (if one was set).
 

--------------------------------------------------------------------
int rrd_update(string filename, string options)

	rrd_update takes 2 arguments, a filename of an RRD file
and a string with options to fill the RRD file with.

	It has been designed to work similary to the rrd_update
call in the RRDs perl library.

Example:  $result = rrd_update("/some.rrd", "N:123:9873:235");
 
	If rrd_update is successful, 1 is returned. 

	If rrd_update is not successful, 0 is returned, and an
error message should be obtainable by called 'rrd_error()'.


--------------------------------------------------------------------
int rrd_create(string filename, array options, int num_of_elements)

	rrd_create takes 3 arguments, a filename of an RRD file to
create, an array of options (exactly like you would pass in the RRDs 
perl library, or on the command line to 'rrdtool'), and the last 
argument is the number of elements in the array of options.  This 
can be obtained by simply calling " count($opt_array) ".  See the 
example scripts for a more clear example.

	If rrd_update is successful, 1 is returned. 

	If rrd_update is not successful, 0 is returned, and an
error message should be obtainable by called 'rrd_error()'.



--------------------------------------------------------------------
mixed rrd_graph(string filename, array options, int num_of_elements) 

	rrd_graph takes 3 arguments, a filename of an RRD file,
an array of options (exactly like you would pass in the RRDs perl
library, or on the command line to 'rrdtool'), and the last argument
is the number of elements in the array of options.  This can be 
obtained by simply calling " count($opt_array) ".  See the example
scripts for a more clear example.


	If rrd_graph is successful, an array is returned.  The
array is an associate array with 3 values:

$array[xsize]  -  The size of the image along the X axis.
$array[ysize]  -  The size of the image along the Y axis.
$array[calcpr] -  This is actually another array, that will contain
                  the results of any PRINT statements.


	If rrd_graph is not successful, a 0 is returned.

IMPORTANT NOTE:  In order for php not to complain about mis-using
the return value, it is important that you check the type of the
return value.  use the " is_array() " function to check if the 
returned value is an array (in which case rrd_graph was successful),
or not an array (meaning rrd_graph was NOT successful).  See the
examples for an illustration of this.


--------------------------------------------------------------------
mixed rrd_fetch(string filename, array options, int num_of_elements) 

	rrd_fetch takes 3 arguments, a filename of an RRD file,
an array of options (exactly like you would pass in the RRDs perl
library, or on the command line to 'rrdtool'), and the last argument
is the number of elements in the array of options.  This can be 
obtained by simply calling " count($opt_array) ".  See the example
scripts for a more clear example.


	If rrd_fetch is successful, an array is returned.  The
array is an associate array with 5 values:

$array[start]   -  This is the start time of the data returned 
                   (unix epoch timestamp format)
$array[end]     -  This is the end time of the data returned
                   (unix epoch timestamp format)
$array[step]    -  This is the step interval of the data returned,
                   in number of seconds.
$array[ds_cnt]  -  This is the number of DS's returned from the
                   RRD file.
$array[ds_namv] -  This is an array with the names of the DS's
                   returned from the RRD file.
$array[data]    -  This is an array with all the values fetch'd
                   from the rrd file by rrd_fetch.

(This is very similar to the way rrd_fetch() in the RRDs
perl library works, as well as the C function rrd_fetch()).

	If rrd_fetch is not successful, a 0 is returned.

IMPORTANT NOTE:  In order for php not to complain about mis-using
the return value, it is important that you check the type of the
return value.  use the " is_array() " function to check if the 
returned value is an array (in which case rrd_fetch was successful),
or not an array (meaning rrd_fetch was NOT successful).  See the
examples for an illustration of this.


--------------------------------------------------------------------