247 lines
13 KiB
HTML
247 lines
13 KiB
HTML
|
|
|
|
|
|
<h1><a name="template_helper_functions" id="template_helper_functions">Template Helper Functions</a></h1>
|
|
<div class="level1">
|
|
|
|
<p>
|
|
|
|
Helper functions are meant to simplify the creation of templates and trap errors
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "Template Helper Functions" [1-123] -->
|
|
<h2><a name="rrddef" id="rrddef">rrd::def</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::def</strong> ( $vname, $rrdfile, $ds, [ $cf='AVERAGE' ] )
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">=</span> rrd<span class="sy0">::</span><span class="me2">def</span><span class="br0">(</span><span class="st_h">'var1'</span><span class="sy0">,</span> <span class="re0">$RRDFILE</span><span class="br0">[</span>0<span class="br0">]</span><span class="sy0">,</span> <span class="re0">$DS</span><span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="sy0">,</span> <span class="st_h">'MAX'</span><span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
<a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html" class="urlextern" title="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html" rel="nofollow">http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::def" [124-342] -->
|
|
<h2><a name="rrdcdef" id="rrdcdef">rrd::cdef</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::cdef</strong> ( $vname, $rpn, )
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">=</span> rrd<span class="sy0">::</span><span class="me2">cdef</span><span class="br0">(</span><span class="st_h">'var1_bits'</span><span class="sy0">,</span> <span class="st_h">'var1,8,*'</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
<a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html" class="urlextern" title="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html" rel="nofollow">http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::cdef" [343-527] -->
|
|
<h2><a name="rrdvdef" id="rrdvdef">rrd::vdef</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::vdef</strong> ( $vname, $rpn, )
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">=</span> rrd<span class="sy0">::</span><span class="me2">vdef</span><span class="br0">(</span><span class="st_h">'var1_avg'</span><span class="sy0">,</span> <span class="st_h">'var1,AVERAGE'</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
<a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html" class="urlextern" title="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html" rel="nofollow">http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::vdef" [528-715] -->
|
|
<h2><a name="rrdline_1-3" id="rrdline_1-3">rrd::line[1-3]</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::line[1-3]</strong> ( $vname, $color, [ $text ], [ $stack ] )
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">line1</span><span class="br0">(</span><span class="st_h">'var1'</span><span class="sy0">,</span> <span class="co2">#ff00ff );</span></pre>
|
|
|
|
<p>
|
|
Draws a simple line one pixel wide without label
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">line3</span><span class="br0">(</span><span class="st_h">'var1'</span><span class="sy0">,</span> <span class="st_h">'#ff00ff'</span><span class="sy0">,</span> <span class="st_h">'Load'</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
Draws a line three pixels wide with label “Load”
|
|
</p>
|
|
|
|
<p>
|
|
<a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html" class="urlextern" title="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html" rel="nofollow">http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::line[1-3]" [716-1098] -->
|
|
<h2><a name="rrdarea" id="rrdarea">rrd::area</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::area</strong> ( $vname, $color, [ $text ], [ $stack ] )
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">area</span><span class="br0">(</span><span class="st_h">'var1'</span><span class="sy0">,</span> <span class="st_h">'#ff00ff'</span><span class="sy0">,</span> <span class="st_h">'Load'</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
Draws an area with label “Load”
|
|
</p>
|
|
|
|
<p>
|
|
<a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html" class="urlextern" title="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html" rel="nofollow">http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::area" [1099-1344] -->
|
|
<h2><a name="rrdgprint" id="rrdgprint">rrd::gprint</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::gprint</strong> ( $vname, $cf, [ $text ] )
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">gprint</span><span class="br0">(</span><span class="st_h">'var1'</span><span class="sy0">,</span> <span class="st_h">'MAX'</span><span class="sy0">,</span> <span class="st_h">'%4.2lf %s Max'</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">gprint</span><span class="br0">(</span><span class="st_h">'var1'</span><span class="sy0">,</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">(</span><span class="st_h">'MIN'</span><span class="sy0">,</span> <span class="st_h">'MAX'</span><span class="sy0">,</span> <span class="st_h">'AVERAGE'</span><span class="br0">)</span><span class="sy0">,</span> <span class="st_h">'%4.2lf %s'</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
If $cf is an array the legend will be formatted automatically
|
|
</p>
|
|
|
|
<p>
|
|
<a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html" class="urlextern" title="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html" rel="nofollow">http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::gprint" [1345-1712] -->
|
|
<h2><a name="rrdcolor" id="rrdcolor">rrd::color</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::color</strong> ( $num [, $num])
|
|
</p>
|
|
|
|
<p>
|
|
Returns a color from the <acronym title="HyperText Markup Language">HTML</acronym> color table. The second (optional) argument allows to specify an alpha value used to set the transparency of the selected color.
|
|
</p>
|
|
|
|
<p>
|
|
Starting with PNP 0.6.18 the function accepts a third argument which refers to colour scheme definitions in <code>config.php</code> (or <code>config_local.php</code> which is update safe). There you can find the array $scheme[], e.g.
|
|
</p>
|
|
<pre class="code">$scheme['Reds'] = array (...)</pre>
|
|
|
|
<p>
|
|
Within the template you define
|
|
</p>
|
|
<pre class="code">$schema = $this->config->scheme['Reds'];
|
|
...
|
|
rrd::color ($key, '', $schema);</pre>
|
|
|
|
<p>
|
|
This way you select the value taken from $scheme['Reds'][$key]. If $key is not within the array or you misspelled the name (<strong>case sensitive</strong>) then the default colour palette is used.
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::color" [1713-2500] -->
|
|
<h2><a name="rrdgradient" id="rrdgradient">rrd::gradient</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::gradient</strong> ( $vname, [$start_color], [$end_color], [$label], [$steps], [$lower] )
|
|
</p>
|
|
|
|
<p>
|
|
Creates a color gradient from $start_color to $end_color
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">gradient</span><span class="br0">(</span><span class="st_h">'var1'</span><span class="sy0">,</span> <span class="st_h">'#ff0000'</span><span class="sy0">,</span> <span class="st_h">'#ffff00'</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
|
|
<a href="/templates/gradient" class="wikilink1" title="templates:gradient">Example</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::gradient" [2501-2788] -->
|
|
<h2><a name="rrdcut" id="rrdcut">rrd::cut</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::cut</strong> ( $text, $length )
|
|
</p>
|
|
<pre class="code php"><span class="re0">$label</span> <span class="sy0">=</span> rrd<span class="sy0">::</span><span class="me2">cut</span><span class="br0">(</span><span class="re0">$LABEL</span><span class="br0">[</span>0<span class="br0">]</span><span class="sy0">,</span> 18<span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
Cuts a text to a given length $length or fills it up to $length if needed.<br/>
|
|
|
|
This function is helpful if legend needs to be justified but length of label is unknown.
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::cut" [2789-3073] -->
|
|
<h2><a name="rrdticker" id="rrdticker">rrd::ticker</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::ticker</strong> ( $vname, $warning, $critical, [$fraction], [$opacity], [$color_OK], [$color_WARN], [$color_CRIT] )
|
|
</p>
|
|
|
|
<p>
|
|
Creates a colorized bar at the top of the chart which shows different colors depending on states OK, WARNING & CRITICAL
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">ticker</span><span class="br0">(</span> <span class="st0">"var1"</span><span class="sy0">,</span> <span class="re0">$WARN</span><span class="br0">[</span>0<span class="br0">]</span><span class="sy0">,</span> <span class="re0">$CRIT</span><span class="br0">[</span>0<span class="br0">]</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
|
|
<a href="/templates/ticker" class="wikilink1" title="templates:ticker">Example</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::ticker" [3074-3444] -->
|
|
<h2><a name="rrdalerter" id="rrdalerter">rrd::alerter</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::alerter</strong> ( $vname, $label, $warning, $critical, [$opacity], [$unit], [$color_OK], [$color_WARN], [$color_CRIT], [$line_col] )
|
|
</p>
|
|
|
|
<p>
|
|
Creates colorized areas, which show different colors depending on states OK, WARNING & CRITICAL
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">alerter</span><span class="br0">(</span> <span class="st0">"var1"</span><span class="sy0">,</span> <span class="re0">$LABEL</span><span class="br0">[</span>0<span class="br0">]</span><span class="sy0">,</span> <span class="re0">$WARN</span><span class="br0">[</span>0<span class="br0">]</span><span class="sy0">,</span> <span class="re0">$CRIT</span><span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="sy0">,</span> <span class="st0">"FF"</span><span class="sy0">,</span> <span class="re0">$UNIT</span><span class="br0">[</span>0<span class="br0">]</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
<a href="/templates/alerter" class="wikilink1" title="templates:alerter">Example</a>
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::alerter" [3445-3839] -->
|
|
<h2><a name="rrdalerter_gr" id="rrdalerter_gr">rrd::alerter_gr</a></h2>
|
|
<div class="level2">
|
|
|
|
<p>
|
|
|
|
string <strong>rrd::alerter_gr</strong> ( $vname, $label, $warning, $critical, [$opacity], [$unit], [$color_OK], [$color_WARN], [$color_CRIT], [$line_col], [$start_color] )
|
|
</p>
|
|
|
|
<p>
|
|
Creates colorized gradients, which show different colors depending on states OK, WARNING & CRITICAL
|
|
</p>
|
|
<pre class="code php"><span class="re0">$def</span> <span class="sy0">.=</span> rrd<span class="sy0">::</span><span class="me2">alerter_gr</span><span class="br0">(</span> <span class="st0">"var1"</span><span class="sy0">,</span> <span class="re0">$LABEL</span><span class="br0">[</span>0<span class="br0">]</span><span class="sy0">,</span> <span class="re0">$WARN</span><span class="br0">[</span>0<span class="br0">]</span><span class="sy0">,</span> <span class="re0">$CRIT</span><span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="sy0">,</span> <span class="st0">"FF"</span><span class="sy0">,</span> <span class="re0">$UNIT</span><span class="br0">[</span>0<span class="br0">]</span> <span class="br0">)</span><span class="sy0">;</span></pre>
|
|
|
|
<p>
|
|
<a href="/templates/alerter_gr" class="wikilink1" title="templates:alerter_gr">Example</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
<!-- SECTION "rrd::alerter_gr" [3840-] --> |