Code

Imported upstream version 1.3rc4.
[pkg-rrdtool.git] / doc / RRDs.html
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 (&quot;mydemo.rrd&quot;, &quot;--template&quot;, &quot;in:out&quot;, &quot;N:12:13&quot;);</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 (&quot;mydemo.rrd&quot;,&quot;N:12:13&quot;);
90  my $ERR=RRDs::error;
91  die &quot;ERROR while updating mydemo.rrd: $ERR\n&quot; 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 &quot;Imagesize: ${xsize}x${ysize}\n&quot;;
105  print &quot;Averages: &quot;, (join &quot;, &quot;, @$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 &quot;example.rrd&quot;;
111  foreach my $key (keys %$hash){
112    print &quot;$key = $$hash{$key}\n&quot;;
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 &quot;Start:       &quot;, scalar localtime($start), &quot; ($start)\n&quot;;
129   print &quot;Step size:   $step seconds\n&quot;;
130   print &quot;DS names:    &quot;, join (&quot;, &quot;, @$names).&quot;\n&quot;;
131   print &quot;Data points: &quot;, $#$data + 1, &quot;\n&quot;;
132   print &quot;Data:\n&quot;;
133   foreach my $line (@$data) {
134     print &quot;  &quot;, scalar localtime($start), &quot; ($start) &quot;;
135     $start += $step;
136     foreach my $val (@$line) {
137       printf &quot;%12.1f &quot;, $val;
138     }
139     print &quot;\n&quot;;
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 &lt;<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>&gt;</p>
161 </body>
163 </html>