4 use vars qw(@ISA $VERSION);
12 bootstrap RRDs $VERSION;
19 RRDs - Access RRDtool as a shared module
33 RRDs::times(start, end)
40 =head2 Calling Sequence
42 This module accesses RRDtool functionality directly from within Perl. The
43 arguments to the functions listed in the SYNOPSIS are explained in the regular
44 RRDtool documentation. The command line call
46 rrdtool update mydemo.rrd --template in:out N:12:13
50 RRDs::update ("mydemo.rrd", "--template", "in:out", "N:12:13");
58 The RRDs::times function takes two parameters: a "start" and "end" time.
59 These should be specified in the B<AT-STYLE TIME SPECIFICATION> format
60 used by RRDtool. See the B<rrdfetch> documentation for a detailed
61 explanation on how to specify time.
65 The RRD functions will not abort your program even when they can not make
66 sense out of the arguments you fed them.
68 The function RRDs::error should be called to get the error status
69 after each function call. If RRDs::error does not return anything
70 then the previous function has completed its task successfully.
73 RRDs::update ("mydemo.rrd","N:12:13");
75 die "ERROR while updating mydemo.rrd: $ERR\n" if $ERR;
79 The functions RRDs::last, RRDs::graph, RRDs::info, RRDs::fetch and RRDs::times
80 return their findings.
82 B<RRDs::last> returns a single INTEGER representing the last update time.
84 $lastupdate = RRDs::last ...
86 B<RRDs::graph> returns an ARRAY containing the x-size and y-size of the
87 created image and a pointer to an array with the results of the PRINT arguments.
89 ($result_arr,$xsize,$ysize) = RRDs::graph ...
90 print "Imagesize: ${xsize}x${ysize}\n";
91 print "Averages: ", (join ", ", @$averages);
93 B<RRDs::info> returns a pointer to a hash. The keys of the hash
94 represent the property names of the RRD and the values of the hash are
95 the values of the properties.
97 $hash = RRDs::info "example.rrd";
98 foreach my $key (keys %$hash){
99 print "$key = $$hash{$key}\n";
102 B<RRDs::graphv> takes the same parameters as B<RRDs::graph> but it returns a
103 pointer to hash. The hash returned contains meta information about the
104 graph. Like its size as well as the position of the graph area on the image.
105 When calling with and empty filename than the contents of the graph will be
106 returned in the hash as well (key 'image').
108 B<RRDs::updatev> also returns a pointer to hash. The keys of the hash
109 are concatenated strings of a timestamp, RRA index, and data source name for
110 each consolidated data point (CDP) written to disk as a result of the
111 current update call. The hash values are CDP values.
113 B<RRDs::fetch> is the most complex of
114 the pack regarding return values. There are 4 values. Two normal
115 integers, a pointer to an array and a pointer to a array of pointers.
117 my ($start,$step,$names,$data) = RRDs::fetch ...
118 print "Start: ", scalar localtime($start), " ($start)\n";
119 print "Step size: $step seconds\n";
120 print "DS names: ", join (", ", @$names)."\n";
121 print "Data points: ", $#$data + 1, "\n";
123 for my $line (@$data) {
124 print " ", scalar localtime($start), " ($start) ";
126 for my $val (@$line) {
127 printf "%12.1f ", $val;
132 B<RRDs::times> returns two integers which are the number of seconds since
133 epoch (1970-01-01) for the supplied "start" and "end" arguments, respectively.
135 See the examples directory for more ways to use this extension.
139 If you are manipulating the TZ variable you should also call the POSIX
140 function L<tzset(3)> to initialize all internal state of the library for properly
141 operating in the timezone of your choice.
150 Tobias Oetiker E<lt>tobi@oetiker.chE<gt>