.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' '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 >0, 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. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "RRDGRAPH_LIBDBI 1" .TH RRDGRAPH_LIBDBI 1 2024-03-17 1.7.2 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" = \fBsql///=/...\:[/rrdminstepsize=]\:[/rrdfillmissing=]\://\:/\:/\:[/derive]\:/\:/...\:/\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\fR" 8 .IX Item "" .Vb 1 \& which libdbi driver to use (e.g.: mysql) .Ve .IP \fB\fR=\fB\fR 8 .IX Item "=" .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\fR" 8 .IX Item "/rrdminstepsize=" .Vb 1 \& defines the minimum number of the step\-length used for graphing (default: 300 seconds) .Ve .IP "\fB/rrdfillmissing\fR=\fB\fR" 8 .IX Item "/rrdfillmissing=" .Vb 1 \& defines the number of seconds to fill with the last value to avoid NaN boxes due to data\-insertation jitter (default: 0 seconds) .Ve .IP \fB
\fR 8 .IX Item "
" .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
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\fR" 8 .IX Item "" .Vb 1 \& defines the column of
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/\fR" 8 .IX Item "/" .Vb 1 \& defines one (ore more) where clauses that are joined with AND to filter the entries in the
\& \& 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 \& dbname=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: "sql//mysql/host=127.0.0.1/dbname=rrd/username=rrd/password=secret\://RRDValue\:/UnixTimeStamp\:/value\:/RRDKeyID=1141464142203608274" .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 data source is joined, it should also be possible to do joins over different tables (separate tables with "," in table and add in the WHERE 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 data source string. This has not been implemented... .PP * The aggregation functions are ignored and several data columns are used instead to avoid querying the same SQL several times when minimum, average and maximum are needed for graphing... .PP * for DB 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 amount of blocking SQL statements. With mysql you can even use myisam table-type for the first and InnoDB for the second. This is especially interesting as with tables with +100M rows myisam is much smaller then InnoDB. .PP * To debug the SQL statements set the environment variable RRDDEBUGSQL and the actual SQL statements and the timing is printed to stderr. .SH "Performance issues with MySQL backend" .IX Header "Performance issues with MySQL backend" Previous versions of LibDBI have a big performance issue when retrieving data from a MySQL server. Performance impact is exponentially based on the number of values you retrieve from the database. For example, it would take more than 2 seconds to graph 5DS on 150 hours of data with a precision of 5 minutes (against 100ms when data comes from a RRD file). This bug has been fixed in version 0.9.0 of LibDBI. You can find more information on this libdbi-users mailing list thread: http://sourceforge.net/mailarchive/message.php?msg_id=30320894 .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 cannot find some symbols from libdbi.so. (this only happens when the libdbi driver is actually used the first time!) This is KNOWN to be the case with RHEL4 and FC4 and FC5! (But actually this is a bug with libdbi make files!) .PP * at least version 0.8.1 of libdbi exhibits a bug with BINARY fields (shorttext,text,mediumtext,longtext and possibly also BINARY and BLOB fields), that can result in coredumps of rrdtool. The tool will tell you on stderr if this occurs, so that you know what may be the reason. If you are not experiencing these coredumps, then set the environment variable RRD_NO_LIBDBI_BUG_WARNING, and then the message will not get shown. .SH AUTHOR .IX Header "AUTHOR" Martin Sperl