1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>RRDp</title>
5 <link rev="made" href="mailto:root@localhost" />
6 </head>
8 <body style="background-color: white">
10 <p><a name="__index__"></a></p>
11 <!-- INDEX BEGIN -->
12 <!--
14 <ul>
16 <li><a href="#name">NAME</a></li>
17 <li><a href="#synopsis">SYNOPSIS</a></li>
18 <li><a href="#description">DESCRIPTION</a></li>
19 <li><a href="#example">EXAMPLE</a></li>
20 <li><a href="#see_also">SEE ALSO</a></li>
21 <li><a href="#author">AUTHOR</a></li>
22 </ul>
23 -->
24 <!-- INDEX END -->
26 <p>
27 </p>
28 <h1><a name="name">NAME</a></h1>
29 <p>RRDp - Attach RRDtool from within a perl script via a set of pipes;</p>
30 <p>
31 </p>
32 <hr />
33 <h1><a name="synopsis">SYNOPSIS</a></h1>
34 <p>use <strong>RRDp</strong></p>
35 <p><strong>RRDp::start</strong> <em>path to RRDtool executable</em></p>
36 <p><strong>RRDp::cmd</strong> <em>rrdtool commandline</em></p>
37 <p>$answer = <strong>RRD::read</strong></p>
38 <p>$status = <strong>RRD::end</strong></p>
39 <p><strong>$RRDp::user</strong>, <strong>$RRDp::sys</strong>, <strong>$RRDp::real</strong>, <strong>$RRDp::error_mode</strong>, <strong>$RRDp::error</strong></p>
40 <p>
41 </p>
42 <hr />
43 <h1><a name="description">DESCRIPTION</a></h1>
44 <p>With this module you can safely communicate with the RRDtool.</p>
45 <p>After every <strong>RRDp::cmd</strong> you have to issue an <strong>RRDp::read</strong> command to get
46 <strong>RRDtool</strong>s answer to your command. The answer is returned as a pointer,
47 in order to speed things up. If the last command did not return any
48 data, <strong>RRDp::read</strong> will return an undefined variable.</p>
49 <p>If you import the PERFORMANCE variables into your namespace,
50 you can access RRDtool's internal performance measurements.</p>
51 <dl>
52 <dt><strong><a name="item_use_rrdp">use <strong>RRDp</strong></a></strong><br />
53 </dt>
54 <dd>
55 Load the RRDp::pipe module.
56 </dd>
57 <p></p>
58 <dt><strong><a name="item_rrdp_3a_3astart_path_to_rrdtool_executable"><strong>RRDp::start</strong> <em>path to RRDtool executable</em></a></strong><br />
59 </dt>
60 <dd>
61 start RRDtool. The argument must be the path to the RRDtool executable
62 </dd>
63 <p></p>
64 <dt><strong><a name="item_rrdp_3a_3acmd_rrdtool_commandline"><strong>RRDp::cmd</strong> <em>rrdtool commandline</em></a></strong><br />
65 </dt>
66 <dd>
67 pass commands on to RRDtool. check the RRDtool documentation for
68 more info on the RRDtool commands.
69 </dd>
70 <dd>
71 <p><strong>Note</strong>: Due to design limitations, <strong>RRDp::cmd</strong> does not support the
72 <code>graph -</code> command - use <code>graphv -</code> instead.</p>
73 </dd>
74 <p></p>
75 <dt><strong><a name="item__24answer__3d_rrdp_3a_3aread">$answer = <strong>RRDp::read</strong></a></strong><br />
76 </dt>
77 <dd>
78 read RRDtool's response to your command. Note that the $answer variable will
79 only contain a pointer to the returned data. The reason for this is, that
80 RRDtool can potentially return quite excessive amounts of data
81 and we don't want to copy this around in memory. So when you want to
82 access the contents of $answer you have to use $$answer which dereferences
83 the variable.
84 </dd>
85 <p></p>
86 <dt><strong><a name="item__24status__3d_rrdp_3a_3aend">$status = <strong>RRDp::end</strong></a></strong><br />
87 </dt>
88 <dd>
89 terminates RRDtool and returns RRDtool's status ...
90 </dd>
91 <p></p>
92 <dt><strong><a name="item__24rrdp_3a_3auser_2c__24rrdp_3a_3asys_2c__24rrdp_3"><strong>$RRDp::user</strong>, <strong>$RRDp::sys</strong>, <strong>$RRDp::real</strong></a></strong><br />
93 </dt>
94 <dd>
95 these variables will contain totals of the user time, system time and
96 real time as seen by RRDtool. User time is the time RRDtool is
97 running, System time is the time spend in system calls and real time
98 is the total time RRDtool has been running.
99 </dd>
100 <dd>
101 <p>The difference between user + system and real is the time spent
102 waiting for things like the hard disk and new input from the perl
103 script.</p>
104 </dd>
105 <p></p>
106 <dt><strong><a name="item__24rrdp_3a_3aerror_mode_and__24rrdp_3a_3aerror"><strong>$RRDp::error_mode</strong> and <strong>$RRDp::error</strong></a></strong><br />
107 </dt>
108 <dd>
109 If you set the variable $RRDp::error_mode to the value 'catch' before you run RRDp::read a potential
110 ERROR message will not cause the program to abort but will be returned in this variable. If no error
111 occurs the variable will be empty.
112 </dd>
113 <dd>
114 <pre>
115 $RRDp::error_mode = 'catch';
116 RRDp::cmd qw(info file.rrd);
117 print $RRDp::error if $RRDp::error;</pre>
118 </dd>
119 <p></p></dl>
120 <p>
121 </p>
122 <hr />
123 <h1><a name="example">EXAMPLE</a></h1>
124 <pre>
125 use RRDp;
126 RRDp::start "/usr/local/bin/rrdtool";
127 RRDp::cmd qw(create demo.rrd --step 100
128 DS:in:GAUGE:100:U:U
129 RRA:AVERAGE:0.5:1:10);
130 $answer = RRDp::read;
131 print $$answer;
132 ($usertime,$systemtime,$realtime) = ($RRDp::user,$RRDp::sys,$RRDp::real);</pre>
133 <p>
134 </p>
135 <hr />
136 <h1><a name="see_also">SEE ALSO</a></h1>
137 <p>For more information on how to use RRDtool, check the manpages.</p>
138 <p>
139 </p>
140 <hr />
141 <h1><a name="author">AUTHOR</a></h1>
142 <p>Tobias Oetiker <<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>></p>
144 </body>
146 </html>