Code

4b740106b2954843dbb6080e7d59ed110071e6a4
[pkg-rrdtool.git] / doc / rrdcgi.1
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "RRDCGI 1"
132 .TH RRDCGI 1 "2008-12-22" "1.3.99909060808" "rrdtool"
133 .SH "NAME"
134 rrdcgi \- Create web pages containing RRD graphs based on templates
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 \&\f(CW\*(C`#!/path/to/\*(C'\fR\fBrrdcgi\fR [\fB\-\-filter\fR]
138 .SH "DESCRIPTION"
139 .IX Header "DESCRIPTION"
140 \&\fBrrdcgi\fR is a sort of very limited script interpreter. Its purpose
141 is to run as a cgi-program and parse a web page template containing special
142 <\s-1RRD::\s0 tags. \fBrrdcgi\fR will interpret and act according to these tags.
143 In the end it will printout a web page including the necessary \s-1CGI\s0 headers.
144 .PP
145 \&\fBrrdcgi\fR parses the contents of the template in 3 steps. In each step it looks
146 only for a subset of tags. This allows nesting of tags.
147 .PP
148 The argument parser uses the same semantics as you are used from your C\-shell.
149 .IP "\fB\-\-filter\fR" 8
150 .IX Item "--filter"
151 Assume that rrdcgi is run as a filter and not as a cgi.
152 .Sh "Keywords"
153 .IX Subsection "Keywords"
154 .IP "\s-1RRD::CV\s0 \fIname\fR" 8
155 .IX Item "RRD::CV name"
156 Inserts the \s-1CGI\s0 variable of the given name.
157 .IP "\s-1RRD::CV::QUOTE\s0 \fIname\fR" 8
158 .IX Item "RRD::CV::QUOTE name"
159 Inserts the \s-1CGI\s0 variable of the given name but quotes it, ready for
160 use as an argument in another \s-1RRD::\s0 tag. So even when there are spaces in the
161 value of the \s-1CGI\s0 variable it will still be considered to be one argument.
162 .IP "\s-1RRD::CV::PATH\s0 \fIname\fR" 8
163 .IX Item "RRD::CV::PATH name"
164 Inserts the \s-1CGI\s0 variable of the given name, quotes it and makes sure
165 it starts neither with a '/' nor contains '..'. This is to make
166 sure that no problematic pathnames can be introduced through the
167 \&\s-1CGI\s0 interface.
168 .IP "\s-1RRD::GETENV\s0 \fIvariable\fR" 8
169 .IX Item "RRD::GETENV variable"
170 Get the value of an environment variable.
171 .Sp
172 .Vb 1
173 \& <RRD::GETENV REMOTE_USER>
174 .Ve
175 .Sp
176 might give you the name of the remote user given you are using
177 some sort of access control on the directory.
178 .IP "\s-1RRD::GOODFOR\s0 \fIseconds\fR" 8
179 .IX Item "RRD::GOODFOR seconds"
180 Specify the number of seconds this page should remain valid. This will prompt
181 the rrdcgi to output a Last\-Modified, an Expire and if the number of
182 seconds is \fInegative\fR a Refresh header.
183 .IP "\s-1RRD::INCLUDE\s0 \fIfilename\fR" 8
184 .IX Item "RRD::INCLUDE filename"
185 Include the contents of the specified file into the page returned from the cgi.
186 .IP "\s-1RRD::SETENV\s0 \fIvariable\fR \fIvalue\fR" 8
187 .IX Item "RRD::SETENV variable value"
188 If you want to present your graphs in another time zone than your own, you
189 could use
190 .Sp
191 .Vb 1
192 \& <RRD::SETENV TZ UTC>
193 .Ve
194 .Sp
195 to make sure everything is presented in Universal Time. Note that the
196 values permitted to \s-1TZ\s0 depend on your \s-1OS\s0.
197 .IP "\s-1RRD::SETVAR\s0 \fIvariable\fR \fIvalue\fR" 8
198 .IX Item "RRD::SETVAR variable value"
199 Analog to \s-1SETENV\s0 but for local variables.
200 .IP "\s-1RRD::GETVAR\s0 \fIvariable\fR" 8
201 .IX Item "RRD::GETVAR variable"
202 Analog to \s-1GETENV\s0 but for local variables.
203 .IP "\s-1RRD::TIME::LAST\s0 \fIrrd-file\fR \fIstrftime-format\fR" 8
204 .IX Item "RRD::TIME::LAST rrd-file strftime-format"
205 This gets replaced by the last modification time of the selected \s-1RRD\s0. The
206 time is \fIstrftime\fR\-formatted with the string specified in the second argument.
207 .IP "\s-1RRD::TIME::NOW\s0 \fIstrftime-format\fR" 8
208 .IX Item "RRD::TIME::NOW strftime-format"
209 This gets replaced by the current time of day. The time is
210 \&\fIstrftime\fR\-formatted with the string specified in the argument.
211 .Sp
212 Note that if you return : (colons) from your strftime format you may
213 have to escape them using \e if the time is to be used as an argument
214 to a \s-1GRAPH\s0 command.
215 .IP "\s-1RRD::TIME::STRFTIME\s0 \fISTART|END\fR \fIstart-spec\fR \fIend-spec\fR \fIstrftime-format\fR" 8
216 .IX Item "RRD::TIME::STRFTIME START|END start-spec end-spec strftime-format"
217 This gets replaced by a strftime-formatted time using the format
218 \&\fIstrftime-format\fR on either \fIstart-spec\fR or \fIend-spec\fR depending on
219 whether \fI\s-1START\s0\fR or \fI\s-1END\s0\fR is specified.  Both \fIstart-spec\fR and \fIend-spec\fR
220 must be supplied as either could be relative to the other.  This is intended
221 to allow pretty titles on graphs with times that are easier for non RRDtool
222 folks to figure out than \*(L"\-2weeks\*(R".
223 .Sp
224 Note that again, if you return : (colon) from your strftime format,
225 you may have to escape them using \e if the time is to be used as an
226 argument to a \s-1GRAPH\s0 command.
227 .IP "\s-1RRD::GRAPH\s0 \fIrrdgraph arguments\fR" 8
228 .IX Item "RRD::GRAPH rrdgraph arguments"
229 This tag creates the \s-1RRD\s0 graph defined by its argument and then is
230 replaced by an appropriate <\s-1IMG\s0 ... > tag referring to the graph.
231 The \fB\-\-lazy\fR option in \s-1RRD\s0 graph can be used to make sure that graphs
232 are only regenerated when they are out of date. The arguments
233 to the \fB\s-1RRD::GRAPH\s0\fR tag work as described in the \fBrrdgraph\fR manual page.
234 .Sp
235 Use the \fB\-\-lazy\fR option in your \s-1RRD::GRAPH\s0 tags, to reduce the load
236 on your server. This option makes sure that graphs are only regenerated when
237 the old ones are out of date.
238 .Sp
239 If you do not specify your own \fB\-\-imginfo\fR format, the following will
240 be used:
241 .Sp
242 .Vb 1
243 \& <IMG SRC="%s" WIDTH="%lu" HEIGHT="%lu">
244 .Ve
245 .Sp
246 Note that \f(CW%s\fR stands for the filename part of the graph generated, all
247 directories given in the \s-1PNG\s0 file argument will get dropped.
248 .IP "\s-1RRD::PRINT\s0 \fInumber\fR" 8
249 .IX Item "RRD::PRINT number"
250 If the preceding  \fB\s-1RRD::GRAPH\s0\fR tag contained and \fB\s-1PRINT\s0\fR arguments,
251 then you can access their output with this tag. The \fInumber\fR argument refers to the
252 number of the \fB\s-1PRINT\s0\fR argument. This first \fB\s-1PRINT\s0\fR has \fInumber\fR 0.
253 .IP "\s-1RRD::INTERNAL\s0 <var>" 8
254 .IX Item "RRD::INTERNAL <var>"
255 This tag gets replaced by an internal var. Currently these vars are known:
256 \&\s-1VERSION\s0, \s-1COMPILETIME\s0.
257 These vars represent the compiled-in values. 
258 .SH "EXAMPLE 1"
259 .IX Header "EXAMPLE 1"
260 The example below creates a web pages with a single \s-1RRD\s0 graph.
261 .PP
262 .Vb 9
263 \& #!/usr/local/bin/rrdcgi
264 \& <HTML>
265 \& <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
266 \& <BODY>
267 \& <H1>RRDCGI Example Page</H1>
268 \& <P>
269 \& <RRD::GRAPH demo.png \-\-lazy \-\-title="Temperatures"
270 \&          DEF:cel=demo.rrd:exhaust:AVERAGE
271 \&          LINE2:cel#00a000:"D. Celsius">
272 .Ve
273 .PP
274 .Vb 3
275 \& </P>
276 \& </BODY>
277 \& </HTML>
278 .Ve
279 .SH "EXAMPLE 2"
280 .IX Header "EXAMPLE 2"
281 This script is slightly more elaborate, it allows you to run it from
282 a form which sets \s-1RRD_NAME\s0. \s-1RRD_NAME\s0 is then used to select which \s-1RRD\s0
283 you want to use as source for your graph.
284 .PP
285 .Vb 15
286 \& #!/usr/local/bin/rrdcgi
287 \& <HTML>
288 \& <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
289 \& <BODY>
290 \& <H1>RRDCGI Example Page for <RRD::CV RRD_NAME></H1>
291 \& <H2>Selection</H2>
292 \& <FORM><INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomA> Room A,
293 \&       <INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomB> Room B.
294 \&       <INPUT TYPE=SUBMIT></FORM>
295 \& <H2>Graph</H2>
296 \& <P>
297 \& <RRD::GRAPH <RRD::CV::PATH RRD_NAME>.png \-\-lazy
298 \&          \-\-title "Temperatures for "<RRD::CV::QUOTE RRD_NAME>
299 \&          DEF:cel=<RRD::CV::PATH RRD_NAME>.rrd:exhaust:AVERAGE
300 \&          LINE2:cel#00a000:"D. Celsius">
301 .Ve
302 .PP
303 .Vb 3
304 \& </P>
305 \& </BODY>
306 \& </HTML>
307 .Ve
308 .SH "EXAMPLE 3"
309 .IX Header "EXAMPLE 3"
310 This example shows how to handle the case where the \s-1RRD\s0, graphs and
311 cgi-bins are separate directories
312 .PP
313 .Vb 14
314 \& #!/.../bin/rrdcgi
315 \& <HTML>
316 \& <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
317 \& <BODY>
318 \& <H1>RRDCGI test Page</H1>
319 \& <RRD::GRAPH
320 \&  /.../web/pngs/testhvt.png
321 \&  \-\-imginfo '<IMG SRC=/.../pngs/%s WIDTH=%lu HEIGHT=%lu >'
322 \&  \-\-lazy \-\-start \-1d \-\-end now
323 \&  DEF:http_src=/.../rrds/test.rrd:http_src:AVERAGE
324 \&  AREA:http_src#00ff00:http_src
325 \& >
326 \& </BODY>
327 \& </HTML>
328 .Ve
329 .PP
330 Note 1: Replace /.../ with the relevant directories
331 .PP
332 Note 2: The SRC=/.../pngs should be paths from the view of the
333 webserver/browser
334 .SH "AUTHOR"
335 .IX Header "AUTHOR"
336 Tobias Oetiker <tobi@oetiker.ch>