<?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>hmmm.... &#187; rrd</title>
	<atom:link href="http://michael.thegrebs.com/tag/rrd/feed/" rel="self" type="application/rss+xml" />
	<link>http://michael.thegrebs.com</link>
	<description></description>
	<lastBuildDate>Thu, 27 Oct 2011 18:48:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Adding a Datastore to an RRD File</title>
		<link>http://michael.thegrebs.com/2007/12/30/adding-a-datastore-to-an-rrd-file/</link>
		<comments>http://michael.thegrebs.com/2007/12/30/adding-a-datastore-to-an-rrd-file/#comments</comments>
		<pubDate>Sun, 30 Dec 2007 18:17:13 +0000</pubDate>
		<dc:creator>mikegrb</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[neat]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[rrd]]></category>

		<guid isPermaLink="false">http://michael.thegrebs.com/2007/12/30/adding-a-datastore-to-an-rrd-file/</guid>
		<description><![CDATA[Mainly for personal future reference. Adding a DS to a bunch of RRD files is a big pain, RRD doesn&#8217;t have any sort of native mechanism for doing this. The usual procedure is exporting the RRD data to XML, creating &#8230; <a href="http://michael.thegrebs.com/2007/12/30/adding-a-datastore-to-an-rrd-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Mainly for personal future reference.</p>
<p>Adding a DS to a bunch of RRD files is a big pain,  RRD doesn&#8217;t have any sort of native mechanism for doing this.  The usual procedure is exporting the RRD data to XML, creating a new rrd file with the old datastores plus your new ones, then importing the data back in from the XML.</p>
<p>A while back I needed to do this for a load of RRDs so I wrote a quick and dirty bash script for it.  Today I had reason to add a DS again but couldn&#8217;t find my script.  A bit of googling was no help either, surely other people have this problem too?  I discovered Nicola Worthington&#8217;s <a href="http://search.cpan.org/~nicolaw/RRD-Simple/lib/RRD/Simple.pm">RRD::Simple</a> contains add_source method so a few moments in <a href="http://macromates.com/">TextMate</a> later we have:</p>
<pre class="textmate-source black_pearl"><span class="source source_perl"></span><span class="meta meta_comment meta_comment_full-line meta_comment_full-line_perl"></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_perl"></span><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_perl">#</span>!/usr/bin/perl

<span class="keyword keyword_control keyword_control_perl">use</span> strict;
<span class="keyword keyword_control keyword_control_perl">use</span> warnings;

<span class="keyword keyword_control keyword_control_perl">use</span> RRD::Simple();

<span class="storage storage_modifier storage_modifier_perl">my</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">$</span>rrd_path = <span class="string string_quoted string_quoted_double string_quoted_double_perl"></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_perl">"</span>/path/to/dir/of/rrds/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_perl">"</span>;
<span class="storage storage_modifier storage_modifier_perl">my</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">@</span>rrd_files = &lt;<span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">$</span>rrd_path/*.rrd&gt;;

<span class="storage storage_modifier storage_modifier_perl">my</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">$</span>rrd = RRD::Simple<span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_perl">-&gt;</span>new();

<span class="keyword keyword_control keyword_control_perl">for</span> <span class="storage storage_modifier storage_modifier_perl">my</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">$</span>file (<span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">@</span>rrd_files) {
<span class="meta meta_leading-tabs"></span><span class="meta meta_odd-tab">    </span><span class="support support_function support_function_perl">print</span> <span class="string string_quoted string_quoted_double string_quoted_double_perl"></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_perl">"</span>Processing <span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">$</span>file...<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_perl">"</span>;
<span class="meta meta_leading-tabs"></span><span class="meta meta_odd-tab">    </span><span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">$</span>rrd<span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_perl">-&gt;</span>add_source(<span class="variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_perl"></span><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_perl">$</span>file, <span class="string string_quoted string_quoted_single string_quoted_single_perl"></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_perl">'</span>DS_name<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_perl">'</span><span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_perl"> =&gt;</span> <span class="string string_quoted string_quoted_single string_quoted_single_perl"></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_perl">'</span>DERIVE<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_perl">'</span>);
<span class="meta meta_leading-tabs"></span><span class="meta meta_odd-tab">    </span><span class="support support_function support_function_perl">print</span> <span class="string string_quoted string_quoted_double string_quoted_double_perl"></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_perl">"</span> ok.<span class="constant constant_character constant_character_escape constant_character_escape_perl">\n</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_perl">"</span>;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://michael.thegrebs.com/2007/12/30/adding-a-datastore-to-an-rrd-file/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

