Code

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