<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Piece of Unix Hints &#187; RRDTool</title>
	<atom:link href="http://hints.jeb.be/tag/rrdtool/feed/" rel="self" type="application/rss+xml" />
	<link>http://hints.jeb.be</link>
	<description>hints.jeb.be</description>
	<lastBuildDate>Fri, 04 Dec 2009 20:35:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Trend / Prediction with RRDtool</title>
		<link>http://hints.jeb.be/2009/12/04/trend-prediction-with-rrdtool/</link>
		<comments>http://hints.jeb.be/2009/12/04/trend-prediction-with-rrdtool/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 20:33:12 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[RRDTool]]></category>
		<category><![CDATA[Trend]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=58</guid>
		<description><![CDATA[I&#8217;ve not used RRDtool for a while and put back my attention on it few weeks ago. I found out that lots of new cool stuff are avalaible, like LSLSLOPE, LSLINT. These function return the parameters of the Least Squares Line (y = ax +b) approximating a dataset (LSLSLOPE return a, LSLINT return b). This [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve not used <a href="http://oss.oetiker.ch/rrdtool/" onclick="pageTracker._trackPageview('/outgoing/oss.oetiker.ch/rrdtool/?referer=');">RRDtool</a> for a while and put back my attention on it few weeks ago. I found out that lots of new cool stuff are avalaible, like <a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html" onclick="pageTracker._trackPageview('/outgoing/oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html?referer=');">LSLSLOPE, LSLINT</a>. These function return the parameters of the Least Squares Line (y = ax +b) approximating a dataset (LSLSLOPE return a, LSLINT return b).<br />
This is interesting because with the function approximating your data you can graph a prediction of future data. Of course a Least Squares Line function will work best to approximate a dataset that tend to grow or shrink (like filesystem usage, memory usage, &#8230;) but not for data like temperature. I would say that if your data can be expressed in a percentage, an Least Squares Line can be fine. For data not tending to grow or shrink rrdtool provide some other function like <a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html" onclick="pageTracker._trackPageview('/outgoing/oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html?referer=');">TREND and PREDICT</a>.</p>
<p>I will show how to use LSLSLOPE and LSLINT taking memory usage of a device as an example. My exemple will produce a graph like the following :<br />
<img class="alignnone size-full wp-image-59" title="MemoryTrend" src="http://hints.jeb.be/wp-content/uploads/2009/11/MemoryTrend.png" alt="MemoryTrend" /></p>
<p>As you see, the graph show trend using two Least Squares Line function, one generated from the full dataset (dataset is starting 24 Oct 2009) and one generated only from last week data. Projection on time axis is done from 90% to 100% of memory usage and the date resulting of calculation for 90% and 100% of usage is displayed. I&#8217;ve seen lots of question asking how to do this but did not found any answer, so I hope that my example will provide an answer.</p>
<p>Here is the perl code I&#8217;m using to generate this graph. There is no Perl specific code, so it can be converted to a normal rrdtool command.</p>
<pre>#! /usr/bin/perl
use RRDs;

$rrd_file = 'MEMORY.rrd';

RRDs::graph "MEMORY_Trend.png",
'--start', "10/24/2009",
'--end', "12/31/2009 00:00am",
'--title', "Memory Usage",
'--interlace', '--width=620', '--height=200',
"--color","ARROW#009900",
'--vertical-label', "Memory used (%)",
'--lower-limit', '0',
'--upper-limit', '100',
'--border','0',
'--rigid',

"DEF:used1=$rrd_file:used:AVERAGE",
"DEF:used2=$rrd_file:used:AVERAGE:start=10/24/2009",
"DEF:used3=$rrd_file:used:AVERAGE:start=-1w",
"DEF:used4=$rrd_file:used:AVERAGE:start=-2w",
"DEF:used5=$rrd_file:used:AVERAGE:start=-4w",
"DEF:free1=$rrd_file:free:AVERAGE",
"DEF:free2=$rrd_file:free:AVERAGE:start=10/24/2009",
"DEF:free3=$rrd_file:free:AVERAGE:start=-1w",
"DEF:free4=$rrd_file:free:AVERAGE:start=-2w",
"DEF:free5=$rrd_file:free:AVERAGE:start=-4w",

"CDEF:pused1=used1,100,*,used1,free1,+,/",
"CDEF:pused2=used2,100,*,used2,free2,+,/",
"CDEF:pused3=used3,100,*,used3,free3,+,/",
"CDEF:pused4=used4,100,*,used4,free4,+,/",
"CDEF:pused5=used5,100,*,used5,free5,+,/",

"HRULE:100#FF000044",
"HRULE:99.5#FF000044",
"HRULE:99#FF000044",
"HRULE:98.5#FF000044",
"HRULE:98#FF000044",
"HRULE:97.5#FF000044",
"HRULE:97#FF000044",
"HRULE:96.5#FF000044",
"HRULE:96#FF000044",
"HRULE:95.5#FF000044",
"HRULE:95#FF000044",
"HRULE:94.5#FF000022",
"HRULE:94#FF000022",
"HRULE:93.5#FF000022",
"HRULE:93#FF000022",
"HRULE:92.5#FF000022",
"HRULE:92#FF000022",
"HRULE:91.5#FF000022",
"HRULE:91#FF000022",
"HRULE:90.5#FF000022",
"HRULE:90#FF000022",

"COMMENT:                         Now          Min             Avg             Max\\n",
"AREA:pused1#00880077:Memory Used",
'GPRINT:pused1:LAST:%12.0lf%s',
'GPRINT:pused1:MIN:%10.0lf%s',
'GPRINT:pused1:AVERAGE:%13.0lf%s',
'GPRINT:pused1:MAX:%13.0lf%s' . "\\n",
"COMMENT: \\n",

'VDEF:D2=pused2,LSLSLOPE',
'VDEF:H2=pused2,LSLINT',
'CDEF:avg2=pused2,POP,D2,COUNT,*,H2,+',
'CDEF:abc2=avg2,90,100,LIMIT',
'VDEF:minabc2=abc2,FIRST',
'VDEF:maxabc2=abc2,LAST',

'VDEF:D3=pused3,LSLSLOPE',
'VDEF:H3=pused3,LSLINT',
'CDEF:avg3=pused3,POP,D3,COUNT,*,H3,+',
'CDEF:abc3=avg3,90,100,LIMIT',
'VDEF:minabc3=abc3,FIRST',
'VDEF:maxabc3=abc3,LAST',

"AREA:abc2#FFBB0077",
"AREA:abc3#0077FF77",
"LINE2:abc2#FFBB00",
"LINE2:abc3#0077FF",

"LINE1:avg2#FFBB00:Trend since 24 Oct 2009                      :dashes=10",
"LINE1:avg3#0077FF:Trend since 1 week\\n:dashes=10",
"GPRINT:minabc2:  Reach  90% @ %c :strftime",
"GPRINT:minabc3:  Reach  90% @ %c \\n:strftime",
"GPRINT:maxabc2:  Reach 100% @ %c :strftime",
"GPRINT:maxabc3:  Reach 100% @ %c \\n:strftime",

;

my $ERR=RRDs::error;
die "ERROR : $ERR" if $ERR;</pre>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2009/12/04/trend-prediction-with-rrdtool/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Getting human reading time info from RRD files</title>
		<link>http://hints.jeb.be/2008/12/17/getting-human-reading-time-info-from-rrd-files/</link>
		<comments>http://hints.jeb.be/2008/12/17/getting-human-reading-time-info-from-rrd-files/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:49:59 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[RRDTool]]></category>
		<category><![CDATA[Humain Reading]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=36</guid>
		<description><![CDATA[You have a .rrd file but you don&#8217;t remember how much time RRAs can store data ? all right, no problem. First save this Perl code into a .pl file. $step = $1 if (m/step = (\d+)/); $rows = $1 if (m/rra.*\.rows = (\d+)/); if (m/(.*)\.pdp_per_row = (\d+)/) { $pdp = $2; $time = $step*$rows*$pdp; [...]]]></description>
			<content:encoded><![CDATA[<p>You have a .rrd file but you don&#8217;t remember how much time RRAs can store data ? all right, no problem.</p>
<p>First save this Perl code into a .pl file.</p>
<blockquote><p><code>$step = $1 if (m/step = (\d+)/);<br />
$rows = $1 if (m/rra.*\.rows = (\d+)/);<br />
if (m/(.*)\.pdp_per_row = (\d+)/) {<br />
$pdp = $2; $time = $step*$rows*$pdp;<br />
if ($time &gt; 31536000) { $time = sprintf("%.2f year",$time/31536000) }<br />
elsif ($time &gt; 86400) { $time = sprintf("%.2f days",$time/86400) }<br />
elsif ($time &gt; 3600)  { $time = sprintf("%.2f hours",$time/3600) }<br />
print "$1: $step*$rows*$pdp = $time\n";<br />
}</code></p></blockquote>
<p>Assuming the filename of the script is rrd_info.pl, run this Shell command:</p>
<blockquote><p><code>rrdtool info file.rrd | perl -n rrd_info.pl</code></p></blockquote>
<p>Here is an output example:</p>
<pre>rra[0]: 300*864*1 = 3.00 days
rra[1]: 300*864*5 = 15.00 days
rra[2]: 300*702*25 = 60.94 days
rra[3]: 300*840*125 = 364.58 days
rra[4]: 300*840*625 = 4.99 year
rra[5]: 300*864*1 = 3.00 days
rra[6]: 300*864*5 = 15.00 days
rra[7]: 300*702*25 = 60.94 days
rra[8]: 300*840*125 = 364.58 days
rra[9]: 300*840*625 = 4.99 year
rra[10]: 300*864*1 = 3.00 days
rra[11]: 300*864*5 = 15.00 days
rra[12]: 300*702*25 = 60.94 days
rra[13]: 300*840*125 = 364.58 days
rra[14]: 300*840*625 = 4.99 year</pre>
<p>The formula is update step time * numbers of rows in the rra * pdp_per_row</p>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/getting-human-reading-time-info-from-rrd-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counter reset problem with RRDTool</title>
		<link>http://hints.jeb.be/2008/12/17/counter-reset-problem-with-rrdtool/</link>
		<comments>http://hints.jeb.be/2008/12/17/counter-reset-problem-with-rrdtool/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:44:41 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[RRDTool]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=26</guid>
		<description><![CDATA[A common problem with rrdtool is to have a rrd file with one or more datasource configured as COUNTER, but your counter reset and you get an ugly high peak. There is 2 solutions to solve this In the &#8220;script&#8221; you use to generate the graph file you have something like DEF:A=/path/to/your/file.rrd:dsname:AVERAGE to get data, [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem with rrdtool is to have a rrd file with one or more datasource configured as COUNTER, but your counter reset and you get an ugly high peak.</p>
<p>There is 2 solutions to solve this</p>
<ul>
<li> In the &#8220;script&#8221; you use to generate the graph file you have something like <code>DEF:A=/path/to/your/file.rrd:dsname:AVERAGE</code> to get data, then you graph it with something like LINE1:A#&#8230;..<br />
Try to add <code>CDEF:B=A,MINVALUE,GT,A,MAXVALUE,LT,A,UNKN,IF,UNKN,IF</code> and graph B instead of A.<br />
Replace MINVALUE with the minimun value you want to graph (typically 0) and MAXVALUE with the maximum value you want on the graph (100000000 or something like this).<br />
This will suppress ugly peak on the graph.</li>
</ul>
<ul>
<li>The second (better) solution is to change from COUNTER DS to DERIVE DS, to do so follow theses commands:<br />
<code># cp file.rrd file.rrd.bkup # this is to backup the file !<br />
# rrdtool tune file.rrd<br />
# rrdtool tune file.rrd --data-source-type dsname:DERIVE # this change DS dsname from COUNTER to DERIVE<br />
# rrdtool tune file.rrd --minimum dsname:0 --maximum dsname:100000000 # Set the min and max value of data you have to graph<br />
# rrdtool tune file.rrd<br />
# rrdtool dump file.rrd &gt; file.xml # Dump data to xml file<br />
# rrdtool restore -r file.xml file.rrd.new # This restore xml data in rrd file with a check on value<br />
# to suppress value higher than --maximum you choose</code></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/counter-reset-problem-with-rrdtool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
