Code

Imported upstream version 1.2.26
[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>
56 <dd>
57 <p>Load the RRDp::pipe module.</p>
58 </dd>
59 </li>
60 <dt><strong><a name="item_rrdp_3a_3astart_path_to_rrdtool_executable"><strong>RRDp::start</strong> <em>path to RRDtool executable</em></a></strong>
62 <dd>
63 <p>start RRDtool. The argument must be the path to the RRDtool executable</p>
64 </dd>
65 </li>
66 <dt><strong><a name="item_rrdp_3a_3acmd_rrdtool_commandline"><strong>RRDp::cmd</strong> <em>rrdtool commandline</em></a></strong>
68 <dd>
69 <p>pass commands on to RRDtool. check the RRDtool documentation for
70 more info on the RRDtool commands.</p>
71 </dd>
72 </li>
73 <dt><strong><a name="item__answer">$answer = <strong>RRDp::read</strong></a></strong>
75 <dd>
76 <p>read RRDtool's response to your command. Note that the $answer variable will
77 only contain a pointer to the returned data. The reason for this is, that
78 RRDtool can potentially return quite excessive amounts of data
79 and we don't want to copy this around in memory. So when you want to 
80 access the contents of $answer you have to use $$answer which dereferences
81 the variable.</p>
82 </dd>
83 </li>
84 <dt><strong><a name="item__status">$status = <strong>RRDp::end</strong></a></strong>
86 <dd>
87 <p>terminates RRDtool and returns RRDtool's status ...</p>
88 </dd>
89 </li>
90 <dt><strong><a name="item__rrdp__user_"><strong>$RRDp::user</strong>,  <strong>$RRDp::sys</strong>, <strong>$RRDp::real</strong></a></strong>
92 <dd>
93 <p>these variables will contain totals of the user time, system time and
94 real time as seen by RRDtool.  User time is the time RRDtool is
95 running, System time is the time spend in system calls and real time
96 is the total time RRDtool has been running.</p>
97 </dd>
98 <dd>
99 <p>The difference between user + system and real is the time spent
100 waiting for things like the hard disk and new input from the perl
101 script.</p>
102 </dd>
103 </li>
104 <dt><strong><a name="item__rrdp__error_mode"><strong>$RRDp::error_mode</strong> and <strong>$RRDp::error</strong></a></strong>
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 </dd>
111 <dd>
112 <pre>
113  $RRDp::error_mode = 'catch';
114  RRDp::cmd qw(info file.rrd);
115  print $RRDp::error if $RRDp::error;</pre>
116 </dd>
117 </li>
118 </dl>
119 <p>
120 </p>
121 <hr />
122 <h1><a name="example">EXAMPLE</a></h1>
123 <pre>
124  use RRDp;
125  RRDp::start &quot;/usr/local/bin/rrdtool&quot;;
126  RRDp::cmd   qw(create demo.rrd --step 100 
127                DS:in:GAUGE:100:U:U
128                RRA:AVERAGE:0.5:1:10);
129  $answer = RRDp::read;
130  print $$answer;
131  ($usertime,$systemtime,$realtime) =  ($RRDp::user,$RRDp::sys,$RRDp::real);</pre>
132 <p>
133 </p>
134 <hr />
135 <h1><a name="see_also">SEE ALSO</a></h1>
136 <p>For more information on how to use RRDtool, check the manpages.</p>
137 <p>
138 </p>
139 <hr />
140 <h1><a name="author">AUTHOR</a></h1>
141 <p>Tobias Oetiker &lt;<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>&gt;</p>
143 </body>
145 </html>