3 rrdcgi - Create web pages containing RRD graphs based on templates
7 C<#!/path/to/>B<rrdcgi> S<[B<--filter>]>
11 B<rrdcgi> is a sort of very limited script interpreter. Its purpose
12 is to run as a cgi-program and parse a web page template containing special
13 E<lt>RRD:: tags. B<rrdcgi> will interpret and act according to these tags.
14 In the end it will printout a web page including the necessary CGI headers.
16 B<rrdcgi> parses the contents of the template in 3 steps. In each step it looks
17 only for a subset of tags. This allows nesting of tags.
19 The argument parser uses the same semantics as you are used from your C-shell.
25 Assume that rrdcgi is run as a filter and not as a cgi.
35 Inserts the CGI variable of the given name.
37 =item RRD::CV::QUOTE I<name>
39 Inserts the CGI variable of the given name but quotes it, ready for
40 use as an argument in another RRD:: tag. So even when there are spaces in the
41 value of the CGI variable it will still be considered to be one argument.
43 =item RRD::CV::PATH I<name>
45 Inserts the CGI variable of the given name, quotes it and makes sure
46 it starts neither with a '/' nor contains '..'. This is to make
47 sure that no problematic pathnames can be introduced through the
50 =item RRD::GETENV I<variable>
52 Get the value of an environment variable.
54 <RRD::GETENV REMOTE_USER>
56 might give you the name of the remote user given you are using
57 some sort of access control on the directory.
60 =item RRD::GOODFOR I<seconds>
62 Specify the number of seconds this page should remain valid. This will prompt
63 the rrdcgi to output a Last-Modified, an Expire and if the number of
64 seconds is I<negative> a Refresh header.
66 =item RRD::INCLUDE I<filename>
68 Include the contents of the specified file into the page returned from the cgi.
70 =item RRD::SETENV I<variable> I<value>
72 If you want to present your graphs in another time zone than your own, you
77 to make sure everything is presented in Universal Time. Note that the
78 values permitted to TZ depend on your OS.
80 =item RRD::SETVAR I<variable> I<value>
82 Analog to SETENV but for local variables.
84 =item RRD::GETVAR I<variable>
86 Analog to GETENV but for local variables.
88 =item RRD::TIME::LAST I<rrd-file> I<strftime-format>
90 This gets replaced by the last modification time of the selected RRD. The
91 time is I<strftime>-formatted with the string specified in the second argument.
93 =item RRD::TIME::NOW I<strftime-format>
95 This gets replaced by the current time of day. The time is
96 I<strftime>-formatted with the string specified in the argument.
98 Note that if you return : (colons) from your strftime format you may
99 have to escape them using \ if the time is to be used as an argument
102 =item RRD::TIME::STRFTIME I<START|END> I<start-spec> I<end-spec> I<strftime-format>
104 This gets replaced by a strftime-formatted time using the format
105 I<strftime-format> on either I<start-spec> or I<end-spec> depending on
106 whether I<START> or I<END> is specified. Both I<start-spec> and I<end-spec>
107 must be supplied as either could be relative to the other. This is intended
108 to allow pretty titles on graphs with times that are easier for non RRDtool
109 folks to figure out than "-2weeks".
111 Note that again, if you return : (colon) from your strftime format,
112 you may have to escape them using \ if the time is to be used as an
113 argument to a GRAPH command.
115 =item RRD::GRAPH I<rrdgraph arguments>
117 This tag creates the RRD graph defined by its argument and then is
118 replaced by an appropriate E<lt>IMG ... E<gt> tag referring to the graph.
119 The B<--lazy> option in RRD graph can be used to make sure that graphs
120 are only regenerated when they are out of date. The arguments
121 to the B<RRD::GRAPH> tag work as described in the B<rrdgraph> manual page.
123 Use the B<--lazy> option in your RRD::GRAPH tags, to reduce the load
124 on your server. This option makes sure that graphs are only regenerated when
125 the old ones are out of date.
127 If you do not specify your own B<--imginfo> format, the following will
130 <IMG SRC="%s" WIDTH="%lu" HEIGHT="%lu">
132 Note that %s stands for the filename part of the graph generated, all
133 directories given in the PNG file argument will get dropped.
135 =item RRD::PRINT I<number>
137 If the preceding B<RRD::GRAPH> tag contained and B<PRINT> arguments,
138 then you can access their output with this tag. The I<number> argument refers to the
139 number of the B<PRINT> argument. This first B<PRINT> has I<number> 0.
141 =item RRD::INTERNAL <var>
143 This tag gets replaced by an internal var. Currently these vars are known:
144 VERSION, COMPILETIME.
145 These vars represent the compiled-in values.
151 The example below creates a web pages with a single RRD graph.
153 #!/usr/local/bin/rrdcgi
155 <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
157 <H1>RRDCGI Example Page</H1>
159 <RRD::GRAPH demo.png --lazy --title="Temperatures"
160 DEF:cel=demo.rrd:exhaust:AVERAGE
161 LINE2:cel#00a000:"D. Celsius">
169 This script is slightly more elaborate, it allows you to run it from
170 a form which sets RRD_NAME. RRD_NAME is then used to select which RRD
171 you want to use as source for your graph.
173 #!/usr/local/bin/rrdcgi
175 <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
177 <H1>RRDCGI Example Page for <RRD::CV RRD_NAME></H1>
179 <FORM><INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomA> Room A,
180 <INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomB> Room B.
181 <INPUT TYPE=SUBMIT></FORM>
184 <RRD::GRAPH <RRD::CV::PATH RRD_NAME>.png --lazy
185 --title "Temperatures for "<RRD::CV::QUOTE RRD_NAME>
186 DEF:cel=<RRD::CV::PATH RRD_NAME>.rrd:exhaust:AVERAGE
187 LINE2:cel#00a000:"D. Celsius">
195 This example shows how to handle the case where the RRD, graphs and
196 cgi-bins are seperate directories
200 <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
202 <H1>RRDCGI test Page</H1>
204 /.../web/pngs/testhvt.png
205 --imginfo '<IMG SRC=/.../pngs/%s WIDTH=%lu HEIGHT=%lu >'
206 --lazy --start -1d --end now
207 DEF:http_src=/.../rrds/test.rrd:http_src:AVERAGE
208 AREA:http_src#00ff00:http_src
213 Note 1: Replace /.../ with the relevant directories
215 Note 2: The SRC=/.../pngs should be paths from the view of the
220 Tobias Oetiker E<lt>tobi@oetiker.chE<gt>