1RRDCGI(1)                           rrdtool                          RRDCGI(1)
2
3
4

NAME

6       rrdcgi - Create web pages containing RRD graphs based on templates
7

SYNOPSIS

9       "#!/path/to/"rrdcgi [--filter]
10

DESCRIPTION

12       rrdcgi is a sort of very limited script interpreter. Its purpose is to
13       run as a cgi-program and parse a web page template containing special
14       <RRD:: tags. rrdcgi will interpret and act according to these tags.  In
15       the end it will printout a web page including the necessary CGI head‐
16       ers.
17
18       rrdcgi parses the contents of the template in 3 steps. In each step it
19       looks only for a subset of tags. This allows nesting of tags.
20
21       The argument parser uses the same semantics as you are used from your
22       C-shell.
23
24       --filter
25               Assume that rrdcgi is run as a filter and not as a cgi.
26
27       Keywords
28
29       RRD::CV name
30               Inserts the CGI variable of the given name.
31
32       RRD::CV::QUOTE name
33               Inserts the CGI variable of the given name but quotes it, ready
34               for use as an argument in another RRD:: tag. So even when there
35               are spaces in the value of the CGI variable it will still be
36               considered to be one argument.
37
38       RRD::CV::PATH name
39               Inserts the CGI variable of the given name, quotes it and makes
40               sure it starts neither with a '/' nor contains '..'. This is to
41               make sure that no problematic pathnames can be introduced
42               through the CGI interface.
43
44       RRD::GETENV variable
45               Get the value of an environment variable.
46
47                <RRD::GETENV REMOTE_USER>
48
49               might give you the name of the remote user given you are using
50               some sort of access control on the directory.
51
52       RRD::GOODFOR seconds
53               Specify the number of seconds this page should remain valid.
54               This will prompt the rrdcgi to output a Last-Modified, an
55               Expire and if the number of seconds is negative a Refresh
56               header.
57
58       RRD::INCLUDE filename
59               Include the contents of the specified file into the page
60               returned from the cgi.
61
62       RRD::SETENV variable value
63               If you want to present your graphs in another time zone than
64               your own, you could use
65
66                <RRD::SETENV TZ UTC>
67
68               to make sure everything is presented in Universal Time. Note
69               that the values permitted to TZ depend on your OS.
70
71       RRD::SETVAR variable value
72               Analog to SETENV but for local variables.
73
74       RRD::GETVAR variable
75               Analog to GETENV but for local variables.
76
77       RRD::TIME::LAST rrd-file strftime-format
78               This gets replaced by the last modification time of the
79               selected RRD. The time is strftime-formatted with the string
80               specified in the second argument.
81
82       RRD::TIME::NOW strftime-format
83               This gets replaced by the current time of day. The time is
84               strftime-formatted with the string specified in the argument.
85
86               Note that if you return : (colons) from your strftime format
87               you may have to escape them using \ if the time is to be used
88               as an argument to a GRAPH command.
89
90       RRD::TIME::STRFTIME START|END start-spec end-spec strftime-format
91               This gets replaced by a strftime-formatted time using the for‐
92               mat strftime-format on either start-spec or end-spec depending
93               on whether START or END is specified.  Both start-spec and end-
94               spec must be supplied as either could be relative to the other.
95               This is intended to allow pretty titles on graphs with times
96               that are easier for non RRDtool folks to figure out than
97               "-2weeks".
98
99               Note that again, if you return : (colon) from your strftime
100               format, you may have to escape them using \ if the time is to
101               be used as an argument to a GRAPH command.
102
103       RRD::GRAPH rrdgraph arguments
104               This tag creates the RRD graph defined by its argument and then
105               is replaced by an appropriate <IMG ... > tag referring to the
106               graph.  The --lazy option in RRD graph can be used to make sure
107               that graphs are only regenerated when they are out of date. The
108               arguments to the RRD::GRAPH tag work as described in the rrd‐
109               graph manual page.
110
111               Use the --lazy option in your RRD::GRAPH tags, to reduce the
112               load on your server. This option makes sure that graphs are
113               only regenerated when the old ones are out of date.
114
115               If you do not specify your own --imginfo format, the following
116               will be used:
117
118                <IMG SRC="%s" WIDTH="%lu" HEIGHT="%lu">
119
120               Note that %s stands for the filename part of the graph gener‐
121               ated, all directories given in the PNG file argument will get
122               dropped.
123
124       RRD::PRINT number
125               If the preceding  RRD::GRAPH tag contained and PRINT arguments,
126               then you can access their output with this tag. The number
127               argument refers to the number of the PRINT argument. This first
128               PRINT has number 0.
129
130       RRD::INTERNAL <var>
131               This tag gets replaced by an internal var. Currently these vars
132               are known: VERSION, COMPILETIME.  These vars represent the com‐
133               piled-in values.
134

EXAMPLE 1

136       The example below creates a web pages with a single RRD graph.
137
138        #!/usr/local/bin/rrdcgi
139        <HTML>
140        <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
141        <BODY>
142        <H1>RRDCGI Example Page</H1>
143        <P>
144        <RRD::GRAPH demo.png --lazy --title="Temperatures"
145                 DEF:cel=demo.rrd:exhaust:AVERAGE
146                 LINE2:cel#00a000:"D. Celsius">
147
148        </P>
149        </BODY>
150        </HTML>
151

EXAMPLE 2

153       This script is slightly more elaborate, it allows you to run it from a
154       form which sets RRD_NAME. RRD_NAME is then used to select which RRD you
155       want to use as source for your graph.
156
157        #!/usr/local/bin/rrdcgi
158        <HTML>
159        <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
160        <BODY>
161        <H1>RRDCGI Example Page for <RRD::CV RRD_NAME></H1>
162        <H2>Selection</H2>
163        <FORM><INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomA> Room A,
164              <INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomB> Room B.
165              <INPUT TYPE=SUBMIT></FORM>
166        <H2>Graph</H2>
167        <P>
168        <RRD::GRAPH <RRD::CV::PATH RRD_NAME>.png --lazy
169                 --title "Temperatures for "<RRD::CV::QUOTE RRD_NAME>
170                 DEF:cel=<RRD::CV::PATH RRD_NAME>.rrd:exhaust:AVERAGE
171                 LINE2:cel#00a000:"D. Celsius">
172
173        </P>
174        </BODY>
175        </HTML>
176

EXAMPLE 3

178       This example shows how to handle the case where the RRD, graphs and
179       cgi-bins are seperate directories
180
181        #!/.../bin/rrdcgi
182        <HTML>
183        <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
184        <BODY>
185        <H1>RRDCGI test Page</H1>
186        <RRD::GRAPH
187         /.../web/pngs/testhvt.png
188         --imginfo '<IMG SRC=/.../pngs/%s WIDTH=%lu HEIGHT=%lu >'
189         --lazy --start -1d --end now
190         DEF:http_src=/.../rrds/test.rrd:http_src:AVERAGE
191         AREA:http_src#00ff00:http_src
192        >
193        </BODY>
194        </HTML>
195
196       Note 1: Replace /.../ with the relevant directories
197
198       Note 2: The SRC=/.../pngs should be paths from the view of the web‐
199       server/browser
200

AUTHOR

202       Tobias Oetiker <tobi@oetiker.ch>
203
204
205
2061.2.27                            2008-02-17                         RRDCGI(1)
Impressum