1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## migrate-4-5-df.dpatch by Florian Forster <octo@collectd.org>
3 ##
4 ## DP: contrib/migrate-4-5.px: Break up "df" RRD files into multiple files.
5 ## DP: cf. upstream commit 605dab534eb2f0ee26446c157c9fdd2ad6e9427a
7 @DPATCH@
9 diff --git a/contrib/migrate-4-5.px b/contrib/migrate-4-5.px
10 index d3ff796..c39b51b 100755
11 --- a/contrib/migrate-4-5.px
12 +++ b/contrib/migrate-4-5.px
13 @@ -33,6 +33,7 @@ use File::Basename ('dirname');
15 our $InDir = '/var/lib/collectd';
16 our $RRDtool = 'rrdtool';
17 +our $RRDFilter = 'rrd_filter.px';
19 our %TypesCounterToDerive = # {{{
20 (
21 @@ -184,7 +185,15 @@ sub handle_file # {{{
22 {
23 my $dir = join ('/', @path);
24 print "mkdir -p \"$dir/$plugin-$type_inst\"\n";
25 - print "mv \"$path\" \"$dir/$plugin-$type_inst/$type.rrd\"\n";
26 + if (($plugin eq 'df') and ($type eq 'df'))
27 + {
28 + print "$RRDFilter --infile=\"$path\" --outfile=\"$dir/$plugin-$type_inst/df_complex-free.rrd\" --map free:value\n";
29 + print "$RRDFilter --infile=\"$path\" --outfile=\"$dir/$plugin-$type_inst/df_complex-used.rrd\" --map used:value\n";
30 + }
31 + else
32 + {
33 + print "mv \"$path\" \"$dir/$plugin-$type_inst/$type.rrd\"\n";
34 + }
35 }
36 } # }}} sub handle_file
38 @@ -223,10 +232,12 @@ migrate-4-5.px [OPTIONS]
40 Valid options are:
42 - --indir <dir> Source directory
43 - Default: $InDir
44 - --rrdtool <path> Path to the RRDtool binary
45 - Default: $RRDtool
46 + --indir <dir> Source directory
47 + Default: $InDir
48 + --rrdtool <path> Path to the RRDtool binary
49 + Default: $RRDtool
50 + --rrdfilter <path> Path to the rrd_filter.px script
51 + Default: $RRDFilter
53 EOF
54 exit (1);
55 @@ -234,8 +245,11 @@ EOF
57 GetOptions ("indir|i=s" => \$InDir,
58 "rrdtool=s" => \$RRDtool,
59 + "rrdfilter=s" => \$RRDFilter,
60 "help|h" => \&exit_usage) or exit_usage ();
62 +print "#!/bin/bash\n\n";
63 +
64 scan_dir ($InDir);
66 # vim: set sw=2 sts=2 et fdm=marker :