Code

Imported upstream SVN snapshot 1.4~rc2+20090928.
[pkg-rrdtool.git] / doc / rrdgraph_libdbi.1
diff --git a/doc/rrdgraph_libdbi.1 b/doc/rrdgraph_libdbi.1
new file mode 100644 (file)
index 0000000..9f00dda
--- /dev/null
@@ -0,0 +1,289 @@
+.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.08)
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings.  \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
+.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
+.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
+.\" nothing in troff, for use with C<>.
+.tr \(*W-
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+.    ds -- \(*W-
+.    ds PI pi
+.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
+.    ds L" ""
+.    ds R" ""
+.    ds C` ""
+.    ds C' ""
+'br\}
+.el\{\
+.    ds -- \|\(em\|
+.    ds PI \(*p
+.    ds L" ``
+.    ds R" ''
+'br\}
+.\"
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds Aq \(aq
+.el       .ds Aq '
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
+.\" entries marked with X<> in POD.  Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.ie \nF \{\
+.    de IX
+.    tm Index:\\$1\t\\n%\t"\\$2"
+..
+.    nr % 0
+.    rr F
+.\}
+.el \{\
+.    de IX
+..
+.\}
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
+.    \" fudge factors for nroff and troff
+.if n \{\
+.    ds #H 0
+.    ds #V .8m
+.    ds #F .3m
+.    ds #[ \f1
+.    ds #] \fP
+.\}
+.if t \{\
+.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+.    ds #V .6m
+.    ds #F 0
+.    ds #[ \&
+.    ds #] \&
+.\}
+.    \" simple accents for nroff and troff
+.if n \{\
+.    ds ' \&
+.    ds ` \&
+.    ds ^ \&
+.    ds , \&
+.    ds ~ ~
+.    ds /
+.\}
+.if t \{\
+.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+.    \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.    \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+.    \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+.    ds : e
+.    ds 8 ss
+.    ds o a
+.    ds d- d\h'-1'\(ga
+.    ds D- D\h'-1'\(hy
+.    ds th \o'bp'
+.    ds Th \o'LP'
+.    ds ae ae
+.    ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "RRDGRAPH_LIBDBI 1"
+.TH RRDGRAPH_LIBDBI 1 "2009-06-09" "1.3.999" "rrdtool"
+.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
+.SH "NAME"
+rrdgraph_libdbi \- fetching data for graphing in rrdtool graph via libdbi
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+<rrdfile> = \fBsql//<libdbi driver>/<driver\-option\-name>=<driver\-option\-value>/...[/rrdminstepsize=<stepsize>][/rrdfillmissing=<fill missing n samples>]//<table>/<unixtimestamp column>/<data value column>[/derive]/<where clause 1>/.../<where clause n>\fR
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+This pseudo-rrd-filename defines a sql datasource:
+.IP "\fBsql//\fR" 8
+.IX Item "sql//"
+.Vb 1
+\&  magic cookie\-prefix for a libdbi type datasource
+.Ve
+.IP "\fB<libdbi driver>\fR" 8
+.IX Item "<libdbi driver>"
+.Vb 1
+\&  which libdbi driver to use (e.g: mysql)
+.Ve
+.IP "\fB<driver\-option\-name>\fR=\fB<driver\-option\-value>\fR" 8
+.IX Item "<driver-option-name>=<driver-option-value>"
+.Vb 2
+\&  defines the parameters that are required to connect to the database with the given libdbi driver
+\&  (These drivers are libdbi dependent \- for details please look at the driver documentation of libdbi!)
+.Ve
+.IP "\fB/rrdminstepsize\fR=\fB<minimum step size>\fR" 8
+.IX Item "/rrdminstepsize=<minimum step size>"
+.Vb 1
+\&  defines the minimum number of the step\-length used for graphing (default: 300 seconds)
+.Ve
+.IP "\fB/rrdfillmissing\fR=\fB<fill missing steps>\fR" 8
+.IX Item "/rrdfillmissing=<fill missing steps>"
+.Vb 1
+\&  defines the number of steps to fill with the last value to avoid NaN boxes due to data\-insertation jitter (default: 0 steps)
+.Ve
+.IP "\fB<table>\fR" 8
+.IX Item "<table>"
+.Vb 1
+\&  defines the table from which to fetch the resultset.
+\&
+\&  If there is a need to fetch data from several tables, these tables can be defined by separating the tablenames with a "+"
+\&
+\&  hex\-type\-encoding via %xx are translated to the actual value, use %% to use %
+.Ve
+.IP "\fB<[*]unixtimestamp column>\fR" 8
+.IX Item "<[*]unixtimestamp column>"
+.Vb 2
+\&  defines the column of E<lt>tableE<gt> which contains the unix\-timestamp 
+\&  \- if this is a DATETIME field in the database, then prefix with leading \*(Aq*\*(Aq
+\&
+\&  hex\-type\-encoding via %xx are translated to the actual value, use %% to use %
+.Ve
+.IP "\fB<data value column>\fR" 8
+.IX Item "<data value column>"
+.Vb 1
+\&  defines the column of E<lt>tableE<gt> which contains the value column, which should be graphed
+\&
+\&  hex\-type\-encoding via %xx are translated to the actual value, use %% to use %
+.Ve
+.IP "\fB/derive\fR" 8
+.IX Item "/derive"
+.Vb 1
+\&  defines that the data value used should be the delta of the 2 consecutive values (to simulate COUNTER or DERIVE type datasources)
+.Ve
+.IP "\fB/<where clause(s)>\fR" 8
+.IX Item "/<where clause(s)>"
+.Vb 1
+\&  defines one (ore more) where clauses that are joined with AND to filter the entries in the <lt>table<gt>
+\&
+\&  hex\-type\-encoding via %xx are translated to the actual value, use %% to use %
+.Ve
+.PP
+the returned value column-names, which can be used as ds-names, are:
+.IP "\fBmin\fR, \fBavg\fR, \fBmax\fR, \fBcount\fR and \fBsigma\fR" 8
+.IX Item "min, avg, max, count and sigma"
+.Vb 3
+\&  are returned to be used as ds\-names in your DS definition.
+\&  The reason for using this is that if the consolidation function is used for min/avg and max, then the engine is used several times.
+\&  And this results in the same SQL Statements used several times
+.Ve
+.SH "EXAMPLES"
+.IX Header "EXAMPLES"
+Here an example of a table in a MySQL database:
+.PP
+.Vb 5
+\&  DB connect information
+\&    dbhost=127.0.0.1
+\&    user=rrd
+\&    password=secret
+\&    database=rrd
+\&
+\&  here the table:
+\&    CREATE TABLE RRDValue (
+\&      RRDKeyID      bigint(20) NOT NULL,
+\&      UnixTimeStamp int(11) NOT NULL,
+\&      value         double default NOT NULL,
+\&      PRIMARY KEY  (RRDKeyID,UnixTimeStamp)
+\&    );
+.Ve
+.PP
+and the RRDKeyID we want to graph for is: 1141942900757789274
+.PP
+The pseudo rrd-filename to access this is:
+\&\*(L"sql//mysql/host=127.0.0.1/dbname=rrd/username=rrd/password=secret//RRDValue/UnixTimeStamp/value/RRDKeyID=1141464142203608274\*(R"
+.PP
+To illustrate this here a command to create a graph that contains the actual values.
+.PP
+.Vb 10
+\&  DS_BASE="sql//mysql/host=127.0.0.1/dbname=rrd/username=rrd/password=passwd//RRDValue/UnixTimeStamp/value/RRDKeyID=1141942900757789274"
+\&  rrdtool graph test.png \-\-imgformat=PNG \-\-start=\-1day \-\-end=+3hours \-\-width=1000 \-\-height=600 \e
+\&    "DEF:min=$DS_BASE:min:AVERAGE" \e
+\&    "LINE1:min#FF0000:value" \e
+\&    "DEF:avg=$DS_BASE:avg:AVERAGE" \e
+\&    "LINE1:avg#00FF00:average" \e
+\&    "DEF:max=$DS_BASE:max:AVERAGE" \e
+\&    "LINE1:max#FF0000:max" \e
+\&    "DEF:sigma=$DS_BASE:sigma:AVERAGE" \e
+\&    "CDEF:upper=avg,4,sigma,*,+" \e
+\&    "LINE1:upper#0000FF:+4 sigma" \e
+\&    "CDEF:lower=avg,4,sigma,*,\-" \e
+\&    "LINE1:lower#0000FF:\-4 sigma"
+.Ve
+.SH "NOTES"
+.IX Header "NOTES"
+* Naturally you can also use any other kind of driver that libdbi supports \- e.g postgres, ...
+.PP
+* From the way the datasource is joined, it should also be possible to do joins over different tables 
+  (separate tables with \*(L",\*(R" in table and add in the \s-1WHERE\s0 Clauses the table equal joins. 
+  This has not been tested!!!)
+.PP
+* It should also be relatively simple to add to the database using the same datasource string.
+  This has not been implemented...
+.PP
+* The aggregation functions are ignored and several data columns are used instead 
+  to avoid querying the same \s-1SQL\s0 several times when minimum, average and maximum are needed for graphing...
+.PP
+* for \s-1DB\s0 efficiency you should think of having 2 tables, one containing historic values and the other containing the latest data.
+  This second table should be kept small to allow for the least ammount of blocking \s-1SQL\s0 statements.
+  Whith mysql you can even use myisam table-type for the first and InnoDB for the second. 
+  This is especially interresting as with tables with +100M rows myisam is much smaller then InnoDB.
+.PP
+* To debug the \s-1SQL\s0 statements set the environment variable \s-1RRDDEBUGSQL\s0 and the actual \s-1SQL\s0 statements and the timing is printed to stderr.
+.SH "BUGS"
+.IX Header "BUGS"
+* at least on Linux please make sure that the libdbi driver is explicitly linked against libdbi.so.0 
+  check via ldd /usr/lib/dbd/libmysql.so, that there is a line with libdbi.so.0. 
+  otherwise at least the perl module RRDs will fail because the dynamic linker can not find some symbols from libdbi.so.
+  (this only happens when the libdbi driver is actually used the first time!)
+  This is \s-1KNOWN\s0 to be the case with \s-1RHEL4\s0 and \s-1FC4\s0 and \s-1FC5\s0! (But actually this is a bug with libdbi make files!)
+.PP
+* at least version 0.8.1 of libdbiexhibits a bug with \s-1BINARY\s0 fields
+  (shorttext,text,mediumtext,longtext and possibly also \s-1BINARY\s0 and \s-1BLOB\s0 fields), 
+  that can result in coredumps of rrdtool. 
+  The tool will tell you on stderr if this occures, so that you know what may be the reason.
+  If you are not experiencing these coredumps, then set the environment variable \s-1RRD_NO_LIBDBI_BUG_WARNING\s0, 
+  and then the message will not get shown.
+.SH "AUTHOR"
+.IX Header "AUTHOR"
+Martin Sperl <rrdtool@martin.sperl.org>