RRDCGI(1)
β¨ NAME β¨
okay bestie, meet rrdcgi β aka RRDCGI(1) from rrdtool β and its whole thing is creating web pages containing RRD graphs based on templates. iconic behavior, honestly. π
β¨ SYNOPSIS β¨
"#!/path/to/"rrdcgi [--filter|-f]
πΈ DESCRIPTION πΈ
so rrdcgi is a sort of very limited script interpreter. no cap. its purpose is to run as a cgi-program and parse a web page template containing special RRD:: tags. rrdcgi will interpret those tags and act according to them. in the end it prints out a web page including the necessary CGI headers. periodt. β¨
rrdcgi parses the contents of the template in 3 steps. in each step it looks only for a subset of tags β which is exactly what allows nesting of tags. the argument parser lowkey uses the same semantics as you are used from your C-shell, iykyk.
--filter,-fβ assume thatrrdcgiis run as a filter and not as a cgi.
π Keywords π
RRD::CV nameβ inserts the CGI variable of the given name.RRD::CV::QUOTE nameβ inserts the CGI variable of the given name but quotes it, ready for use as an argument in anotherRRD::tag. so even when there are spaces in the value of the CGI variable it will still be considered to be one argument. slay.RRD::CV::PATH nameβ inserts the CGI variable of the given name, quotes it and makes sure it starts neither with a/nor contains... this is to make sure that no problematic pathnames can be introduced through the CGI interface. safety queen. π‘οΈRRD::GETENV variableβ get the value of an environment variable. for example,<RRD::GETENV REMOTE_USER>might give you the name of the remote user given you are using some sort of access control on the directory.RRD::GOODFOR secondsβ specify the number of seconds this page should remain valid. this will promptrrdcgito output aLast-Modified, anExpireand if the number of seconds is negative aRefreshheader.RRD::INCLUDE filenameβ include the contents of the specified file into the page returned from the cgi.RRD::SETENV variable valueβ if you want to present your graphs in another time zone than your own, you could use<RRD::SETENV TZ UTC>to make sure everything is presented in Universal Time. note that the values permitted toTZdepend on your OS.RRD::SETVAR variable valueβ analog toSETENVbut for local variables.RRD::GETVAR variableβ analog toGETENVbut for local variables.RRD::TIME::LAST rrd-file strftime-formatβ this gets replaced by the last modification time of the selected RRD. the time isstrftime-formatted with the string specified in the second argument.RRD::TIME::NOW strftime-formatβ this gets replaced by the current time of day. the time isstrftime-formatted with the string specified in the argument. note that if you return:(colons) from yourstrftimeformat you may have to escape them using\if the time is to be used as an argument to aGRAPHcommand.RRD::TIME::STRFTIME START|END start-spec end-spec strftime-formatβ this gets replaced by astrftime-formatted time using the formatstrftime-formaton eitherstart-specorend-specdepending on whetherSTARTorENDis specified. bothstart-specandend-specmust be supplied as either could be relative to the other. this is intended to allow pretty titles on graphs with times that are easier for non RRDtool folks to figure out than"-2weeks". note that again, if you return:(colon) from yourstrftimeformat, you may have to escape them using\if the time is to be used as an argument to aGRAPHcommand.RRD::GRAPH rrdgraph argumentsβ this tag creates the RRD graph defined by its argument and then is replaced by an appropriate<IMG ... >tag referring to the graph. the--lazyoption in RRD graph can be used to make sure that graphs are only regenerated when they are out of date. the arguments to theRRD::GRAPHtag work as described in therrdgraphmanual page. use the--lazyoption in yourRRD::GRAPHtags, to reduce the load on your server. this option makes sure that graphs are only regenerated when the old ones are out of date. if you do not specify your own--imginfoformat, the following will be used:<IMG SRC="%s" WIDTH="%lu" HEIGHT="%lu">. note that%sstands for the filename part of the graph generated, all directories given in the PNG file argument will get dropped.RRD::PRINT numberβ if the precedingRRD::GRAPHtag contained anyPRINTarguments, then you can access their output with this tag. thenumberargument refers to the number of thePRINTargument. the firstPRINThas number0.RRD::INTERNAL <var>β this tag gets replaced by an internal var. currently these vars are known:VERSION,COMPILETIME. these vars represent the compiled-in values.
π¦ EXAMPLE 1 π¦
the example below creates a web page with a single RRD graph.
#!/usr/local/bin/rrdcgi
<HTML>
<HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
<BODY>
<H1>RRDCGI Example Page</H1>
<P>
<RRD::GRAPH demo.png --lazy --title="Temperatures"
DEF:cel=demo.rrd:exhaust:AVERAGE
LINE2:cel#00a000:"D. Celsius">
</P>
</BODY>
</HTML>
π¦ EXAMPLE 2 π¦
this script is slightly more elaborate, it allows you to run it from a form which sets RRD_NAME. RRD_NAME is then used to select which RRD you want to use as source for your graph.
#!/usr/local/bin/rrdcgi
<HTML>
<HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
<BODY>
<H1>RRDCGI Example Page for <RRD::CV RRD_NAME></H1>
<H2>Selection</H2>
<FORM><INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomA> Room A,
<INPUT NAME=RRD_NAME TYPE=RADIO VALUE=roomB> Room B.
<INPUT TYPE=SUBMIT></FORM>
<H2>Graph</H2>
<P>
<RRD::GRAPH <RRD::CV::PATH RRD_NAME>.png --lazy
--title "Temperatures for "<RRD::CV::QUOTE RRD_NAME>
DEF:cel=<RRD::CV::PATH RRD_NAME>.rrd:exhaust:AVERAGE
LINE2:cel#00a000:"D. Celsius">
</P>
</BODY>
</HTML>
π¦ EXAMPLE 3 π¦
this example shows how to handle the case where the RRD, graphs and cgi-bins are separate directories
#!/.../bin/rrdcgi
<HTML>
<HEAD><TITLE>RRDCGI Demo</TITLE></HEAD>
<BODY>
<H1>RRDCGI test Page</H1>
<RRD::GRAPH
/.../web/pngs/testhvt.png
--imginfo '<IMG SRC=/.../pngs/%s WIDTH=%lu HEIGHT=%lu >'
--lazy --start -1d --end now
DEF:http_src=/.../rrds/test.rrd:http_src:AVERAGE
AREA:http_src#00ff00:http_src
>
</BODY>
</HTML>
note 1: replace /.../ with the relevant directories.
note 2: the SRC=/.../pngs should be paths from the view of the webserver/browser.
π AUTHOR π
Tobias Oetiker <tobi@oetiker.ch> β the legend himself. π«Ά
β¨ that's the whole RRDCGI(1) situation β rrdtool version 1.11.0, dated 2026-10-17. go forth and graph, bestie! π
π¦ where this page comes from
- arch rolling: rrdtool 1.11.0-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms