From: Florian Forster Date: Wed, 5 Jan 2011 09:15:32 +0000 (+0100) Subject: contrib/migrate-4-5.px: Add options parsing and help output. X-Git-Tag: collectd-5.0.0~27 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=9589c94b03e65c8eb66c6b8b27f7455c558e604d contrib/migrate-4-5.px: Add options parsing and help output. --- diff --git a/contrib/migrate-4-5.px b/contrib/migrate-4-5.px index efb2e0a1..1e54683a 100755 --- a/contrib/migrate-4-5.px +++ b/contrib/migrate-4-5.px @@ -33,7 +33,7 @@ use File::Basename ('dirname'); our $InDir = '/var/lib/collectd'; our $OutDir = '/tmp/collectd-5'; -our $Hostname = 'localhost'; +our $RRDtool = 'rrdtool'; our %TypesCounterToDerive = # {{{ ( @@ -167,7 +167,7 @@ sub handle_file # {{{ if ($TypesRenameDataSource{$type}) { my $old_ds = $TypesRenameDataSource{$type}; - print "rrdtool tune \"$path\" --data-source-rename ${old_ds}:value\n"; + print "$RRDtool tune \"$path\" --data-source-rename ${old_ds}:value\n"; } if ($TypesCounterToDerive{$type}) @@ -177,7 +177,7 @@ sub handle_file # {{{ for (@$ds_names) { my $name = $_; - print "rrdtool tune \"$path\" --data-source-type ${name}:DERIVE --minimum ${name}:0 --maximum ${name}:U\n"; + print "$RRDtool tune \"$path\" --data-source-type ${name}:DERIVE --minimum ${name}:0 --maximum ${name}:U\n"; } } @@ -217,6 +217,29 @@ sub scan_dir # {{{ closedir ($dh); } # }}} sub scan_dir +sub exit_usage # {{{ +{ + print STDERR < Source directory + Default: $InDir + --outdir Destination directory + Default: $OutDir + --rrdtool Path to the RRDtool binary + Default: $RRDtool + +EOF + exit (1); +} # }}} sub exit_usage + +GetOptions ("indir|i=s" => \$InDir, + "outdir|o=s" => \$OutDir, + "rrdtool=s" => \$RRDtool, + "help|h" => \&exit_usage) or exit_usage (); + scan_dir ($InDir); # vim: set sw=2 sts=2 et fdm=marker :