Code

Imported upstream version 1.4.8
[pkg-rrdtool.git] / doc / rrdcgi.txt
1 RRDCGI(1)                           rrdtool                          RRDCGI(1)
5 N\bNA\bAM\bME\bE
6        rrdcgi - Create web pages containing RRD graphs based on templates
8 S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
9        "#!/path/to/"r\brr\brd\bdc\bcg\bgi\bi [-\b--\b-f\bfi\bil\blt\bte\ber\br]
11 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
12        r\brr\brd\bdc\bcg\bgi\bi 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. r\brr\brd\bdc\bcg\bgi\bi will interpret and act according to these tags.  In
15        the end it will printout a web page including the necessary CGI
16        headers.
18        r\brr\brd\bdc\bcg\bgi\bi 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.
21        The argument parser uses the same semantics as you are used from your
22        C-shell.
24        -\b--\b-f\bfi\bil\blt\bte\ber\br
25                Assume that rrdcgi is run as a filter and not as a cgi.
27    K\bKe\bey\byw\bwo\bor\brd\bds\bs
28        RRD::CV _\bn_\ba_\bm_\be
29                Inserts the CGI variable of the given name.
31        RRD::CV::QUOTE _\bn_\ba_\bm_\be
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.
37        RRD::CV::PATH _\bn_\ba_\bm_\be
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.
43        RRD::GETENV _\bv_\ba_\br_\bi_\ba_\bb_\bl_\be
44                Get the value of an environment variable.
46                 <RRD::GETENV REMOTE_USER>
48                might give you the name of the remote user given you are using
49                some sort of access control on the directory.
51        RRD::GOODFOR _\bs_\be_\bc_\bo_\bn_\bd_\bs
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 _\bn_\be_\bg_\ba_\bt_\bi_\bv_\be a Refresh
55                header.
57        RRD::INCLUDE _\bf_\bi_\bl_\be_\bn_\ba_\bm_\be
58                Include the contents of the specified file into the page
59                returned from the cgi.
61        RRD::SETENV _\bv_\ba_\br_\bi_\ba_\bb_\bl_\be _\bv_\ba_\bl_\bu_\be
62                If you want to present your graphs in another time zone than
63                your own, you could use
65                 <RRD::SETENV TZ UTC>
67                to make sure everything is presented in Universal Time. Note
68                that the values permitted to TZ depend on your OS.
70        RRD::SETVAR _\bv_\ba_\br_\bi_\ba_\bb_\bl_\be _\bv_\ba_\bl_\bu_\be
71                Analog to SETENV but for local variables.
73        RRD::GETVAR _\bv_\ba_\br_\bi_\ba_\bb_\bl_\be
74                Analog to GETENV but for local variables.
76        RRD::TIME::LAST _\br_\br_\bd_\b-_\bf_\bi_\bl_\be _\bs_\bt_\br_\bf_\bt_\bi_\bm_\be_\b-_\bf_\bo_\br_\bm_\ba_\bt
77                This gets replaced by the last modification time of the
78                selected RRD. The time is _\bs_\bt_\br_\bf_\bt_\bi_\bm_\be-formatted with the string
79                specified in the second argument.
81        RRD::TIME::NOW _\bs_\bt_\br_\bf_\bt_\bi_\bm_\be_\b-_\bf_\bo_\br_\bm_\ba_\bt
82                This gets replaced by the current time of day. The time is
83                _\bs_\bt_\br_\bf_\bt_\bi_\bm_\be-formatted with the string specified in the argument.
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.
89        RRD::TIME::STRFTIME _\bS_\bT_\bA_\bR_\bT_\b|_\bE_\bN_\bD _\bs_\bt_\ba_\br_\bt_\b-_\bs_\bp_\be_\bc _\be_\bn_\bd_\b-_\bs_\bp_\be_\bc _\bs_\bt_\br_\bf_\bt_\bi_\bm_\be_\b-_\bf_\bo_\br_\bm_\ba_\bt
90                This gets replaced by a strftime-formatted time using the
91                format _\bs_\bt_\br_\bf_\bt_\bi_\bm_\be_\b-_\bf_\bo_\br_\bm_\ba_\bt on either _\bs_\bt_\ba_\br_\bt_\b-_\bs_\bp_\be_\bc or _\be_\bn_\bd_\b-_\bs_\bp_\be_\bc
92                depending on whether _\bS_\bT_\bA_\bR_\bT or _\bE_\bN_\bD is specified.  Both _\bs_\bt_\ba_\br_\bt_\b-
93                _\bs_\bp_\be_\bc and _\be_\bn_\bd_\b-_\bs_\bp_\be_\bc 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".
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.
102        RRD::GRAPH _\br_\br_\bd_\bg_\br_\ba_\bp_\bh _\ba_\br_\bg_\bu_\bm_\be_\bn_\bt_\bs
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 -\b--\b-l\bla\baz\bzy\by 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 R\bRR\bRD\bD:\b::\b:G\bGR\bRA\bAP\bPH\bH tag work as described in the
108                r\brr\brd\bdg\bgr\bra\bap\bph\bh manual page.
110                Use the -\b--\b-l\bla\baz\bzy\by 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.
114                If you do not specify your own -\b--\b-i\bim\bmg\bgi\bin\bnf\bfo\bo format, the following
115                will be used:
117                 <IMG SRC="%s" WIDTH="%lu" HEIGHT="%lu">
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.
123        RRD::PRINT _\bn_\bu_\bm_\bb_\be_\br
124                If the preceding  R\bRR\bRD\bD:\b::\b:G\bGR\bRA\bAP\bPH\bH tag contained and P\bPR\bRI\bIN\bNT\bT arguments,
125                then you can access their output with this tag. The _\bn_\bu_\bm_\bb_\be_\br
126                argument refers to the number of the P\bPR\bRI\bIN\bNT\bT argument. This first
127                P\bPR\bRI\bIN\bNT\bT has _\bn_\bu_\bm_\bb_\be_\br 0.
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.
134 E\bEX\bXA\bAM\bMP\bPL\bLE\bE 1\b1
135        The example below creates a web pages with a single RRD graph.
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">
147         </P>
148         </BODY>
149         </HTML>
151 E\bEX\bXA\bAM\bMP\bPL\bLE\bE 2\b2
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.
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">
172         </P>
173         </BODY>
174         </HTML>
176 E\bEX\bXA\bAM\bMP\bPL\bLE\bE 3\b3
177        This example shows how to handle the case where the RRD, graphs and
178        cgi-bins are separate directories
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>
195        Note 1: Replace /.../ with the relevant directories
197        Note 2: The SRC=/.../pngs should be paths from the view of the
198        webserver/browser
200 A\bAU\bUT\bTH\bHO\bOR\bR
201        Tobias Oetiker <tobi@oetiker.ch>
205 1.4.8                             2013-05-23                         RRDCGI(1)