1RRDCGI(1) rrdtool RRDCGI(1)
2
3
4
6 rrdcgi - Create web pages containing RRD graphs based on templates
7
9 "#!/path/to/"rrdcgi [--filter]
10
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
16 headers.
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 RRD::CV name
29 Inserts the CGI variable of the given name.
30
31 RRD::CV::QUOTE name
32 Inserts the CGI variable of the given name but quotes it, ready
33 for use as an argument in another RRD:: tag. So even when there
34 are spaces in the value of the CGI variable it will still be
35 considered to be one argument.
36
37 RRD::CV::PATH name
38 Inserts the CGI variable of the given name, quotes it and makes
39 sure it starts neither with a '/' nor contains '..'. This is to
40 make sure that no problematic pathnames can be introduced
41 through the CGI interface.
42
43 RRD::GETENV variable
44 Get the value of an environment variable.
45
46 <RRD::GETENV REMOTE_USER>
47
48 might give you the name of the remote user given you are using
49 some sort of access control on the directory.
50
51 RRD::GOODFOR seconds
52 Specify the number of seconds this page should remain valid.
53 This will prompt the rrdcgi to output a Last-Modified, an
54 Expire and if the number of seconds is negative a Refresh
55 header.
56
57 RRD::INCLUDE filename
58 Include the contents of the specified file into the page
59 returned from the cgi.
60
61 RRD::SETENV variable value
62 If you want to present your graphs in another time zone than
63 your own, you could use
64
65 <RRD::SETENV TZ UTC>
66
67 to make sure everything is presented in Universal Time. Note
68 that the values permitted to TZ depend on your OS.
69
70 RRD::SETVAR variable value
71 Analog to SETENV but for local variables.
72
73 RRD::GETVAR variable
74 Analog to GETENV but for local variables.
75
76 RRD::TIME::LAST rrd-file strftime-format
77 This gets replaced by the last modification time of the
78 selected RRD. The time is strftime-formatted with the string
79 specified in the second argument.
80
81 RRD::TIME::NOW strftime-format
82 This gets replaced by the current time of day. The time is
83 strftime-formatted with the string specified in the argument.
84
85 Note that if you return : (colons) from your strftime format
86 you may have to escape them using \ if the time is to be used
87 as an argument to a GRAPH command.
88
89 RRD::TIME::STRFTIME START|END start-spec end-spec strftime-format
90 This gets replaced by a strftime-formatted time using the
91 format strftime-format on either start-spec or end-spec
92 depending on whether START or END is specified. Both start-
93 spec and end-spec must be supplied as either could be relative
94 to the other. This is intended to allow pretty titles on
95 graphs with times that are easier for non RRDtool folks to
96 figure out than "-2weeks".
97
98 Note that again, if you return : (colon) from your strftime
99 format, you may have to escape them using \ if the time is to
100 be used as an argument to a GRAPH command.
101
102 RRD::GRAPH rrdgraph arguments
103 This tag creates the RRD graph defined by its argument and then
104 is replaced by an appropriate <IMG ... > tag referring to the
105 graph. The --lazy option in RRD graph can be used to make sure
106 that graphs are only regenerated when they are out of date. The
107 arguments to the RRD::GRAPH tag work as described in the
108 rrdgraph manual page.
109
110 Use the --lazy option in your RRD::GRAPH tags, to reduce the
111 load on your server. This option makes sure that graphs are
112 only regenerated when the old ones are out of date.
113
114 If you do not specify your own --imginfo format, the following
115 will be used:
116
117 <IMG SRC="%s" WIDTH="%lu" HEIGHT="%lu">
118
119 Note that %s stands for the filename part of the graph
120 generated, all directories given in the PNG file argument will
121 get dropped.
122
123 RRD::PRINT number
124 If the preceding RRD::GRAPH tag contained and PRINT arguments,
125 then you can access their output with this tag. The number
126 argument refers to the number of the PRINT argument. This first
127 PRINT has number 0.
128
129 RRD::INTERNAL <var>
130 This tag gets replaced by an internal var. Currently these vars
131 are known: VERSION, COMPILETIME. These vars represent the
132 compiled-in values.
133
135 The example below creates a web pages with a single RRD graph.
136
137 #!/usr/local/bin/rrdcgi
138 <HTML>
139 <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
140 <BODY>
141 <H1>RRDCGI Example Page</H1>
142 <P>
143 <RRD::GRAPH demo.png --lazy --title="Temperatures"
144 DEF:cel=demo.rrd:exhaust:AVERAGE
145 LINE2:cel#00a000:"D. Celsius">
146
147 </P>
148 </BODY>
149 </HTML>
150
152 This script is slightly more elaborate, it allows you to run it from a
153 form which sets RRD_NAME. RRD_NAME is then used to select which RRD you
154 want to use as source for your graph.
155
156 #!/usr/local/bin/rrdcgi
157 <HTML>
158 <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
159 <BODY>
160 <H1>RRDCGI Example Page for <RRD::CV RRD_NAME></H1>
161 <H2>Selection</H2>
162 <FORM><INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomA> Room A,
163 <INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomB> Room B.
164 <INPUT TYPE=SUBMIT></FORM>
165 <H2>Graph</H2>
166 <P>
167 <RRD::GRAPH <RRD::CV::PATH RRD_NAME>.png --lazy
168 --title "Temperatures for "<RRD::CV::QUOTE RRD_NAME>
169 DEF:cel=<RRD::CV::PATH RRD_NAME>.rrd:exhaust:AVERAGE
170 LINE2:cel#00a000:"D. Celsius">
171
172 </P>
173 </BODY>
174 </HTML>
175
177 This example shows how to handle the case where the RRD, graphs and
178 cgi-bins are separate directories
179
180 #!/.../bin/rrdcgi
181 <HTML>
182 <HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
183 <BODY>
184 <H1>RRDCGI test Page</H1>
185 <RRD::GRAPH
186 /.../web/pngs/testhvt.png
187 --imginfo '<IMG SRC=/.../pngs/%s WIDTH=%lu HEIGHT=%lu >'
188 --lazy --start -1d --end now
189 DEF:http_src=/.../rrds/test.rrd:http_src:AVERAGE
190 AREA:http_src#00ff00:http_src
191 >
192 </BODY>
193 </HTML>
194
195 Note 1: Replace /.../ with the relevant directories
196
197 Note 2: The SRC=/.../pngs should be paths from the view of the
198 webserver/browser
199
201 Tobias Oetiker <tobi@oetiker.ch>
202
203
204
2051.4.4 2008-12-22 RRDCGI(1)