<?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>Circles of Archimedes</title>
	<atom:link href="http://wiki.springsurprise.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://wiki.springsurprise.com</link>
	<description>Technical scribbles in the sand</description>
	<lastBuildDate>Mon, 24 Oct 2011 01:00:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Graphing Running Averages in RRDTool</title>
		<link>http://wiki.springsurprise.com/2011/10/23/graphing-running-averages-in-rrdtool/</link>
		<comments>http://wiki.springsurprise.com/2011/10/23/graphing-running-averages-in-rrdtool/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 01:00:15 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Graphing Solutions]]></category>
		<category><![CDATA[Server Solutions]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[rrd tool]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=598</guid>
		<description><![CDATA[There are a number of times where the data collected may appear so erratic that it is difficult to identify any trends.  While use of a VDEF can provide a gross average of a data set, it doesn&#8217;t provide the &#8230; <a href="http://wiki.springsurprise.com/2011/10/23/graphing-running-averages-in-rrdtool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are a number of times where the data collected may appear so erratic that it is difficult to identify any trends.  While use of a VDEF can provide a gross average of a data set, it doesn&#8217;t provide the utility of a true running average.  The running average can provide a consistent calculation regardless as to the time scale displayed in the graph.  Fortunately, <a href="http://oss.oetiker.ch/rrdtool/index.en.html">RRDTool</a> provides a flexible means via its TREND operator for calculating a running average to address this need.</p>
<p>To begin, setup a chart that graphs the desired data in a typical manner before adding in the running average.  The following graph command creates a somewhat typical visualization of the last day&#8217;s network traffic as illustrated by the following graph:</p>
<pre>rrdtool graph example.png \
  --title "Network Traffic" \
  --width=500 \
  --slope-mode \
  --end=now \
  --start=end-24h \
  --base=1000 \
  DEF:bytesIn=network.rrd:bytesIn:AVERAGE \
  DEF:bytesOut=network.rrd:bytesOut:AVERAGE \
  CDEF:bpsIn=bytesIn,8,* \
  CDEF:bpsOut=bytesOut,8,* \
  CDEF:bpsOutNeg=bpsOut,-1,* \
  VDEF:bpsInTot=bpsIn,TOTAL \
  VDEF:bpsOutTot=bpsOut,TOTAL \
  COMMENT:"              current     min        max      total\n" \
  AREA:bpsIn#FF880044:"Bits/s In " \
  GPRINT:bpsIn:LAST:"%6.1lf%s\t" \
  GPRINT:bpsIn:MIN:"%6.1lf%s\t" \
  GPRINT:bpsIn:MAX:"%6.1lf%s\t" \
  GPRINT:bpsInTot:"%6.1lf%s\n" \
  LINE1:bpsIn#FF8800CC \
  AREA:bpsOutNeg#44C80044:"Bits/s Out" \
  GPRINT:bpsOut:LAST:"%6.1lf%s\t" \
  GPRINT:bpsOut:MIN:"%6.1lf%s\t" \
  GPRINT:bpsOut:MAX:"%6.1lf%s\t" \
  GPRINT:bpsOutTot:"%6.1lf%s\n" \
  LINE1:bpsOutNeg#44C800CC \
  HRULE:0#000000</pre>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-11.png"><img class="aligncenter size-full wp-image-599" title="Example 1" src="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-11.png" alt="" width="581" height="201" /></a>With the basic graph setup, adding the elements necessary for the running average can now begin.  In this example, it appears there is a roughly hourly cycle (Time Machine backups) that defines the period so a reasonable start is to work with a minimum average calculated over 60 minutes.</p>
<p>First, additional CDEF statements need to be declared applying the TREND operator to the desired data.  The format for this operation is straightforward:</p>
<p style="text-align: center;"><code>CDEF:label=data_source,time_span,TREND</code></p>
<p>In this case, two new data sources are defined and are given the labels <code>bspInTrend</code> and <code>bpsOutTrendNeg</code>.  The data sources for these are the previously declared <code>bpsIn</code> and <code>bpsOutNeg</code> and the time span for them is 1 hour (3600 seconds).</p>
<pre>  CDEF:bpsInTrend=bpsIn,3600,TREND \
  CDEF:bpsOutTrendNeg=bpsOutNeg,3600,TREND \</pre>
<p>With the running averages now defined, it is possible to graph the data.  For the purposes of this example, the running average is graphed as a &#8220;shadow&#8221; on top of the base data.</p>
<pre>  LINE2:bpsInTrend#000000CC \
  LINE2:bpsOutTrendNeg#000000CC \</pre>
<p>The graph shown below illustrates the new running averages.</p>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-21.png"><img class="aligncenter size-full wp-image-602" title="Example 2" src="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-21.png" alt="" width="581" height="201" /></a>The running averages are now shown and it illustrates that despite the hourly peaks, the overall trend is fairly flat with the slight exception around 00:15.  However, the running averages also show a gap at the beginning of the graph. This gap is because it takes an hour of data before the hourly running average can be computed.  While this may be acceptable, it doesn&#8217;t look polished.</p>
<p>A minor tweak of the original DEF statements can provide &#8220;padding&#8221; necessary to eliminate the displayed gap in the running average lines.  This can be accomplished by extending the start time of the data sources by at least the same duration specified in the running averages.  Note that the <em>display area</em> is not affected by altering the start time of the DEF statements &#8212; that is controlled by the <code>--start</code> and <code>--end</code> options.  For the example data, the DEF statements need to extend the range of the data set by 1 hour so as to encompass 25 hours instead of the display area&#8217;s 24 hours:</p>
<pre>  DEF:bytesIn=network.rrd:bytesIn:AVERAGE:start=end-25h \
  DEF:bytesOut=network.rrd:bytesOut:AVERAGE:start=end-25h \</pre>
<p>Putting it together, the following command will pull in all the data necessary to calculate a running average for the extent of the display area, calculate the running averages, and display the results:</p>
<pre>rrdtool graph example.png \
  --title "Network Traffic" \
  --width=500 \
  --slope-mode \
  --end=now \
  --start=end-24h \
  --base=1000 \
  DEF:bytesIn=network.rrd:bytesIn:AVERAGE:start=end-25h \
  DEF:bytesOut=network.rrd:bytesOut:AVERAGE:start=end-25h \
  CDEF:bpsIn=bytesIn,8,* \
  CDEF:bpsOut=bytesOut,8,* \
  CDEF:bpsOutNeg=bpsOut,-1,* \
  CDEF:bpsInTrend=bpsIn,3600,TREND \
  CDEF:bpsOutTrendNeg=bpsOutNeg,3600,TREND \
  VDEF:bpsInTot=bpsIn,TOTAL \
  VDEF:bpsOutTot=bpsOut,TOTAL \
  COMMENT:"              current     min        max      total\n" \
  AREA:bpsIn#FF880044:"Bits/s In " \
  GPRINT:bpsIn:LAST:"%6.1lf%s\t" \
  GPRINT:bpsIn:MIN:"%6.1lf%s\t" \
  GPRINT:bpsIn:MAX:"%6.1lf%s\t" \
  GPRINT:bpsInTot:"%6.1lf%s\n" \
  LINE1:bpsIn#FF8800CC \
  AREA:bpsOutNeg#44C80044:"Bits/s Out" \
  GPRINT:bpsOut:LAST:"%6.1lf%s\t" \
  GPRINT:bpsOut:MIN:"%6.1lf%s\t" \
  GPRINT:bpsOut:MAX:"%6.1lf%s\t" \
  GPRINT:bpsOutTot:"%6.1lf%s\n" \
  LINE1:bpsOutNeg#44C800CC \
  LINE2:bpsInTrend#000000CC \
  LINE2:bpsOutTrendNeg#000000CC \
  HRULE:0#000000</pre>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-3.png"><img class="aligncenter size-full wp-image-603" title="Example 3" src="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-3.png" alt="" width="581" height="201" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2011/10/23/graphing-running-averages-in-rrdtool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Graphing Time Shifted Data in RRDTool</title>
		<link>http://wiki.springsurprise.com/2011/10/20/graphing-time-shifted-data-in-rrdtool/</link>
		<comments>http://wiki.springsurprise.com/2011/10/20/graphing-time-shifted-data-in-rrdtool/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 07:38:48 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Graphing Solutions]]></category>
		<category><![CDATA[Server Solutions]]></category>
		<category><![CDATA[Technical Tidbits]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[rrd tool]]></category>
		<category><![CDATA[rrdtool]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=586</guid>
		<description><![CDATA[While visualizing performance or activity data using a well-designed chart can be useful, it is frequently desired to be able to compare recent performance against an earlier period of time.  Comparisons against historic data help identify changes in trends or &#8230; <a href="http://wiki.springsurprise.com/2011/10/20/graphing-time-shifted-data-in-rrdtool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While visualizing performance or activity data using a well-designed chart can be useful, it is frequently desired to be able to compare recent performance against an earlier period of time.  Comparisons against historic data help identify changes in trends or other anomalous performance behaviors.  In some cases, this can be done simply by extending the time span of the graph.  However, expansion of the graphed time span can lead to either an unacceptable loss of resolution or an unacceptably large image.  Fortunately, <a href="http://oss.oetiker.ch/rrdtool/index.en.html">RRDTool</a> can make this type of comparison chart fairly easily without resulting in a loss of fidelity or unwieldy image size.</p>
<p>To begin, it helps to setup a chart that graphs the desired data in a typical manner before adding in the time shifted overlays.  The following graph command creates a somewhat typical visualization of the last hour&#8217;s network traffic as illustrated by Example 1 graph:</p>
<pre>rrdtool graph example.png \
  --title "Network Traffic" \
  --width=500 \
  --slope-mode \
  --end=now \
  --start=end-1h \
  --base=1000 \
  DEF:bytesIn=network.rrd:bytesIn:AVERAGE \
  DEF:bytesOut=network.rrd:bytesOut:AVERAGE \
  CDEF:bpsIn=bytesIn,8,* \
  CDEF:bpsOut=bytesOut,8,* \
  CDEF:bpsOutNeg=bpsOut,-1,* \
  VDEF:bpsInTot=bpsIn,TOTAL \
  VDEF:bpsOutTot=bpsOut,TOTAL \
  COMMENT:"            current     min        max      total\n" \
  AREA:bpsIn#FF880044:"Bits/s In " \
  GPRINT:bpsIn:LAST:"%6.1lf%s\t" \
  GPRINT:bpsIn:MIN:"%6.1lf%s\t" \
  GPRINT:bpsIn:MAX:"%6.1lf%s\t" \
  GPRINT:bpsInTot:"%6.1lf%s\n" \
  LINE1:bpsIn#FF8800CC \
  AREA:bpsOutNeg#44C80044:"Bits/s Out" \
  GPRINT:bpsOut:LAST:"%6.1lf%s\t" \
  GPRINT:bpsOut:MIN:"%6.1lf%s\t" \
  GPRINT:bpsOut:MAX:"%6.1lf%s\t" \
  GPRINT:bpsOutTot:"%6.1lf%s\n" \
  LINE1:bpsOutNeg#44C800CC \
  HRULE:0#000000</pre>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-1.png"><img class="aligncenter size-full wp-image-587" title="Example 1" src="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-1.png" alt="" width="581" height="201" /></a>With the basic chart setup as desired, now the command can be modified to support a time shifted overlay.</p>
<p>First, additional DEF statements need to be defined for time range <em>for the source data</em> to encompass the time span desired for comparison.  Note that this is <em>not</em> the same as the graph&#8217;s display range; those options (<code>--start</code> and <code>--end</code>) should remain unchanged.  The override start time should extend the time frame to the start of the time shifted data.  For example, the following would be suitable for comparison of the previous 1 hour:</p>
<pre>  DEF:bytesInPrevHour=network.rrd:bytesIn:AVERAGE:start=end-2h \
  DEF:bytesOutPrevHour=network.rrd:bytesOut:AVERAGE:start=end-2h \</pre>
<p>As another example, the following would be suitable for a comparison of the same hour, 1 day (24 hours) ago:</p>
<pre>  DEF:bytesInPrevDay=network.rrd:bytesIn:AVERAGE:start=end-25h \
  DEF:bytesOutPrevDay=network.rrd:bytesOut:AVERAGE:start=end-25h \</pre>
<p>Next, a new SHIFT statement needs to be introduced that shifts the data being displayed by the specified number of seconds.  The SHIFT statements must be specified <em>after</em> the DEF statements they are shifting.  The following statements would shift the newly inserted DEF statements by 1 hour (3600 seconds):</p>
<pre>  SHIFT:bytesInPrevHour:3600 \
  SHIFT:bytesOutPrevHour:3600 \</pre>
<p>Next, the CDEF and VDEF operations need to be supplied in order to transform the new data in a consistent manner with the original data.</p>
<pre>  CDEF:bpsInPrev=bytesInPrevHour,8,* \
  CDEF:bpsOutPrev=bytesOutInPrevHour,8,* \
  CDEF:bpsOutPrevNeg=bpsOutPrev,-1,* \</pre>
<p>Finally, the new elements are ready for graphing.  Care should be made to ensure the shifted data is displayed in a distinct manner from the current data so as to prevent visual confusion or obscuring the current data.</p>
<pre>  LINE1:bpsInPrev#00000088 \ 
  LINE1:bpsOutPrevNeg#00000088 \</pre>
<p>Pulling it all together, the following command will pull in the data from the extended time frame, shift it forward by the appropriate amount of time so that it aligns with the displayed time frame, perform the desired transformation options, and finally display the results:</p>
<pre>rrdtool graph example.png \
  --title "Network Traffic" \
  --width=500 \
  --slope-mode \
  --end=now \
  --start=end-1h \
  --base=1000 \
  DEF:bytesIn=network.rrd:bytesIn:AVERAGE \
  DEF:bytesOut=network.rrd:bytesOut:AVERAGE \
  DEF:bytesInPrevHour=network.rrd:bytesIn:AVERAGE:start=end-2h \
  DEF:bytesOutPrevHour=network.rrd:bytesOut:AVERAGE:start=end-2h \
  SHIFT:bytesInPrevHour:3600 \
  SHIFT:bytesOutPrevHour:3600 \
  CDEF:bpsIn=bytesIn,8,* \
  CDEF:bpsOut=bytesOut,8,* \
  CDEF:bpsOutNeg=bpsOut,-1,* \
  CDEF:bpsInPrev=bytesInPrevHour,8,* \
  CDEF:bpsOutPrev=bytesOutInPrevHour,8,* \
  CDEF:bpsOutPrevNeg=bpsOutPrev,-1,* \
  VDEF:bpsInTot=bpsIn,TOTAL \
  VDEF:bpsOutTot=bpsOut,TOTAL \
  COMMENT:"            current     min        max      total\n" \
  AREA:bpsIn#FF880044:"Bits/s In " \
  GPRINT:bpsIn:LAST:"%6.1lf%s\t" \
  GPRINT:bpsIn:MIN:"%6.1lf%s\t" \
  GPRINT:bpsIn:MAX:"%6.1lf%s\t" \
  GPRINT:bpsInTot:"%6.1lf%s\n" \
  LINE1:bpsIn#FF8800CC \
  AREA:bpsOutNeg#44C80044:"Bits/s Out" \
  GPRINT:bpsOut:LAST:"%6.1lf%s\t" \
  GPRINT:bpsOut:MIN:"%6.1lf%s\t" \
  GPRINT:bpsOut:MAX:"%6.1lf%s\t" \
  GPRINT:bpsOutTot:"%6.1lf%s\n" \
  LINE1:bpsOutNeg#44C800CC \
  LINE1:bpsInPrev#00000088 \ 
  LINE1:bpsOutPrevNeg#00000088 \
  HRULE:0#000000</pre>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-2.png"><img class="aligncenter size-full wp-image-590" title="Example 2" src="http://wiki.springsurprise.com/wp-content/uploads/2011/10/Example-2.png" alt="" width="581" height="201" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2011/10/20/graphing-time-shifted-data-in-rrdtool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enabling DNS statistics for Mac OS X Server</title>
		<link>http://wiki.springsurprise.com/2011/10/17/enabling-dns-statistics-for-mac-os-x-server/</link>
		<comments>http://wiki.springsurprise.com/2011/10/17/enabling-dns-statistics-for-mac-os-x-server/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 07:06:58 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Server Solutions]]></category>
		<category><![CDATA[Technical Tidbits]]></category>
		<category><![CDATA[leopard server]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=577</guid>
		<description><![CDATA[The DNS server is an essential service for the smooth operations of any site, but there is little insight into how it is being used or its operational health presented in the Apple Server Admin tool.  Thankfully, Apple uses the &#8230; <a href="http://wiki.springsurprise.com/2011/10/17/enabling-dns-statistics-for-mac-os-x-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The DNS server is an essential service for the smooth operations of any site, but there is little insight into how it is being used or its operational health presented in the Apple Server Admin tool.  Thankfully, Apple uses the standard <a href="http://www.bind9.net/">bind9</a> utility as the underlying implementation for the DNS service and this can provide a great deal of statistics for analysis.  Unfortunately, the statistics are currently disabled in the default installation and there is no means to enable them using the Server Admin tool but it is relatively straight-forward to edit a couple configuration files in order to unleash this capability.</p>
<p>First, the <code>/etc/named.conf</code> file needs to be modified to specify both the statistics file and the appropriate control mechanisms.  As this is an essential configuration file, create a backup copy of the existing (working) file before editing in case something goes wrong.</p>
<p>In the <code>named.conf</code> file, ensure that there is an configuration block for the &#8220;controls&#8221;.  By default, it should already be present and look similar to the following:</p>
<pre>controls  {
        inet 127.0.0.1 port 54 allow    {any;   }
        keys    { "rndc-key";    };
   };</pre>
<p>This section defines the access control for the stats tool (among other things).  The essential elements for this purpose is that it defines the communications port as port 54 and it uses the key identified as &#8220;rndc-key&#8221; as its security token.  The key is actually defined in a separate file and read into the configuration via the <code>include "/etc/rndc.key"</code> statement earlier in the <code>named.conf</code> file.</p>
<p>There should also be a configuration block for the &#8220;options&#8221;.  A typical installation will look like the following:</p>
<pre>options  {
        include "/etc/dns/options.conf.apple";
                /*
         * If there is a firewall between you and nameservers you want
         * to talk to, you might need to uncomment the query-source
         * directive below.  Previous versions of BIND always asked
         * questions using port 53, but BIND 8.1 uses an unprivileged
         * port by default.
         */
        // query-source address * port 53;
   };</pre>
<p>This section requires some minor modification to specify the stats file.  In the block, insert a line specifying <code>statistics-file "/full/path/to/the/named.stats";</code>.  It is best to make the addition <em>after</em> the include statement so that the edited result looks similar to the following:</p>
<pre>options  {
        include "/etc/dns/options.conf.apple";

        // Addition to enable statistics
        statistics-file "/var/log/named.stats";

                /*
         * If there is a firewall between you and nameservers you want
         * to talk to, you might need to uncomment the query-source
         * directive below.  Previous versions of BIND always asked
         * questions using port 53, but BIND 8.1 uses an unprivileged
         * port by default.
         */
        // query-source address * port 53;
   };</pre>
<p>After the <code>named.conf</code> file has been configured properly, a new file must created for the configuration of the rndc utility.  Create the <code>/etc/rndc.conf</code> file and edit it with the following settings:</p>
<pre>include "/etc/rndc.key";

options {
    default-key "rndc-key";
    default-server localhost;
    default-port 54;
};</pre>
<p>The include statement <em>must</em> match the same included file specified in the <code>named.conf</code> file as the security key (&#8220;rndc-key&#8221;) must match or the <a href="http://www.manpagez.com/man/8/rndc/">rndc</a> utility used to trigger the stats dump will not be authorized to connect.  The options block specifies the key name and the default server and port.  The assumption here is that the rndc tool will be run on the same host (localhost) as the DNS server.  The port should match the port specified in the controls block of the <code>named.conf</code> file.</p>
<p>At this point, the named daemon can be safely signaled to pick up the configuration changes.  This can be done easily via the Server Admin tool by restarting the DNS service or, for the more advanced sysadmin, a SIGHUP can be sent to the process.</p>
<p>To trigger a stats dump, simply call the <code>rndc stats</code> and look for the stats file specified in the <code>named.conf</code> file.  If the file isn&#8217;t found, there may be a authorization issue:  try running the command as an administrator or call the command via <a href="http://www.manpagez.com/man/8/sudo/">sudo</a> (e.g. <code>sudo rndc stats</code>).</p>
<p>The stats can be triggered on an ongoing basis by specifying an appropriate entry for the <a href="http://www.manpagez.com/man/8/launchd/">launchd</a> system.  A simple plist formatted file located in <code>/Library/LaunchDaemons</code> can serve to repeatedly call the stats file for ongoing monitoring.  (See <a href="http://wiki.springsurprise.com/2009/06/22/mac-os-x-launchd-tips-tricks/">launchd tips and tricks</a> for more information.)</p>
<p>The following example would be named <code>com.hostname.namedstats.plist</code> and specifies that the stats should be generated every 5 minutes (300 seconds).</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.hostname.namedstats&lt;/string&gt;
    &lt;key&gt;StartInterval&lt;/key&gt;
    &lt;integer&gt;300&lt;/integer&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/sbin/rndc&lt;/string&gt;
        &lt;string&gt;stats&lt;/string&gt;
    &lt;/array&gt;
&lt;/dict&gt;
&lt;/plist&gt;</pre>
<p>Note that every time the stats are generated they are appended to the existing file which can quickly result in a very large, unwieldy file.  If recurring stats are desired, then ensuring the stats file is <a href="http://wiki.springsurprise.com/2011/10/15/automatic-log-rotation-in-mac-os-x/">periodically rotated</a> is essential.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2011/10/17/enabling-dns-statistics-for-mac-os-x-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic Log Rotation in Mac OS X</title>
		<link>http://wiki.springsurprise.com/2011/10/15/automatic-log-rotation-in-mac-os-x/</link>
		<comments>http://wiki.springsurprise.com/2011/10/15/automatic-log-rotation-in-mac-os-x/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 07:44:39 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Server Solutions]]></category>
		<category><![CDATA[Technical Tidbits]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[log rotation]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[logrotate]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[newsyslog]]></category>
		<category><![CDATA[newsyslog.conf]]></category>
		<category><![CDATA[syslog]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=553</guid>
		<description><![CDATA[Log rotation is a standard practice to ensure that log files are periodically restarted so that they don&#8217;t grow without bounds.  In the past, when disk space was at a premium and maximum file sizes were limited, this was an &#8230; <a href="http://wiki.springsurprise.com/2011/10/15/automatic-log-rotation-in-mac-os-x/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Log rotation is a standard practice to ensure that log files are periodically restarted so that they don&#8217;t grow without bounds.  In the past, when disk space was at a premium and maximum file sizes were limited, this was an absolute necessity.  For more modern systems, these constraints may be less relevant although they may continue to be a valid concern for very active systems or with verbose logging enabled.  Even with abundant disk space, appropriate managing of the system logs helps ensure the system remains healthy, logs remain available for diagnostics and analysis, and operational overhead is reduced.</p>
<p>In Linux, the typical log rotation utility is, appropriately enough, <a href="http://linuxcommand.org/man_pages/logrotate8.html">logrotate</a>.  However, Mac OS X uses a different tool, <a href="http://www.manpagez.com/man/8/newsyslog/">newsyslog</a>, to manage the log rotation responsibilities.  This utility is run automatically by the OS at frequently intervals and evaluates the rules defined in its configuration file &#8212; <code>/etc/newsyslog.conf</code>.  For the log files defined in the config, it can evaluate the need to rotate based on a number of criteria, such as file size, at a specific time, at a specific interval, etc.  It can also specify additional actions to take on the rotated log, including compression of the old log, maintaining a fixed number of previous log files, setting appropriate permissions, etc.  Full documentation is available in the man page for <a href="http://www.manpagez.com/man/5/newsyslog.conf/">newsyslog.conf</a>.</p>
<p>Each entry in the <code>newsyslog.conf</code> file is specified as a single line with space-delimited fields for the various options.  The general format is as follows (with [] surrounding the optional fields):</p>
<p><code>logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]</code></p>
<p>An example entry for rotating the named.stats log file can be specified as follows:</p>
<p><code>/var/log/named.stats                    640  5     1000 *     J</code></p>
<p>In the above example, the full path is specified for the target log file &#8212; <code>/var/log/named.stats</code>.  Permissions (640) are specified in the typical Unix manner, in this case enabling read/write for the owner and read-only for the group.  This log file will maintain a maximum of 5 files, removing the oldest file as newer archived logs are created.  This log file is also set to rotate at a fixed size &#8212; 1000 kilobytes and can rotate at any time (&#8220;*&#8221;) this size threshold is exceeded.  The &#8220;J&#8221; flag specified calls for the the older log files to be compressed (further reducing used disk space) using the <a href="http://www.manpagez.com/man/1/bzip2/">bzip2</a> utility.</p>
<p>A special note for binary (not text-based) logs:  by default, <code>newsyslog</code> will inject a line at the beginning of a file indicating when and why the log rotated.  For most text-based logs, this can be easily skipped over but for binary logs this might result in an unreadable file.  In this case, be sure to specify the &#8220;B&#8221; flag which suppresses the informational line from being injected.</p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2011/10/15/automatic-log-rotation-in-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Color Graphing Techniques using RRDTool</title>
		<link>http://wiki.springsurprise.com/2010/11/28/advanced-color-graphing-techniques-using-rrdtool/</link>
		<comments>http://wiki.springsurprise.com/2010/11/28/advanced-color-graphing-techniques-using-rrdtool/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 04:46:30 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Graphing Solutions]]></category>
		<category><![CDATA[Technical Tidbits]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[rrd tool]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=521</guid>
		<description><![CDATA[Introduction This section covers some of the more advanced uses of color in a RRDTool graph.  These techniques can not only help in providing an additional bit of polish to an otherwise ordinary graph, but can also be useful in &#8230; <a href="http://wiki.springsurprise.com/2010/11/28/advanced-color-graphing-techniques-using-rrdtool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>This section covers some of the more advanced uses of color in a RRDTool graph.  These techniques can not only help in providing an additional bit of polish to an otherwise ordinary graph, but can also be useful in clarifying interpretation and providing additional information.</p>
<p>Despite the availability of the techniques outlined below, it is still essential that proper color conventions and patterns be observed.  For example, red typically denotes &#8220;hot&#8221; in the context of temperature or &#8220;severe&#8221; in a notification/aberration detection.  Using red to denote a cool temperature on a temperature graph or a &#8220;normal&#8221; operating condition is very likely to lead to viewer confusion.  For more information, please be sure to consult a good reference on color theory.</p>
<h3>Examples</h3>
<h4>Example 1</h4>
<p>This is a simple example of a &#8220;stock&#8221; graph.  It uses no special color treatments but it is still able to clearly convey the necessary information.  In this case, it simply presents a graph of the system temperature.</p>
<blockquote><p><code>rrdtool graph "Example 1 Colors.png" \<br />
--start "end-48 hours" --end "12am Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 1" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
AREA:temp#FF0000</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-1-Colors1.png"><img class="aligncenter size-full wp-image-523" title="Example 1 Colors" src="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-1-Colors1.png" alt="Example 1 Colors" width="597" height="179" /></a></p>
<h4>Example 2</h4>
<p>In this example, the use of an &#8220;alpha channel&#8221; in the color specification is introduced.  The easiest way to think of an alpha channel is as a transparency measure.  A alpha channel of &#8220;FF&#8221; would be completely opaque, while an alpha channel of &#8220;00&#8243; would be completely transparent.  The alpha channel is specified in hexadecimal form at the end of the RGB color value.  In the example below, the color value of &#8220;FF000044&#8243; has specified an alpha channel value of &#8220;44&#8243;.  If no alpha channel is specified, then a default value of &#8220;FF&#8221; (fully opaque) is used.</p>
<blockquote><p><code>rrdtool graph "Example 2 Colors.png" \<br />
--start "end-48 hours" --end "12am Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 2" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
AREA:temp#FF000044</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-2-Colors.png"><img class="aligncenter size-full wp-image-524" title="Example 2 Colors" src="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-2-Colors.png" alt="Example 2 Colors" width="597" height="179" /></a></p>
<h4>Example 3</h4>
<p>This example illustrates the use of the &#8220;layer cake&#8221; effect.  This technique can help to provide additional context to a graph, as the colored layers can help clearly delineate when a system is operating within tolerances or not.  Thus, the health of the system can be determined at a glance and is not dependent on the viewer being intimate with the operational thresholds.  This example breaks down the temperature readings into four layers (cold, cool, warm, and hot) of 50 degrees each, but it would be a trivial extension to increase/decrease the number of layers.</p>
<p>The CDEF for the middle layers can be somewhat intimidating for those who are not experts in Reverse Polish Notation.  In this example, each layer relies on being stacked and so the appropriate calculation is determining the portion of the temperature (if any) that makes up the layer.  The following breakdown may help make it more palatable:</p>
<pre>cool=temp,50,GT,temp,100,GT,50,temp,50,-,IF,UNKN,IF
if (temp &gt; 50) then
  if (temp &gt; 100) then
    cool = 50
  else
    cool = temp - 50
else
  cool = UNKN</pre>
<p>As each layer is a maximum of 50 degrees, the trick is to determine how much (if any) of a layer falls within the designation.  If the actual temperature exceeds that of the layer, then simply use the maximum value (50).  If the temperature falls within the layer, then the value should be the temperature <em>less</em> <em>the total of any previous bands</em>.  If the temperature is less than the minimal temperature for this layer, then simply return the &#8220;unknown&#8221; value to prevent any graphing.</p>
<blockquote><p><code>rrdtool graph "Example 3 Colors.png" \<br />
--start "end-48 hours" --end "12am Dec 5, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 3" \<br />
--vertical-label "Temperature" \<br />
--lower-limit 0 --rigid \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
CDEF:cold=temp,50,LE,temp,50,IF \<br />
CDEF:cool=temp,50,GT,temp,100,GT,50,temp,50,-,IF,UNKN,IF \<br />
CDEF:warm=temp,100,GT,temp,150,GT,50,temp,100,-,IF,UNKN,IF \<br />
CDEF:hot=temp,150,GT,temp,150,-,UNKN,IF \<br />
AREA:cold#0000FFAA:cold:STACK \<br />
AREA:cool#0000FF44:cool:STACK \<br />
AREA:warm#FF000044:warm:STACK \<br />
AREA:hot#FF0000AA:hot:STACK </code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-3-Colors.png"><img class="aligncenter size-full wp-image-530" title="Example 3 Colors" src="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-3-Colors.png" alt="Example 3 Colors" width="597" height="193" /></a></p>
<h4>Example 4</h4>
<p>There are several techniques for &#8220;feathering&#8221; the colors in a graph as shown in this example.  The technique illustrated in this example is suitable for a representing a single color palette with the gradient lightest at the top and darkest at the bottom.  It is achieved by simply overlaying the graph with the same color selection at selected proportions and relying on the alpha channel to &#8220;build up&#8221; as the layers overlap.  Care should be made when using this technique not too make the top layers so translucent they become difficult to discern.</p>
<p>This example simply maps the set of data values into sets for 1/4, 1/2 and 3/4 values and then overlays the original value graph.  Additional looks can also be achieved through the use of alternative data transformation maps/ratios.</p>
<blockquote><p><code>rrdtool graph "Example 4 Colors.png" \<br />
--start "end-48 hours" --end "12am Dec 5, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 4" \<br />
--vertical-label "Temperature" \<br />
--lower-limit 0 --rigid \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
CDEF:tier1=temp,4,/ \<br />
CDEF:tier2=temp,2,/ \<br />
CDEF:tier3=temp,4,/,3,* \<br />
AREA:temp#FF000022: \<br />
AREA:tier3#FF000022: \<br />
AREA:tier2#FF000022: \<br />
AREA:tier1#FF000022: </code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-4-Colors.png"><img class="aligncenter size-full wp-image-531" title="Example 4 Colors" src="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-4-Colors.png" alt="Example 4 Colors" width="597" height="179" /></a></p>
<h4>Example 5</h4>
<p>This example illustrates another method of &#8220;feathering&#8221; the colors in the graph.  In this case, the color gradient is lightest at the bottom and darkest at the top.  In order to achieve this, the value is simply divided up and then each layer is stacked on top of the other while steadily increasing the alpha channel value.</p>
<blockquote><p><code>rrdtool graph "Example 5 Colors.png" \<br />
--start "end-48 hours" --end "12am Dec 5, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 5" \<br />
--vertical-label "Temperature" \<br />
--lower-limit 0 --rigid \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
CDEF:tier=temp,4,/ \<br />
AREA:tier#FF000022::STACK \<br />
AREA:tier#FF000044::STACK \<br />
AREA:tier#FF000066::STACK \<br />
AREA:tier#FF000088::STACK </code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-5-Colors.png"><img class="aligncenter size-full wp-image-536" title="Example 5 Colors" src="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-5-Colors.png" alt="Example 5 Colors" width="597" height="179" /></a></p>
<h4>Example 6</h4>
<p>This example illustrates the use of highlights to clearly delineate the borders between stacked area graphs.  It allows the use of a softer color palette without having to resort to a clashing color scheme to define the borders.</p>
<p>The highlight lines should be specified after <em>all</em> the area graphs have been declared.  Each highlight should be specified in the same order as its corresponding area graph in order to ensure the proper color is &#8220;on top&#8221; should the data sets have any overlap.  It is typically easiest to maintain the same color scheme by using the same RGB value as the area graph but specifying high alpha channel value.</p>
<blockquote><p><code>rrdtool graph "Example 6 Colors.png" \<br />
--start "end-48 hours" --end "12am Jan 15, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 6" \<br />
--vertical-label "Bytes" \<br />
--lower-limit 0 --rigid \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
DEF:disk2=sysinfo.rrd:disk2_used:AVERAGE \<br />
AREA:disk1#0000FF22:: \<br />
AREA:disk2#00F00022::STACK \<br />
LINE1:disk1#0000FFAA:"Disk 1" \<br />
LINE1:disk2#00F000AA:"Disk 2":STACK</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-6-Colors.png"><img class="aligncenter size-full wp-image-537" title="Example 6 Colors" src="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-6-Colors.png" alt="Example 6 Colors" width="597" height="193" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2010/11/28/advanced-color-graphing-techniques-using-rrdtool/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using VDEFs for set calculations in RRDTool</title>
		<link>http://wiki.springsurprise.com/2010/11/01/using_vdefs_in_rrdtool/</link>
		<comments>http://wiki.springsurprise.com/2010/11/01/using_vdefs_in_rrdtool/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 05:37:01 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Graphing Solutions]]></category>
		<category><![CDATA[Technical Tidbits]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[rrd tool]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=507</guid>
		<description><![CDATA[Introduction The VDEF directive provides a mechanism for applying mathematical operations on sets of data.  Unlike the CDEF directive, the result of a VDEF is a single value.  The VDEF can reference either a DEF or CDEF data set and &#8230; <a href="http://wiki.springsurprise.com/2010/11/01/using_vdefs_in_rrdtool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>The VDEF directive provides a mechanism for applying mathematical operations on <em>sets</em> of data.  Unlike the CDEF directive, the result of a VDEF is a single value.  The VDEF can reference either a DEF or CDEF data set and can perform a number of operations including calculating averages, standard deviations, least squares lines, and more.  These values can then be further referenced in CDEFs for graphing or printed out.</p>
<p>There is often much confusion regarding the differences of the DEF,  CDEF, and VDEF directives.  It may help to think of the different  directives in the following manner:</p>
<ul>
<li>A DEF directive references a set of “raw” data as it is stored in a RRA</li>
<li>A CDEF directive applies a function to <em>each</em> data point it references</li>
<li>A VDEF directive applies a function to an <em>aggregate</em> of data points</li>
</ul>
<h3>The VDEF Directive</h3>
<p>The basic format for a VDEF directive is as follows:</p>
<p><em>VDEF:Label=RPN Expression</em></p>
<p><em>Label</em> is the name of the VDEF.  It may be referenced in  other directives including HRULEs or CDEF  calculations.  It may be from 1-19 characters long  and consists of  characters in the  set [a-zA-Z0-9_].  Note that the label must be unique  and cannot overlap with any labels assigned to other DEFs, CDEFs, or  VDEFs.</p>
<p><em>RPN Expression</em> is the mathematical or logical expression  that is applied to a data set.  The expression  uses <a href="http://en.wikipedia.org/wiki/Reverse_Polish_notation" target="_blank">Reverse Polish Notation</a> to eliminate confusion or errors that may occur with the precedence  rules required of traditional infix notation.  There are a number of <a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html" target="_blank">mathematical, boolean and logical operators</a> available for inclusion in a VDEF directive.</p>
<h3>VDEF Examples</h3>
<h4>Example 1</h4>
<p>This is a simple example which illustrates the use of VDEFs to reveal information about the set of data.  In this case, the MINIMUM, MAXIMUM, and AVERAGE operations are used to determine the respective values for the data set.  The resulting value for each operation is then used as the value for a HRULE providing a clear illustration in the resulting graph.  Note that the VDEF values are based <em>only on the data referenced</em>.  In this case, the data is bounded by the start and end time specified and so would likely differ for a different window into the original data set.</p>
<blockquote><p><code>rrdtool graph "Example 1 VDEF.png" \<br />
--start "end-48 hours" --end "12am Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 1" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
VDEF:min=temp,MINIMUM \<br />
VDEF:max=temp,MAXIMUM \<br />
VDEF:avg=temp,AVERAGE \<br />
AREA:temp#FFEF00 \<br />
HRULE:max#FF0000:"Max" \<br />
HRULE:avg#000000:"Average" \<br />
HRULE:min#0000FF:"Min"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-1-VDEF.png"><img class="aligncenter size-full wp-image-508" title="Example 1 VDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-1-VDEF.png" alt="Example 1 VDEF" width="597" height="193" /></a></p>
<h4>Example 2</h4>
<p>This example uses the average and standard deviation VDEF operations to identify temperature ranges that exceed the average temperature by more than one standard deviation.  The VDEF operations determine the appropriate values, which are then used in the CDEF operations to generate new data sets.  The original data set is graphed in the &#8220;hot&#8221; color with the &#8220;normal&#8221; and &#8220;cool&#8221; graphs overlayed on top of the appropriate sections.</p>
<p>The CDEF calculations may be difficult to parse for a novice to Reverse Polish syntax.  It may help to break it down as follows:</p>
<ol>
<li>cool=temp,avg,stdev,-,LE,temp,UNKN,IF</li>
<li>cool=temp,(avg &#8211; stdev),LE,temp,UNKN,IF</li>
<li>cool=(temp &lt;= (avg &#8211; stdev)),temp,UNKN,IF</li>
<li>cool=if (temp &lt;= (avg &#8211; stdev)) then temp else UNKN</li>
</ol>
<blockquote><p><code>rrdtool graph "Example 2 VDEF.png" \<br />
--start "end-48 hours" --end "12am Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 2" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
VDEF:avg=temp,AVERAGE \<br />
VDEF:stdev=temp,STDEV \<br />
CDEF:cool=temp,avg,stdev,-,LE,temp,UNKN,IF \<br />
CDEF:medium=temp,avg,stdev,+,LE,temp,UNKN,IF \<br />
AREA:temp#FF0000:"Hot" \<br />
AREA:medium#FFEF00:"Normal" \<br />
AREA:cool#0000FF:"Cool"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-2-VDEF.png"><img class="aligncenter size-full wp-image-509" title="Example 2 VDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-2-VDEF.png" alt="Example 2 VDEF" width="597" height="193" /></a></p>
<h4>Example 3</h4>
<p>This example illustrates how to use the <a href="http://en.wikipedia.org/wiki/Least_squares" target="_blank">least squares line</a> VDEF operations to draw a trendline.  The LSLSLOPE operation can determine the slope of line and the LSLINT can provide the y-axis intercept value.  A trendline can then be generated using the classic <code>"y=mx+b"</code> formula (where m is the slope and b is the intercept).</p>
<p>The CDEF operation implements this formula using several &#8220;tricks&#8221; of rrdtool: a workaround for the CDEF requirement to reference a DEF or CDEF, and the use of the COUNT operation to increment a value for each data point in the graph set.  In the example, the CDEF reference requirement is satisfied by the &#8220;temp,POP&#8221; elements, which effectively puts a value from the temp DEF on the stack and then pops it back off, discarding it.</p>
<blockquote><p><code>rrdtool graph "Example 3 VDEF.png" \<br />
--start "end-48 hours" --end "12am Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 3" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
VDEF:slope=temp,LSLSLOPE \<br />
VDEF:intercept=temp,LSLINT \<br />
CDEF:trendline=temp,POP,COUNT,slope,*,intercept,+ \<br />
AREA:temp#FFEF00 \<br />
LINE2:trendline#000000</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-3-VDEF.png"><img class="aligncenter size-full wp-image-510" title="Example 3 VDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-3-VDEF.png" alt="Example 3 VDEF" width="597" height="179" /></a></p>
<p>Example 4</p>
<p>This examples uses the PERCENTNAN operation in order to identify the 5% coolest and 5% hottest temperatures in the data set.  These values are then applied as part of the  CDEF calculations to generate the appropriate data sets for graphing.  Note that it is frequently best to use the PERCENTNAN operation instead of the PERCENT operation as the PERCENTNAN variant handles any gaps in the data in a more graceful manner.</p>
<blockquote><p><code>rrdtool graph "Example 4 VDEF.png" \<br />
--start "end-48 hours" --end "12am Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 4" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
VDEF:cool5=temp,5,PERCENTNAN \<br />
VDEF:hot95=temp,95,PERCENTNAN \<br />
CDEF:cool=temp,</code><code>cool5</code><code>,LE,temp,UNKN,IF \<br />
CDEF:medium=temp,</code><code>hot95</code><code>,LE,temp,UNKN,IF \<br />
AREA:temp#FF0000:"Hot" \<br />
AREA:medium#FFEF00:"Normal" \<br />
AREA:cool#0000FF:"Cool"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-4-VDEF.png"><img class="aligncenter size-full wp-image-514" title="Example 4 VDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/11/Example-4-VDEF.png" alt="Example 4 VDEF" width="597" height="193" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2010/11/01/using_vdefs_in_rrdtool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using CDEFs to manipulate data in RRDTool</title>
		<link>http://wiki.springsurprise.com/2010/10/26/using-cdefs-to-manipulate-data-in-rrdtool/</link>
		<comments>http://wiki.springsurprise.com/2010/10/26/using-cdefs-to-manipulate-data-in-rrdtool/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 06:15:24 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Graphing Solutions]]></category>
		<category><![CDATA[Technical Tidbits]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[rrd tool]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=485</guid>
		<description><![CDATA[Introduction The CDEF directive provides a means for manipulating the &#8220;raw&#8221; data stored in a round-robin archive (RRA).  It is typically used to apply a mathematical function to each data point referenced by one or more DEF statements which results &#8230; <a href="http://wiki.springsurprise.com/2010/10/26/using-cdefs-to-manipulate-data-in-rrdtool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>The CDEF directive provides a means for manipulating the &#8220;raw&#8221; data stored in a round-robin archive (RRA).  It is typically used to apply a mathematical function to each data point referenced by one or more DEF statements which results in an array of new values &#8212; each of remains associated with the respective time of the original &#8220;raw&#8221; data point.  This is an in-memory transformation only; the original data remains unchanged in the RRA.</p>
<p>There is often much confusion regarding the differences of the DEF, CDEF, and VDEF directives.  It may help to think of the different directives in the following manner:</p>
<ul>
<li>A DEF directive references a set of &#8220;raw&#8221; data as it is stored in a RRA</li>
<li>A CDEF directive applies a function to <em>each</em> data point it references</li>
<li>A VDEF directive applies a function to an <em>aggregate</em> of data points</li>
</ul>
<h3>The CDEF Directive</h3>
<p>The basic format for a CDEF directive is as follows:</p>
<p><em>CDEF:Label=RPN Expression</em></p>
<p><em>Label</em> is the name of the CDEF.  It may be referenced in other directives for inclusion in LINE, AREA charts or even other CDEF calculations.  It may be from 1-19 characters long  and consists of characters in the  set [a-zA-Z0-9_].  Note that the label must be unique and cannot overlap with any labels assigned to other DEFs, CDEFs, or VDEFs.</p>
<p><em>RPN Expression</em> is the mathematical or logical expression that may be used to manipulate the raw data values as referenced by DEF or CDEF directives or even a pure mathematical function.  The expression uses <a href="http://en.wikipedia.org/wiki/Reverse_Polish_notation" target="_blank">Reverse Polish Notation</a> to eliminate confusion or errors that may occur with the precedence rules required of traditional infix notation.  There are a number of <a href="http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html" target="_blank">mathematical, boolean and logical operators</a> available for inclusion in a CDEF directive.</p>
<h3>CDEF Examples</h3>
<h4>Example 1</h4>
<p>This example illustrates the commonly used transformation of bytes to megabytes.  Disk and memory readings are often reported in bytes, but frequently this is not the most convenient unit for visualization.  In this case, the CDEF directive divides the &#8220;raw&#8221; data value as referenced by the DEF and divides it by 1048576 (1024 x 1024).  Note that the AREA directive now references the CDEF label and that the vertical label has been updated to reflect the proper units.</p>
<blockquote><p><code>rrdtool graph "Example 1 CDEF.png" \<br />
--start "end-48 hours" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 1" \<br />
--vertical-label "Megabytes" \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
CDEF:megadisk1=disk1,1048576,/ \<br />
AREA:megadisk1#0000FF:"Disk 1"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-1-CDEF.png"><img class="aligncenter size-full wp-image-488" title="Example 1 CDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-1-CDEF.png" alt="Example 1 CDEF" width="597" height="193" /></a></p>
<p>Example 2</p>
<p>This example shows a slightly more complex instance of the reverse-polish math that may be referenced in a CDEF.  In this case, the CDEF first sums up the the &#8220;raw&#8221; values as referenced by the two DEF statements and then converts the sum to megabytes.</p>
<blockquote><p><code>rrdtool graph "Example 2 CDEF.png" \<br />
--start "end-48 hours" --end "Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 2" \<br />
--vertical-label "Megabytes" \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
DEF:disk2=sysinfo.rrd:disk2_used:AVERAGE \<br />
CDEF:megadisk=disk1,disk2,+,1048576,/ \<br />
AREA:megadisk#0000FF:"Total Disk Used"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-2-CDEF.png"><img class="aligncenter size-full wp-image-489" title="Example 2 CDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-2-CDEF.png" alt="Example 2 CDEF" width="597" height="193" /></a></p>
<h4>Example 3</h4>
<p>This example illustrates a common technique for differentiating several types of related measurements.  It is a frequent graphing style for disk IO (reads vs. writes) as well as network IO (octets in vs. octets out).  It is achieved by simply negating the values of one of the operations and graphing the result.  In this example, a horizontal rule (HRULE) at the 0 point has also been added in order to highlight the baseline.  Note that the HRULE is specified as the last element to be drawn, which ensures that it will overlay the other graphed elements.</p>
<blockquote><p><code>rrdtool graph "Example 3 CDEF.png" \<br />
--start "end-48 hours" --end "Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 3" \<br />
--vertical-label "Bytes" \<br />
DEF:read=sysinfo.rrd:bytes_read:AVERAGE \<br />
DEF:write=sysinfo.rrd:bytes_written:AVERAGE \<br />
CDEF:negwrite=0,write,- \<br />
AREA:read#0000FF:"Bytes Read" \<br />
AREA:negwrite#00FF00:"Bytes Written" \<br />
HRULE:0#000000</code></p></blockquote>
<p><a href="../wp-content/uploads/2010/10/Example-2-CDEF.png"></a><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-3-CDEF.png"><img class="aligncenter size-full wp-image-494" title="Example 3 CDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-3-CDEF.png" alt="Example 3 CDEF" width="597" height="193" /></a></p>
<h4><a href="../wp-content/uploads/2010/10/Example-2-CDEF.png"> </a>Example 4</h4>
<p>This is a more complex example which illustrates the use of the IF operation as well as a more advanced graphing style useful to call out anomalous behaviors.  In this case, the temperature values (referenced by the DEF &#8220;temp&#8221;) are first assessed by the LE (less than or equal to) and GT (greater than) operations.  The values assigned in these CDEFs (iscool, ishot) will then be used in the CDEFs with the IF operations.  The IF operations evaluate iscool/ishot and if it is &#8220;true&#8221; (i.e. not zero), then the value for temp is returned.  Otherwise, the special constant &#8220;unknown&#8221;  is returned.  These values for the cool/hot CDEFs are then graphed and result in a clear demarcation where the system is over-heated.</p>
<blockquote><p><code>rrdtool graph "Example 4 CDEF.png" \<br />
--start "end-48 hours" --end "Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 4" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
CDEF:iscool=temp,175,LE \<br />
CDEF:ishot=temp,175,GT \<br />
CDEF:cool=iscool,temp,UNKN,IF \<br />
CDEF:hot=ishot,temp,UNKN,IF \<br />
AREA:cool#0000FF:"cool" \<br />
AREA:hot#FF0000:"hot" </code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-4-CDEF.png"><img class="aligncenter size-full wp-image-496" title="Example 4 CDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-4-CDEF.png" alt="Example 4 CDEF" width="597" height="193" /></a></p>
<h4>Example 5</h4>
<p>This example illustrates the use of the LIMIT operation to achieve a similar effect for highlighting anomalous conditions.  In this case, the entire data set is initially graphed using the &#8220;hot&#8221; color and then the &#8220;cool&#8221; data set is overlayed on top of the appropriate sections.</p>
<blockquote><p><code>rrdtool graph "Example 5 CDEF.png" \<br />
--start "end-48 hours" --end "12am Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 5" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
CDEF:cool=temp,0,175,LIMIT \<br />
AREA:temp#FF0000:"hot" \<br />
AREA:cool#0000FF:"cool"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-5-CDEF.png"><img class="aligncenter size-full wp-image-498" title="Example 5 CDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-5-CDEF.png" alt="Example 5 CDEF" width="597" height="193" /></a></p>
<h4>Example 6</h4>
<p>This example shows the use of the MIN operation to provide a &#8220;layer cake effect&#8221; in the graph.  This is a popular graphing technique that can be used either to signify a state change above a given threshold or simply to provide a color gradient in the graph for extra polish.  This particular example again relies on overlaying the &#8220;cool&#8221; graph to mask out the relevant sections of the data.</p>
<blockquote><p><code>rrdtool graph "Example 6 CDEF.png" \<br />
--start "end-48 hours" --end "12am Nov 1, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 6" \<br />
--vertical-label "Temperature" \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
CDEF:cool=temp,175,MIN \<br />
AREA:temp#FF0000:"hot" \<br />
AREA:cool#0000FF:"cool"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-6-CDEF.png"><img class="aligncenter size-full wp-image-499" title="Example 6 CDEF" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-6-CDEF.png" alt="Example 6 CDEF" width="597" height="193" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2010/10/26/using-cdefs-to-manipulate-data-in-rrdtool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rules, Legends and Scales with RRDTool</title>
		<link>http://wiki.springsurprise.com/2010/10/14/rules-legends-and-scales-with-rrdtool/</link>
		<comments>http://wiki.springsurprise.com/2010/10/14/rules-legends-and-scales-with-rrdtool/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 04:22:21 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Graphing Solutions]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[rrd tool]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=441</guid>
		<description><![CDATA[Introduction This section covers some of the basic options and directives that can be used to personalize the graph.  There are a number of options available to control how the legends and other text are displayed, adjustments for the scaling &#8230; <a href="http://wiki.springsurprise.com/2010/10/14/rules-legends-and-scales-with-rrdtool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>This section covers some of the basic options and directives that can be used to personalize the graph.  There are a number of options available to control how the legends and other text are displayed, adjustments for the scaling behavior, as well as means for demarcating significant levels or marking points in time.</p>
<h3>Rule Directives</h3>
<p>Rules are simply straight lines that are drawn in the graphing area.  There are two variations:  Horizontal Rules (HRULEs) and Vertical Rules (VRULEs).  Typical usages of rules may include displaying a bar across the graph that may indicate an important threshold or a delimiter that reflects a system change.  Note that rules will <em>not</em> be drawn if they are not within the scope of the actual data ranges being displayed.  The general format for rules are as follows:</p>
<p><em>HRULE:Value#Color:Legend</em></p>
<p><em>VRULE:Time#Color:Legend</em></p>
<p><em>Value </em>represents the value on the y-axis that will apply to a horizontal rule.  Note that horizontal rules can only be perfectly horizontal; it is not possible to supply a formula for a sloped line.  If the values of the data being displayed are not within the range of the horizontal line, then the line will not be displayed.  A frequent use of a HRULE is to demarcate a critical threshold in the data.</p>
<p><em>Time</em> represents the value on the x-axis that will apply to a vertical rule.  The time must be presented as a standard Unix epoch value (number  of seconds since Jan 1, 1970 UTC).  Note that if the time range of the data displayed does not contain the time specified for the VRULE, the rule will not be displayed.  A common use of a VRULE is to flag a &#8220;state change&#8221; in the measured systems, such as a new software release.</p>
<p><em>Color</em> defines the color of the line or area graph.  This is  expressed in the   web-standard  RGB hexadecimal triplet and must be  separated from the   label by a ‘#’.  Example color definitions are:  333399 (blue), 33FF00   (bright green), and CC0000 (red).  If the color  is not specified, then  the area will be “invisible”.</p>
<p><em>Legend</em> is the text associated with the legend entry for the   graph.  It is an  optional element, and if it is omitted the ‘:’   separator should also be  omitted.</p>
<h3>Rule Examples</h3>
<h4>Example 1</h4>
<p>The following example is a simple example of the different rule types.  The HRULE specifies a red horizontal line drawn at the value of 750,000,000 on the y-axis.   The VRULE specifies a light green vertical line drawn at the value of 11:30am Dec 30, 2009 (1262201400 in Unix epoch format).</p>
<blockquote><p><code>rrdtool graph "Example 1.png" \<br />
--start "end-48 hours" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 1" \<br />
--vertical-label "Bytes" \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk 1" \<br />
HRULE:750000000#FF0000:"750 MB Warning" \<br />
VRULE:1262201400#00FF00:"Software Rollout"</code></p></blockquote>
<h4><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-1-Rules.png"><img class="aligncenter size-full wp-image-443" title="Example 1" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-1-Rules.png" alt="Example 1" width="597" height="193" /></a></h4>
<h4>Example 2</h4>
<p>The following example illustrates use of a time value for the VRULE (Dec 18, 2009) that is not within the scope of the graphed data.  Note that the rule in this case is <em>not</em> displayed nor is there a legend element.  If the scope of the graphed data is changed to encompass the value of the VRULE, then the rule will again be displayed.  This behavior provides some utility in demarcating significant events without causing the y-axis to be &#8220;pinned&#8221; to a specified time.</p>
<blockquote><p><code>rrdtool graph "Example 2 Rule.png" \<br />
--start "end-48 hours" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 2" \<br />
--vertical-label "Bytes" \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk 1" \<br />
HRULE:750000000#FF0000:"750 MB Warning" \<br />
VRULE:1261201400#00FF00:"Software Rollout"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-2-Rules.png"><img class="aligncenter size-full wp-image-444" title="Example 2" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-2-Rules.png" alt="Example 2" width="597" height="193" /></a></p>
<h3>Legend and Title Options</h3>
<p><em><code>--title</code></em> specifies the text to be displayed above the graphing canvas.</p>
<p><em><code>--vertical-label</code></em> specifies the text to be displayed next to the y-axis.  Typically, this indicates the units of the measurement.</p>
<p><em><code>--right-axis</code></em> specifies an alternate y-axis scale that will be displayed on the right side of the graph.  This can be used to realign the units displayed which may have been adjusted to increase the legibility of the graph.  This parameter requires both a scale and offset (<code>scale:offset</code>) be specified.</p>
<p><em><code>--right-axis-label</code></em> specifies the text to be displayed on the right axis.</p>
<p><em><code>--no-legend</code></em> omits the legend information from being drawn.</p>
<p><em><code>--legend-position</code></em> defines where the legend will be displayed in the graph.  Acceptable values are <code>north</code>, <code>south</code>, <code>east</code> and <code>west</code>.  The default value is <code>south</code>.</p>
<h3>Legend and Title Examples</h3>
<h4>Example 1</h4>
<p>This simple example illustrates the title, vertical-label, and legend-position parameters in use.  Note that the text for the label and title is quoted to ensure proper parsing.  The legend-position overrides the default value of <code>south</code> with <code>east</code>.</p>
<blockquote><p><code>rrdtool graph "Example 1 Legend.png" \<br />
--start "end-48 hours" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 1" \<br />
--vertical-label "Bytes" \<br />
--legend-position east \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk 1"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-1-Legend.png"><img class="aligncenter size-full wp-image-467" title="Example 1 Legend" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-1-Legend.png" alt="Example 1 Legend" width="685" height="170" /></a></p>
<h4>Example 2</h4>
<p>This example illustrates the use of the right-axis to specify an alternate scale.  In this case, the y-axis scale on the left (the default) reflects the CPU temperature measured in Celsius.  The y-axis scale on the right reflects the fan speed measured in RPM.  For this example, the scale has been set to 1 and the offset specified as 0.</p>
<blockquote><p><code>rrdtool graph "Example 2 Legend.png" \<br />
--start "end-48 hours" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 2" \<br />
--vertical-label "Celsius" \<br />
--right-axis 1:0 \<br />
--right-axis-label RPM \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
DEF:fan=sysinfo.rrd:cpu_fan:AVERAGE \<br />
AREA:temp#0000FF:"CPU Temperature" \<br />
LINE1:fan#00FF00:"Fan"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-2-Legend.png"><img class="aligncenter size-full wp-image-468" title="Example 2 Legend" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-2-Legend.png" alt="Example 2 Legend" width="649" height="193" /></a></p>
<h4>Example 3</h4>
<p>This example further refines the graph defined in Example 2 by adjusting the values of the fan so that they are closer to the range of the temperatures.  (This is performed by the CDEF directive, which will be further described in later examples.)  To keep the units correct, the scale for the right-label is adjusted to re-compensate.  Note that in this example the variations in temperature and RPM are now both clearly visible and the left and right scales on the y-axis reflect the different scales of the datatypes.</p>
<blockquote><p><code>rrdtool graph "Example 3 Legend.png" \<br />
--start "end-48 hours" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 3" \<br />
--vertical-label "Celsius" \<br />
--right-axis 20:0 \<br />
--right-axis-label RPM \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
DEF:fan=sysinfo.rrd:cpu_fan:AVERAGE \<br />
CDEF:fan20=fan,20,/ \<br />
AREA:temp#0000FF:"CPU Temperature" \<br />
LINE1:fan20#00FF00:"Fan"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-3-Legend.png"><img class="aligncenter size-full wp-image-469" title="Example 3 Legend" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-3-Legend.png" alt="Example 3 Legend" width="649" height="193" /></a></p>
<h3>Scale Options</h3>
<p><em><code>--upper-limit</code></em> provides an override of the default auto-scaling behavior by setting an explicit upper limit value for the y-axis.  Note that the value provided by this option will continue to be overridden if an actual data value in the graph exceeds the limit specified.</p>
<p><em><code>--lower-limit</code></em> provides an override of the default auto-scaling behavior by setting an explicit lower limit value for the y-axis.  Note that the value provided by this option will continue to be overridden if an actual data value in the graph is lower than the limit specified.</p>
<p><em><code>--rigid</code></em> is used in conjunction with the <code>upper-limit</code> and <code>lower-limit</code> options to provide a definitive maximum and minimum y-axis value.  With this option specified, the auto-scaling behavior will not adjust the scale even if a data value would exceed (or fall below) the upper or lower limits specified.</p>
<p><em><code>--logarithmic</code></em> changes the y-axis to use a logarithmic scale instead of the default linear scale.  This can be useful to visualize fine-grain patterns in the data that may otherwise be obscured if the values are wide-ranging.</p>
<p><em><code>--units-exponent</code></em> sets the exponent expressed in the y-axis scale to a fixed value.  For example, setting this to 3 would lead to the scale to consistently use units of 1000 (10^3).</p>
<p><em><code>--units-length</code></em> defines how many characters rrdtool should assume are present in the y-axis scale labels.  This may be necessary to specify when deviating from the default values for the expression of the units (via the <code>units-exponent</code>, <code>logarithmic</code>, or <code>units=si</code> options) in order to prevent rrdtool from overlapping the vertical label and scale labels.</p>
<p><em><code>--units=si</code></em> overrides the exponential notation with the standard SI unit symbols (k, M, etc.)  Note that the exponential notation is the default only for logarithmic graphs; linear graphs already use the SI notation.</p>
<h3>Scale Examples</h3>
<h4>Example 1</h4>
<p>This example illustrates the use of the upper and lower limit options.  Note that in this case the specified lower-limit is <em>ignored</em>, as an actual data value is lower than the value specified and so the auto-scaler adjusts the lower range of the scale to compensate.</p>
<blockquote><p><code>rrdtool graph "Example 1 Scale.png" \<br />
--start "end-1 month" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 1" \<br />
--vertical-label "Bytes" \<br />
--upper-limit 1000000000 \<br />
--lower-limit 500000000 \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-1-Scale.png"><img class="aligncenter size-full wp-image-474" title="Example 1 Scale" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-1-Scale.png" alt="Example 1 Scale" width="597" height="193" /></a></p>
<h4>Example 2</h4>
<p>This example demonstrates how the rigid option can be used to enforce the specified upper and lower limits.  Note that this strict adherence to the specified limits may prevent data that is out of range from being displayed.</p>
<blockquote><p><code>rrdtool graph "Example 2 Scale.png" \<br />
--start "end-1 month" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 2" \<br />
--vertical-label "Bytes" \<br />
--upper-limit 1000000000 \<br />
--lower-limit 500000000 \<br />
--rigid \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-2-Scale.png"><img class="aligncenter size-full wp-image-475" title="Example 2 Scale" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-2-Scale.png" alt="Example 2 Scale" width="597" height="193" /></a></p>
<h4>Example 3</h4>
<p>In this example, the logarithmic option is specified to alter the y-axis scaling behavior.  The units-exponent is also specified which maintains the expression of the scale at the fixed rate of 10^3 (1000&#8242;s).</p>
<blockquote><p><code>rrdtool graph "Example 3 Scale.png" \<br />
--start "end-1 month" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 3" \<br />
--vertical-label "kilobytes" \<br />
--logarithmic \<br />
--units-exponent 3 \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-3-Scale.png"><img class="aligncenter size-full wp-image-476" title="Example 3 Scale" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-3-Scale.png" alt="Example 3 Scale" width="597" height="193" /></a></p>
<p>Example 4</p>
<p>This is an alternate view of the previous graph using the SI notation instead of the default exponential notation for a logarithmic graph.  In addition, the units-length option is specified to facilitate the alignment of the axis label and scale units.</p>
<blockquote><p><code>rrdtool graph "Example 4 Scale.png" \<br />
--start "end-1 month" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 4" \<br />
--vertical-label "Bytes" \<br />
--logarithmic \<br />
--units=si \<br />
--units-length 5 \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-4-Scale.png"><img class="aligncenter size-full wp-image-477" title="Example 4 Scale" src="http://wiki.springsurprise.com/wp-content/uploads/2010/10/Example-4-Scale.png" alt="Example 4 Scale" width="591" height="193" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2010/10/14/rules-legends-and-scales-with-rrdtool/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Basic Area Graphs with RRDTool</title>
		<link>http://wiki.springsurprise.com/2010/09/21/basic-area-graphs-with-rrdtool/</link>
		<comments>http://wiki.springsurprise.com/2010/09/21/basic-area-graphs-with-rrdtool/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 06:57:06 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Graphing Solutions]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[rrd tool]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=428</guid>
		<description><![CDATA[Introduction This post describes some basic techniques for generating area charts using RRD tool.  It builds upon the previous Line Graphs posting which describes DEFs and other basic graphing options.  The data used for the examples was generated using the &#8230; <a href="http://wiki.springsurprise.com/2010/09/21/basic-area-graphs-with-rrdtool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>This post describes some basic techniques for generating area charts using RRD tool.  It builds upon the previous <a href="http://wiki.springsurprise.com/2010/09/20/rrdtool_line_graphs/">Line Graphs</a> posting which describes DEFs and other basic graphing options.  The data used for the examples was generated using the tool specified in the <a href="http://wiki.springsurprise.com/2009/08/08/rrdtool-example-data/">RRD Example Data</a> posting.</p>
<h3>Area Chart Graphing Directives</h3>
<p>As specified in the <a href="http://wiki.springsurprise.com/2010/09/20/rrdtool_line_graphs/">Line Graphs</a> posting, the data definitions (DEFs) must be declared prior to the display directives.  The general format for an area directive is as follows:</p>
<p><em>AREA:Label#Color:Legend:STACK</em></p>
<p><em>Label</em> refers to the label given to a previously defined data definition (DEF).  This defines the source of the data to be graphed.</p>
<p><em>Color</em> defines the color of the line or area graph.  This is  expressed in the  web-standard  RGB hexadecimal triplet and must be  separated from the  label by a ‘#’.  Example color definitions are:  333399 (blue), 33FF00  (bright green), and CC0000 (red).  If the color  is not specified, then the area will be “invisible”.</p>
<p><em>Legend</em> is the text associated with the legend entry for the  graph.  It is an  optional element, and if it is omitted the ‘:’  separator should also be  omitted.</p>
<p><em>STACK</em> specifies that the results in the graph element be offset from the top of the <em>previous</em> display output instead of the normal 0-based offset.  It is case-sensitive and should always be specified in all-caps.  It is an optional element, and if it is omitted the &#8216;:&#8217; separator should also be omitted.  To specify a stacked element without a legend, simply omit any entry for the legend <em>but remember the colon</em>.  (e.g. AREA:label#00FFAA::STACK)</p>
<h3>Examples</h3>
<h4>Example 1</h4>
<p>This is a simple example of an area graph.  In this case, there is only one data element defined and displayed (&#8220;disk1&#8243;).</p>
<blockquote><p><code>rrdtool graph "Example 1.png" \<br />
--start "end-28 hours" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 1" \<br />
--vertical-label "Bytes" \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk 1"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-Area-1.png"><img class="aligncenter size-full wp-image-430" title="Example 1" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-Area-1.png" alt="Example 1" width="597" height="193" /></a></p>
<h4>Example 2</h4>
<p>This example illustrates more than one display element.  In this case, the elements are <em>not</em> stacked and so both use the default 0-based offset.  Note that the order of display directives also defines the drawing order, which may result in some (or all) of an area graph in being hidden.</p>
<blockquote><p><code>rrdtool graph "Example 2.png" \<br />
--start "end-48 hours" --end "Jan 4, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 2" \<br />
--vertical-label "Bytes" \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
DEF:disk2=sysinfo.rrd:disk2_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk 1" \<br />
AREA:disk2#FF0000:"Disk 2"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-Area-2.png"><img class="aligncenter size-full wp-image-434" title="Example 2" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-Area-2.png" alt="Example 2" width="597" height="193" /></a></p>
<h4>Example 3</h4>
<p>This example illustrates the use of the STACK option for the AREA directive.  Remember that the STACK offsets the data display to start from the top of the <em>previously</em> displayed element.  If there is no previous element, then the STACK option uses the default 0-based offset.  Any number of display directives can use the STACK option.  A frequent use of the STACK option is to illustrate a &#8220;summation&#8221; of a set of servers or services.</p>
<p>Compare this graph with that of Example 2, which covers the same set of data.</p>
<blockquote><p><code>rrdtool graph "Example 3.png" \<br />
--start "end-48 hours" --end "Jan 4, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 3" \<br />
--vertical-label "Bytes" \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
DEF:disk2=sysinfo.rrd:disk2_used:AVERAGE \<br />
AREA:disk1#0000FF:"Disk 1":STACK \<br />
AREA:disk2#FF0000:"Disk 2":STACK</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-Area-3.png"><img class="aligncenter size-full wp-image-435" title="Example 3" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-Area-3.png" alt="Example 3" width="597" height="193" /></a></p>
<h4>Example 4</h4>
<p>This example illustrates the technique of making an &#8220;invisible&#8221; element.  In this case, the &#8220;disk1&#8243; directive has no color or legend specified.  However, despite it not being displayed, it is still present as applicable to the STACK option for the &#8220;disk2&#8243; element.</p>
<blockquote><p><code>rrdtool graph "Example 4.png" \<br />
--start "end-48 hours" --end "Jan 4, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 4" \<br />
--vertical-label "Bytes" \<br />
DEF:disk1=sysinfo.rrd:disk_used:AVERAGE \<br />
DEF:disk2=sysinfo.rrd:disk2_used:AVERAGE \<br />
AREA:disk1::STACK \<br />
AREA:disk2#FF0000:"Disk 2":STACK</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-Area-4.png"><img class="aligncenter size-full wp-image-437" title="Example 4" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-Area-4.png" alt="Example 4" width="597" height="193" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2010/09/21/basic-area-graphs-with-rrdtool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Line Graphs with RRDTool</title>
		<link>http://wiki.springsurprise.com/2010/09/20/rrdtool_line_graphs/</link>
		<comments>http://wiki.springsurprise.com/2010/09/20/rrdtool_line_graphs/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 06:18:23 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Graphing Solutions]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[rrd tool]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://wiki.springsurprise.com/?p=410</guid>
		<description><![CDATA[Introduction This post covers some of the basic techniques for generating graphs using RRD tool.  The demonstration examples assumes that the data has been created as described in the RRD Example Data posting.  It should provide a basic understanding of &#8230; <a href="http://wiki.springsurprise.com/2010/09/20/rrdtool_line_graphs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>This post covers some of the basic techniques for generating graphs using RRD tool.  The demonstration examples assumes that the data has been created as described in the <a href="http://wiki.springsurprise.com/2009/08/08/rrdtool-example-data/">RRD Example Data</a> posting.  It should provide a basic understanding of how to specify data sources and transform them into basic line graphs using some of RRDTool&#8217;s built-in graphing options.</p>
<h3>Data Definitions</h3>
<p>The data definition is the source of the data to be graphed.  It  provides a label that is referenced by the graphing directives.  There  can be multiple data definitions in a single graph and the data may be  manipulated extensively by other operations (CDEFs and VDEFs).  In addition, it is possible to specify data from multiple files to be combined in a single graph.</p>
<p>The basic format for a Data Definition (DEF) is as follows:</p>
<p><em>DEF:Label=RRD File:Data Source:Consolidation Function</em></p>
<p><em>Label</em> is the name of the data definition. It may be from 1-19 characters long  and consists of characters in the set [a-zA-Z0-9_].  The label should be  descriptive of the data being graphed and may be the same label as used  in the original Data Source.  Example labels include “temperature”,  “BytesIn”, “bytes_out”, etc.</p>
<p><em>RRD File</em> is the path and name of the data file.  If the full path is not specified, then rrdtool assumes the current working directory.</p>
<p><em>Data Source</em> is the name of the data source (DS) within the RRD file.  See the posting on <a href="http://wiki.springsurprise.com/2009/08/04/creating-a-round-robin-database-with-rrdtool/">Creating a RRD File</a> for a reference of the DS definition if necessary.</p>
<p><em>Consolidation Function</em> specifies how rrdtool may consolidate data prior to display.  This does <em>not</em> affect the actual data stored in the RRD file; it is used to aggregate  data points if the resolution of the graph is too low to display each  data point individually.  There available consolidation functions are  MIN, MAX, AVERAGE, and LAST.</p>
<p style="padding-left: 30px;">MIN uses only the smallest value of the Primary Data Points within the resolution&#8217;s time span.</p>
<p style="padding-left: 30px;">MAX uses only the largest value of the Primary Data Points within the resolution&#8217;s time span.</p>
<p style="padding-left: 30px;">AVERAGE uses the average of the all Primary Data Points within the resolution&#8217;s time span.</p>
<p style="padding-left: 30px;">LAST uses only the last (most recent) Primary Data Point within the resolution&#8217;s time span.</p>
<h3>Graphing Directive for Lines</h3>
<p>With the data definitions established, graphing directives can be used to specify how the data will be displayed.  Note that the graphing directives should be specified only <em>after</em> the data definitions (DEF) have been declared.  The general format for a line directive is as follows:</p>
<p><em>LINE[Width]:Label#Color:Legend</em></p>
<p><em>Width</em> is an optional element for line graphs.  It defines the width of the line used to draw the graph.</p>
<p><em>Label</em> refers to the label given to a previously defined data definition (DEF).  This defines the source of the data to be graphed.</p>
<p><em>Color</em> defines the color of the line or area graph.  This is expressed in the  web-standard  RGB hexadecimal triplet and must be separated from the  label by a &#8216;#&#8217;.  Example color definitions are: 333399 (blue), 33FF00  (bright green), and CC0000 (red).  If the color is not specified, then the line will be &#8220;invisible&#8221;.</p>
<p><em>Legend</em> is the text associated with the legend entry for the graph.  It is an  optional element, and if it is omitted the &#8216;:&#8217; separator should also be  omitted.</p>
<h3>Display Options</h3>
<p>There are a number of options available that define how the graph is  rendered.  These options can define the size, format, time span, legend,  title, etc. of the graph.  None of them are explicitly required  (default values will be used), but they help provide some basic  customization of the graphs.</p>
<p><em><code>--width</code></em> specifies the width (in pixels) of the <em>graphing canvas</em>.  The actual image width may be wider to accommodate any border or label elements.</p>
<p><em><code>--height</code></em> specifies the height (in pixels) of the <em>graphing canvas</em>.  The actual image height may be taller to accommodate any border, title, or legend elements.</p>
<p><em><code>--imgformat</code></em> specifies the desired output format of the graph.  Available options include: PNG, SVG, EPS, and PDF.<strong></strong></p>
<p><em><code>--start</code></em> specifies the start time (in absolute or relative terms) for the data displayed on the graphing canvas.  Frequently, the start time is a relative offset of the end time (e.g. &#8220;end-24 hours&#8221;, &#8220;end-1 month&#8221;, &#8220;end-2 weeks&#8221;)</p>
<p><em><code>--end</code></em> specifies the end time (in absolute or relative terms) for the data displayed on the graphing canvas.  The most frequently used value for the end time is &#8220;now&#8221;, which results in a graph showing the latest data.</p>
<p><em><code>--title</code></em> specifies the text to be displayed above the graphing canvas.</p>
<p><em><code>--vertical-label</code></em> specifies the text to be displayed next to the y-axis.  Typically, this indicates the units of the measurement.</p>
<h3>Examples</h3>
<h4>Example 1</h4>
<p>This basic example creates a graph with the filename &#8220;Example 1.png&#8221;.  As specified by the start and end dates, it encompasses the entire year of 2009.  The resulting PNG file will have a data canvas of 500 x 120 pixels, although the full size of the image will be larger to accommodate the legend and border.  This example uses only one data definition (DEF) which references the sysinfo.rrd file&#8217;s &#8220;load&#8221; data element (but note that the label for the DEF itself is called &#8220;sysload&#8221;).  The line directive (LINE1) in turn references the &#8220;sysload&#8221; label to draw a 1 pixel wide blue line.</p>
<blockquote><p><code>rrdtool graph "Example 1.png" \<br />
--start="Jan 1, 2009" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
DEF:sysload=sysinfo.rrd:load:AVERAGE \<br />
LINE1:sysload#0000FF</code></p></blockquote>
<h4>
<dl id="attachment_184">
<dt><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-1.png"><img class="aligncenter size-full wp-image-411" title="Example 1" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-1.png" alt="Example 1" width="581" height="168" /></a></dt>
</dl>
</h4>
<h4>Example 2</h4>
<p>This example is similar to the first with the exception that it illustrates the use of relative dates to define the graphing period.  In this case, the start time is defined as 2 weeks less than the end time.  A frequent use of relative dates is specifying the end time as &#8220;now&#8221; and the start time relative to that (such as &#8220;end-24 hours&#8221; or &#8220;end-1 week&#8221;).  Note also RRDTool adjusts the x-axis legend to reflect the different time span.</p>
<blockquote><p><code>rrdtool graph "Example 2.png" \<br />
--start="end-2 weeks" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
DEF:load=sysinfo.rrd:load:AVERAGE \<br />
LINE1:load#0000FF</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-2.png"><img class="aligncenter size-full wp-image-412" title="Example 2" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-2.png" alt="Example 2" width="581" height="168" /></a></p>
<h4>Example 3</h4>
<p>This example extends the previous example by adding an additional data definition and line.  Note that the lines are drawn <em>in the order they are specified</em>, which means that where lines overlap, the line specified <em>latest</em> in the graph command will be on top.</p>
<blockquote><p><code>rrdtool graph "Example 3.png" \<br />
--start="end-2 weeks" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
DEF:load=sysinfo.rrd:load:AVERAGE \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
LINE1:load#0000FF \<br />
LINE1:temp#FF0000</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-3.png"><img class="aligncenter size-full wp-image-413" title="Example 3" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-3.png" alt="Example 3" width="581" height="168" /></a></p>
<h4>Example 4</h4>
<p>Extending the example further, this iteration introduces some basic legend and title information.  This example creates a title for the graph (&#8220;Example 4&#8243;) and a label for the vertical axis (&#8220;Units&#8221;).  In addition, each of the line directives are amended to include a legend specification.  RRDTool will create the appropriate &#8220;color squares&#8221; for the legend entries.</p>
<blockquote><p><code>rrdtool graph "Example 4.png" \<br />
--start="end-2 weeks" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 4" \<br />
--vertical-label "Units" \<br />
DEF:load=sysinfo.rrd:load:AVERAGE \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
LINE1:load#0000FF:"System Load" \<br />
LINE1:temp#FF0000:"CPU Temperature"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-4.png"><img class="aligncenter size-full wp-image-414" title="Example 4" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-4.png" alt="Example 4" width="597" height="193" /></a></p>
<p>Example 5</p>
<p>This example simply illustrates a variation of the width of the line element.  In this case, the line representing the temperature has been specified as being 3 pixels wide (LINE3).  Line width can be specified as 1, 2 or 3 pixels wide.</p>
<blockquote><p><code>rrdtool graph "Example 5.png" \<br />
--start="end-2 weeks" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 5" \<br />
--vertical-label "Units" \<br />
DEF:load=sysinfo.rrd:load:AVERAGE \<br />
DEF:temp=sysinfo.rrd:temperature:AVERAGE \<br />
LINE1:load#0000FF:"System Load" \<br />
LINE3:temp#FF0000:"CPU Temperature"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-5.png"><img class="aligncenter size-full wp-image-417" title="Example 5" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-5.png" alt="Example 5" width="597" height="193" /></a></p>
<p>Example 6</p>
<p>This final example illustrates the use of different round-robin archives (RRAs) within a graph definition.  In this case, the different RRAs use a different consolidation function (CF) in order to record different aspects of the data patterns.  Specifying the MIN and MAX consolidation functions in the DEFs allow us to retrieve and plot the min and max temperature readings.</p>
<blockquote><p><code>rrdtool graph "Example 6.png" \<br />
--start="end-30 days" --end "Dec 31, 2009" \<br />
--imgformat PNG --width 500 --height 120 \<br />
--title "Example 6" \<br />
--vertical-label "Celsius" \<br />
DEF:mintemp=sysinfo.rrd:temperature:MIN \<br />
DEF:maxtemp=sysinfo.rrd:temperature:MAX \<br />
LINE1:mintemp#0000FF:"Minimum Temperature" \<br />
LINE1:maxtemp#FF0000:"Maximum Temperature"</code></p></blockquote>
<p><a href="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-6.png"><img class="aligncenter size-full wp-image-426" title="Example 6" src="http://wiki.springsurprise.com/wp-content/uploads/2010/09/Example-6.png" alt="Example 6" width="597" height="193" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.springsurprise.com/2010/09/20/rrdtool_line_graphs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

