Code

Imported upstream SVN snapshot 1.4~rc2+20090928.
[pkg-rrdtool.git] / doc / RRDp.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>RRDp</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">
13 <!-- INDEX BEGIN -->
14 <div name="index">
15 <p><a name="__index__"></a></p>
16 <!--
18 <ul>
20         <li><a href="#name">NAME</a></li>
21         <li><a href="#synopsis">SYNOPSIS</a></li>
22         <li><a href="#description">DESCRIPTION</a></li>
23         <li><a href="#example">EXAMPLE</a></li>
24         <li><a href="#see_also">SEE ALSO</a></li>
25         <li><a href="#author">AUTHOR</a></li>
26 </ul>
28 -->
31 </div>
32 <!-- INDEX END -->
34 <p>
35 </p>
36 <h1><a name="name">NAME</a></h1>
37 <p>RRDp - Attach RRDtool from within a perl script via a set of pipes;</p>
38 <p>
39 </p>
40 <hr />
41 <h1><a name="synopsis">SYNOPSIS</a></h1>
42 <p>use <strong>RRDp</strong></p>
43 <p><strong>RRDp::start</strong> <em>path to RRDtool executable</em></p>
44 <p><strong>RRDp::cmd</strong>  <em>rrdtool commandline</em></p>
45 <p>$answer = <strong>RRD::read</strong></p>
46 <p>$status = <strong>RRD::end</strong></p>
47 <p><strong>$RRDp::user</strong>,  <strong>$RRDp::sys</strong>, <strong>$RRDp::real</strong>, <strong>$RRDp::error_mode</strong>, <strong>$RRDp::error</strong></p>
48 <p>
49 </p>
50 <hr />
51 <h1><a name="description">DESCRIPTION</a></h1>
52 <p>With this module you can safely communicate with the RRDtool.</p>
53 <p>After every <strong>RRDp::cmd</strong> you have to issue an <strong>RRDp::read</strong> command to get
54 <strong>RRDtool</strong>s answer to your command. The answer is returned as a pointer,
55 in order to speed things up. If the last command did not return any
56 data, <strong>RRDp::read</strong> will return an undefined variable.</p>
57 <p>If you import the PERFORMANCE variables into your namespace, 
58 you can access RRDtool's internal performance measurements.</p>
59 <dl>
60 <dt><strong><a name="use_rrdp" class="item">use <strong>RRDp</strong></a></strong></dt>
62 <dd>
63 <p>Load the RRDp::pipe module.</p>
64 </dd>
65 <dt><strong><a name="rrdp_start_path_to_rrdtool_executable" class="item"><strong>RRDp::start</strong> <em>path to RRDtool executable</em></a></strong></dt>
67 <dd>
68 <p>start RRDtool. The argument must be the path to the RRDtool executable</p>
69 </dd>
70 <dt><strong><a name="rrdp_cmd_rrdtool_commandline" class="item"><strong>RRDp::cmd</strong> <em>rrdtool commandline</em></a></strong></dt>
72 <dd>
73 <p>pass commands on to RRDtool. check the RRDtool documentation for
74 more info on the RRDtool commands.</p>
75 <p><strong>Note</strong>: Due to design limitations, <strong>RRDp::cmd</strong> does not support the
76 <code>graph -</code> command - use <code>graphv -</code> instead.</p>
77 </dd>
78 <dt><strong><a name="_answer" class="item">$answer = <strong>RRDp::read</strong></a></strong></dt>
80 <dd>
81 <p>read RRDtool's response to your command. Note that the $answer variable will
82 only contain a pointer to the returned data. The reason for this is, that
83 RRDtool can potentially return quite excessive amounts of data
84 and we don't want to copy this around in memory. So when you want to 
85 access the contents of $answer you have to use $$answer which dereferences
86 the variable.</p>
87 </dd>
88 <dt><strong><a name="_status" class="item">$status = <strong>RRDp::end</strong></a></strong></dt>
90 <dd>
91 <p>terminates RRDtool and returns RRDtool's status ...</p>
92 </dd>
93 <dt><strong><a name="_rrdp__user_" class="item"><strong>$RRDp::user</strong>,  <strong>$RRDp::sys</strong>, <strong>$RRDp::real</strong></a></strong></dt>
95 <dd>
96 <p>these variables will contain totals of the user time, system time and
97 real time as seen by RRDtool.  User time is the time RRDtool is
98 running, System time is the time spend in system calls and real time
99 is the total time RRDtool has been running.</p>
100 <p>The difference between user + system and real is the time spent
101 waiting for things like the hard disk and new input from the perl
102 script.</p>
103 </dd>
104 <dt><strong><a name="_rrdp__error_mode" class="item"><strong>$RRDp::error_mode</strong> and <strong>$RRDp::error</strong></a></strong></dt>
106 <dd>
107 <p>If you set the variable $RRDp::error_mode to the value 'catch' before you run RRDp::read a potential
108 ERROR message will not cause the program to abort but will be returned in this variable. If no error
109 occurs the variable will be empty.</p>
110 <pre>
111  $RRDp::error_mode = 'catch';
112  RRDp::cmd qw(info file.rrd);
113  print $RRDp::error if $RRDp::error;</pre>
114 </dd>
115 </dl>
116 <p>
117 </p>
118 <hr />
119 <h1><a name="example">EXAMPLE</a></h1>
120 <pre>
121  use RRDp;
122  RRDp::start &quot;/usr/local/bin/rrdtool&quot;;
123  RRDp::cmd   qw(create demo.rrd --step 100 
124                DS:in:GAUGE:100:U:U
125                RRA:AVERAGE:0.5:1:10);
126  $answer = RRDp::read;
127  print $$answer;
128  ($usertime,$systemtime,$realtime) =  ($RRDp::user,$RRDp::sys,$RRDp::real);</pre>
129 <p>
130 </p>
131 <hr />
132 <h1><a name="see_also">SEE ALSO</a></h1>
133 <p>For more information on how to use RRDtool, check the manpages.</p>
134 <p>
135 </p>
136 <hr />
137 <h1><a name="author">AUTHOR</a></h1>
138 <p>Tobias Oetiker &lt;<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>&gt;</p>
140 </body>
142 </html>