Server IP : 85.214.239.14 / Your IP : 3.144.118.149 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/share/doc/rrdtool/html/ |
Upload File : |
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>RRDs</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:root@localhost" /> </head> <body> <h1 id="NAME">NAME</h1> <p>RRDs - Access RRDtool as a shared module</p> <h1 id="SYNOPSIS">SYNOPSIS</h1> <pre><code>use RRDs; RRDs::error RRDs::last ... RRDs::info ... RRDs::create ... RRDs::update ... RRDs::updatev ... RRDs::graph ... RRDs::fetch ... RRDs::tune ... RRDs::times(start, end) RRDs::dump ... RRDs::restore ... RRDs::flushcached ... RRDs::register_fetch_cb ... $RRDs::VERSION</code></pre> <h1 id="DESCRIPTION">DESCRIPTION</h1> <h2 id="Calling-Sequence">Calling Sequence</h2> <p>This module accesses RRDtool functionality directly from within Perl. The arguments to the functions listed in the SYNOPSIS are explained in the regular RRDtool documentation. The command line call</p> <pre><code>rrdtool update mydemo.rrd --template in:out N:12:13</code></pre> <p>gets turned into</p> <pre><code>RRDs::update ("mydemo.rrd", "--template", "in:out", "N:12:13");</code></pre> <p>Note that</p> <pre><code>--template=in:out</code></pre> <p>is also valid.</p> <p>The RRDs::times function takes two parameters: a "start" and "end" time. These should be specified in the <b>AT-STYLE TIME SPECIFICATION</b> format used by RRDtool. See the <b>rrdfetch</b> documentation for a detailed explanation on how to specify time.</p> <h2 id="Error-Handling">Error Handling</h2> <p>The RRD functions will not abort your program even when they cannot make sense out of the arguments you fed them.</p> <p>The function RRDs::error should be called to get the error status after each function call. If RRDs::error does not return anything then the previous function has completed its task successfully.</p> <pre><code>use RRDs; RRDs::update ("mydemo.rrd","N:12:13"); my $ERR=RRDs::error; die "ERROR while updating mydemo.rrd: $ERR\n" if $ERR;</code></pre> <h2 id="Return-Values">Return Values</h2> <p>The functions RRDs::last, RRDs::graph, RRDs::info, RRDs::fetch and RRDs::times return their findings.</p> <p><b>RRDs::last</b> returns a single INTEGER representing the last update time.</p> <pre><code>$lastupdate = RRDs::last ...</code></pre> <p><b>RRDs::graph</b> returns an ARRAY containing the x-size and y-size of the created image and a pointer to an array with the results of the PRINT arguments.</p> <pre><code>($result_arr,$xsize,$ysize) = RRDs::graph ... print "Imagesize: ${xsize}x${ysize}\n"; print "Averages: ", (join ", ", @$averages);</code></pre> <p><b>RRDs::info</b> returns a pointer to a hash. The keys of the hash represent the property names of the RRD and the values of the hash are the values of the properties.</p> <pre><code>$hash = RRDs::info "example.rrd"; foreach my $key (keys %$hash){ print "$key = $$hash{$key}\n"; }</code></pre> <p><b>RRDs::graphv</b> takes the same parameters as <b>RRDs::graph</b> but it returns a pointer to hash. The hash returned contains meta information about the graph. Like its size as well as the position of the graph area on the image. When calling with '-' as the filename then the contents of the graph will be returned in the hash as well (key 'image').</p> <p><b>RRDs::updatev</b> also returns a pointer to hash. The keys of the hash are concatenated strings of a timestamp, RRA index, and data source name for each consolidated data point (CDP) written to disk as a result of the current update call. The hash values are CDP values.</p> <p><b>RRDs::fetch</b> is the most complex of the pack regarding return values. There are 4 values. Two normal integers, a pointer to an array and a pointer to an array of pointers.</p> <pre><code>my ($start,$step,$names,$data) = RRDs::fetch ... print "Start: ", scalar localtime($start), " ($start)\n"; print "Step size: $step seconds\n"; print "DS names: ", join (", ", @$names)."\n"; print "Data points: ", $#$data + 1, "\n"; print "Data:\n"; for my $line (@$data) { print " ", scalar localtime($start), " ($start) "; $start += $step; for my $val (@$line) { printf "%12.1f ", $val; } print "\n"; }</code></pre> <p><b>RRDs::xport</b> exposes the <a href="./rrdxport.html">rrdxport</a> functionality and returns data with the following structure:</p> <pre><code> my ($start,$end,$step,$cols,$names,$data) = RRDs::xport ... # $start : timestamp # $end : timestamp # $step : seconds # $cols : number of returned columns # $names : arrayref with the names of the columns # $data : arrayref of arrayrefs with the data (first index is time, second is column)</code></pre> <p><b>RRDs::times</b> returns two integers which are the number of seconds since epoch (1970-01-01) for the supplied "start" and "end" arguments, respectively.</p> <p>See the examples directory for more ways to use this extension.</p> <h2 id="Fetch-Callback-Function">Fetch Callback Function</h2> <p>Normally when using graph, xport or fetch the data you see will come from an actual rrd file. Some people who like the look of rrd charts, therefore export their data from a database and then load it into an rrd file just to be able to call rrdgraph on it. Using a custom callback, you can supply your own code for handling the data requests from graph, xport and fetch.</p> <p>To do this, you have to first write a fetch function in perl, and then register this function using <code>RRDs::fetch_register_callback</code>.</p> <p>Finally you can use the pseudo path name <b>cb//</b>[<i>filename</i>] to tell rrdtool to use your callback routine instead of the normal rrdtool fetch function to organize the data required.</p> <p>The callback function must look like this:</p> <pre><code>sub fetch_callback { my $args_hash = shift; # { # filename => 'cb//somefilename', # cd => 'AVERAGE', # start => 1401295291, # end => 1401295591, # step => 300 } # do some clever thing to get that data ready return { start => $unix_timestamp, step => $step_width, data => { dsName1 => [ value1, value2, ... ], dsName2 => [ value1, value2, ... ], dsName3 => [ value1, value2, ... ], } }; }</code></pre> <h1 id="NOTE">NOTE</h1> <p>If you are manipulating the TZ variable you should also call the POSIX function <a href="http://man.he.net/man3/tzset">tzset(3)</a> to initialize all internal states of the library for properly operating in the timezone of your choice.</p> <pre><code>use POSIX qw(tzset); $ENV{TZ} = 'CET'; POSIX::tzset(); </code></pre> <h1 id="AUTHOR">AUTHOR</h1> <p>Tobias Oetiker <tobi@oetiker.ch></p> </body> </html>