1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>RRDs</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:root@localhost" />
8 </head>
10 <body style="background-color: white">
12 <p><a name="__index__"></a></p>
13 <!-- INDEX BEGIN -->
14 <!--
16 <ul>
18 <li><a href="#name">NAME</a></li>
19 <li><a href="#synopsis">SYNOPSIS</a></li>
20 <li><a href="#description">DESCRIPTION</a></li>
21 <ul>
23 <li><a href="#calling_sequence">Calling Sequence</a></li>
24 <li><a href="#error_handling">Error Handling</a></li>
25 <li><a href="#return_values">Return Values</a></li>
26 </ul>
28 <li><a href="#note">NOTE</a></li>
29 <li><a href="#author">AUTHOR</a></li>
30 </ul>
31 -->
32 <!-- INDEX END -->
34 <p>
35 </p>
36 <h1><a name="name">NAME</a></h1>
37 <p>RRDs - Access RRDtool as a shared module</p>
38 <p>
39 </p>
40 <hr />
41 <h1><a name="synopsis">SYNOPSIS</a></h1>
42 <pre>
43 use RRDs;
44 RRDs::error
45 RRDs::last ...
46 RRDs::info ...
47 RRDs::create ...
48 RRDs::update ...
49 RRDs::updatev ...
50 RRDs::graph ...
51 RRDs::fetch ...
52 RRDs::tune ...
53 RRDs::times(start, end)
54 RRDs::dump ...
55 RRDs::restore ...</pre>
56 <p>
57 </p>
58 <hr />
59 <h1><a name="description">DESCRIPTION</a></h1>
60 <p>
61 </p>
62 <h2><a name="calling_sequence">Calling Sequence</a></h2>
63 <p>This module accesses RRDtool functionality directly from within perl. The
64 arguments to the functions listed in the SYNOPSIS are explained in the regular
65 RRDtool documentation. The commandline call</p>
66 <pre>
67 rrdtool update mydemo.rrd --template in:out N:12:13</pre>
68 <p>gets turned into</p>
69 <pre>
70 RRDs::update ("mydemo.rrd", "--template", "in:out", "N:12:13");</pre>
71 <p>Note that</p>
72 <pre>
73 --template=in:out</pre>
74 <p>is also valid.</p>
75 <p>The RRDs::times function takes two parameters: a ``start'' and ``end'' time.
76 These should be specified in the <strong>AT-STYLE TIME SPECIFICATION</strong> format
77 used by RRDtool. See the <strong>rrdfetch</strong> documentation for a detailed
78 explanation on how to specify time.</p>
79 <p>
80 </p>
81 <h2><a name="error_handling">Error Handling</a></h2>
82 <p>The RRD functions will not abort your program even when they can not make
83 sense out of the arguments you fed them.</p>
84 <p>The function RRDs::error should be called to get the error status
85 after each function call. If RRDs::error does not return anything
86 then the previous function has completed its task successfully.</p>
87 <pre>
88 use RRDs;
89 RRDs::update ("mydemo.rrd","N:12:13");
90 my $ERR=RRDs::error;
91 die "ERROR while updating mydemo.rrd: $ERR\n" if $ERR;</pre>
92 <p>
93 </p>
94 <h2><a name="return_values">Return Values</a></h2>
95 <p>The functions RRDs::last, RRDs::graph, RRDs::info, RRDs::fetch and RRDs::times
96 return their findings.</p>
97 <p><strong>RRDs::last</strong> returns a single INTEGER representing the last update time.</p>
98 <pre>
99 $lastupdate = RRDs::last ...</pre>
100 <p><strong>RRDs::graph</strong> returns an ARRAY containing the x-size and y-size of the
101 created image and a pointer to an array with the results of the PRINT arguments.</p>
102 <pre>
103 ($result_arr,$xsize,$ysize) = RRDs::graph ...
104 print "Imagesize: ${xsize}x${ysize}\n";
105 print "Averages: ", (join ", ", @$averages);</pre>
106 <p><strong>RRDs::info</strong> returns a pointer to a hash. The keys of the hash
107 represent the property names of the RRD and the values of the hash are
108 the values of the properties.</p>
109 <pre>
110 $hash = RRDs::info "example.rrd";
111 foreach my $key (keys %$hash){
112 print "$key = $$hash{$key}\n";
113 }</pre>
114 <p><strong>RRDs::graphv</strong> takes the same paramters as <strong>RRDs::graph</strong> but it returns a
115 pointer to hash. The hash returned contains meta information about the
116 graph. Like its size as well as the position of the graph area on the image.
117 When calling with and empty filename than the contents of the graph will be
118 returned in the hash as well (key 'image').</p>
119 <p><strong>RRDs::updatev</strong> also returns a pointer to hash. The keys of the hash
120 are concatenated strings of a timestamp, RRA index, and data source name for
121 each consolidated data point (CDP) written to disk as a result of the
122 current update call. The hash values are CDP values.</p>
123 <p><strong>RRDs::fetch</strong> is the most complex of
124 the pack regarding return values. There are 4 values. Two normal
125 integers, a pointer to an array and a pointer to a array of pointers.</p>
126 <pre>
127 my ($start,$step,$names,$data) = RRDs::fetch ...
128 print "Start: ", scalar localtime($start), " ($start)\n";
129 print "Step size: $step seconds\n";
130 print "DS names: ", join (", ", @$names)."\n";
131 print "Data points: ", $#$data + 1, "\n";
132 print "Data:\n";
133 for my $line (@$data) {
134 print " ", scalar localtime($start), " ($start) ";
135 $start += $step;
136 for my $val (@$line) {
137 printf "%12.1f ", $val;
138 }
139 print "\n";
140 }</pre>
141 <p><strong>RRDs::times</strong> returns two integers which are the number of seconds since
142 epoch (1970-01-01) for the supplied ``start'' and ``end'' arguments, respectively.</p>
143 <p>See the examples directory for more ways to use this extension.</p>
144 <p>
145 </p>
146 <hr />
147 <h1><a name="note">NOTE</a></h1>
148 <p>If you are manipulating the TZ variable you should also call the posixs
149 function tzset to initialize all internal state of the library for properly
150 operating in the timezone of your choice.</p>
151 <pre>
152 use POSIX qw(tzset);
153 $ENV{TZ} = 'CET';
154 POSIX::tzset();</pre>
155 <p>
156 </p>
157 <hr />
158 <h1><a name="author">AUTHOR</a></h1>
159 <p>Tobias Oetiker <<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>></p>
161 </body>
163 </html>