[collectd] [PATCH] migrate-3-4.px: Use 'rrdtool tune' instead of 'sed' to rename DS's.

Sebastian Harl sh at tokkee.org
Fri Apr 4 22:05:48 CEST 2008


Either the output format of 'rrdtool dump' has changed or there was an
error in the regex used with sed in the first place. Anyway, in some cases
the 'if_octects' DS's did not get translated. 'rrdtool tune' should be
able to handle it correctly in any case.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---

NOTE: Due to the lack of some test-case, this patch is currently
untested - so feedback and / or review would be welcome!

---
 contrib/migrate-3-4.px |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/contrib/migrate-3-4.px b/contrib/migrate-3-4.px
index 673929c..bb5bc94 100755
--- a/contrib/migrate-3-4.px
+++ b/contrib/migrate-3-4.px
@@ -169,22 +169,23 @@ for (@Files)
 			print "./rrd_filter.px -i '$InDir/$orig_filename' -m '${src_ds}:${dst_ds}' -o '$OutDir/$dest_filename'\n";
 		}
 	}
-	elsif (exists ($TypeRename{$orig->{'type'}}))
+	else
+	{
+		print "cp '$InDir/$orig_filename' '$OutDir/$dest_filename'\n";
+	}
+
+	if (exists ($TypeRename{$orig->{'type'}}))
 	{
 		my $src_dses = $TypeRename{$orig->{'type'}}->{'from'};
 		my $dst_dses = $TypeRename{$orig->{'type'}}->{'to'};
-		my @sed_prog = ();
 
+		print "rrdtool tune '$OutDir/$dest_filename'";
 		for (my $i = 0; $i < @$src_dses; $i++)
 		{
-			push (@sed_prog, 's/^' . $src_dses->[$i] . '$/' . $dst_dses->[$i] . '/g;');
+			print " --data-source-rename "
+				. $src_dses->[$i] . ':' . $dst_dses->[$i];
 		}
-
-		print "rrdtool dump '$InDir/$orig_filename' | sed -e '" . join (' ', @sed_prog) . "' | rrdtool restore - '$OutDir/$dest_filename'\n";
-	}
-	else
-	{
-		print "cp '$InDir/$orig_filename' '$OutDir/$dest_filename'\n";
+		print "\n";
 	}
 }
 
-- 
1.5.5.rc2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080404/b171c48d/attachment.pgp 


More information about the collectd mailing list