use File::Basename ('dirname');
our $InDir = '/var/lib/collectd';
-our $OutDir = '/tmp/collectd-5';
-our $Hostname = 'localhost';
+our $RRDtool = 'rrdtool';
+our $RRDFilter = 'rrd_filter.px';
our %TypesCounterToDerive = # {{{
(
connections => ["value"],
cpu => ["value"],
current => ["value"],
- df => ["used", "free"],
disk_merged => ["read", "write"],
disk_octets => ["read", "write"],
disk_ops => ["read", "write"],
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})
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";
}
}
&& (!$plugin_inst) && ($type_inst))
{
my $dir = join ('/', @path);
- print "mv \"$path\" \"$dir/$plugin-$type_inst/$type.rrd\"\n";
+ print "mkdir -p \"$dir/$plugin-$type_inst\"\n";
+ if (($plugin eq 'df') and ($type eq 'df'))
+ {
+ print "$RRDFilter --infile=\"$path\" --outfile=\"$dir/$plugin-$type_inst/df_complex-free.rrd\" --map free:value\n";
+ print "$RRDFilter --infile=\"$path\" --outfile=\"$dir/$plugin-$type_inst/df_complex-used.rrd\" --map used:value\n";
+ }
+ else
+ {
+ print "mv \"$path\" \"$dir/$plugin-$type_inst/$type.rrd\"\n";
+ }
}
} # }}} sub handle_file
closedir ($dh);
} # }}} sub scan_dir
+sub exit_usage # {{{
+{
+ print STDERR <<EOF;
+migrate-4-5.px [OPTIONS]
+
+Valid options are:
+
+ --indir <dir> Source directory
+ Default: $InDir
+ --rrdtool <path> Path to the RRDtool binary
+ Default: $RRDtool
+ --rrdfilter <path> Path to the rrd_filter.px script
+ Default: $RRDFilter
+
+EOF
+ exit (1);
+} # }}} sub exit_usage
+
+GetOptions ("indir|i=s" => \$InDir,
+ "rrdtool=s" => \$RRDtool,
+ "rrdfilter=s" => \$RRDFilter,
+ "help|h" => \&exit_usage) or exit_usage ();
+
+print "#!/bin/bash\n\n";
+
scan_dir ($InDir);
# vim: set sw=2 sts=2 et fdm=marker :