Code

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