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 pointer to an ARRAY containing the x-size and y-size of the
101 created image and results of the PRINT arguments.</p>
102 <pre>
103 ($averages,$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::updatev</strong> also returns a pointer to hash. The keys of the hash
115 are concatenated strings of a timestamp, RRA index, and data source name for
116 each consolidated data point (CDP) written to disk as a result of the
117 current update call. The hash values are CDP values.</p>
118 <p><strong>RRDs::fetch</strong> is the most complex of
119 the pack regarding return values. There are 4 values. Two normal
120 integers, a pointer to an array and a pointer to a array of pointers.</p>
121 <pre>
122 my ($start,$step,$names,$data) = RRDs::fetch ...
123 print "Start: ", scalar localtime($start), " ($start)\n";
124 print "Step size: $step seconds\n";
125 print "DS names: ", join (", ", @$names)."\n";
126 print "Data points: ", $#$data + 1, "\n";
127 print "Data:\n";
128 foreach my $line (@$data) {
129 print " ", scalar localtime($start), " ($start) ";
130 $start += $step;
131 foreach my $val (@$line) {
132 printf "%12.1f ", $val;
133 }
134 print "\n";
135 }</pre>
136 <p><strong>RRDs::times</strong> returns two integers which are the number of seconds since
137 epoch (1970-01-01) for the supplied ``start'' and ``end'' arguments, respectively.</p>
138 <p>See the examples directory for more ways to use this extension.</p>
139 <p>
140 </p>
141 <hr />
142 <h1><a name="note">NOTE</a></h1>
143 <p>If you are manipulating the TZ variable you should also call the posixs
144 function tzset to initialize all internal state of the library for properly
145 operating in the timezone of your choice.</p>
146 <pre>
147 use POSIX qw(tzset);
148 $ENV{TZ} = 'CET';
149 POSIX::tzset();</pre>
150 <p>
151 </p>
152 <hr />
153 <h1><a name="author">AUTHOR</a></h1>
154 <p>Tobias Oetiker <<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>></p>
156 </body>
158 </html>