]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
Now migrating of qos rrds should work 2nd part done time for testing
authorManiacikarus <maniacikarus@ipfire.org>
Wed, 3 Sep 2008 21:12:25 +0000 (23:12 +0200)
committerManiacikarus <maniacikarus@ipfire.org>
Wed, 3 Sep 2008 21:12:25 +0000 (23:12 +0200)
config/qos/migrate.pl [new file with mode: 0755]
config/rootfiles/core/17/update.sh

diff --git a/config/qos/migrate.pl b/config/qos/migrate.pl
new file mode 100755 (executable)
index 0000000..48ef558
--- /dev/null
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+
+my $rrddir = "/var/log/rrd";
+my @files = `cd $rrddir && ls class_* `;
+
+if ( -e "$rrddir/migrated" ){print "Already migrated rrd files -> exit.\n";exit 1;}
+
+system("/etc/init.d/collectd stop");
+system("/usr/local/bin/qosctrl stop");
+
+foreach (@files){
+               chomp($_);
+               my @lines = `rrdtool dump $rrddir/$_`;
+               
+               my $fromhere = 0;
+               my @newlines = "<!-- Round Robin Database Dump --><rrd> <version> 0003 </version>
+       <step> 10 </step> <!-- Seconds -->
+       <lastupdate> </lastupdate>
+
+       <ds>
+               <name> bytes </name>
+               <type> COUNTER </type>
+               <minimal_heartbeat> 20 </minimal_heartbeat>
+               <min> 0.0000000000e+00 </min>
+               <max> NaN </max>
+
+               <!-- PDP Status -->
+               <last_ds> </last_ds>
+               <value> </value>
+               <unknown_sec> 0 </unknown_sec>
+       </ds>
+
+<!-- Round Robin Archives -->  <rra>
+               <cf> AVERAGE </cf>
+               <pdp_per_row> 1 </pdp_per_row> <!-- 10 seconds -->
+
+               <params>
+               <xff> 5.0000000000e-01 </xff>
+               </params>
+               <cdp_prep>
+                       <ds>
+                       <primary_value> </primary_value>
+                       <secondary_value> NaN </secondary_value>
+                       <value> NaN </value>
+                       <unknown_datapoints> 0 </unknown_datapoints>
+                       </ds>
+               </cdp_prep>
+               <database>
+";
+               foreach (@lines){
+                                               if ( $_ =~ /\<database\>/ ){
+                                                       $fromhere = 1;next;
+                                               }
+                                               if ( $_ =~ /\<\/database\>/ ){
+                                                       $fromhere = 0;next;
+                                               }
+                                               if ( $fromhere eq "0" ){
+                                                               next;
+                                               }else{
+                                                               my @t = split(/<v>/,$_);
+                                                               push(@newlines,$t[0]."<v>".$t[1]."</row>\n");
+                                               }
+               }
+push(@newlines,"               </database>
+       </rra>
+</rrd>");
+open(DATEI, ">/tmp/rrd.xml") || die "Unable to create temp file";
+print DATEI @newlines;
+close(DATEI);
+
+system("rm -f $rrddir/$_");
+system("rrdtool restore -f /tmp/rrd.xml $rrddir/$_");
+print "$_ ... resized\n";
+}
+
+system("/etc/init.d/collectd start");
+system("/usr/local/bin/qosctrl start");
+system("touch $rrddir/migrated");
+exit 0;
index aed2378fc1450f4f7bdd90d0626fa820d2d10b91..7622c197c935d47add5fbe8da854b2138a04a0ee 100644 (file)
@@ -5,3 +5,4 @@
 extract_files
 /etc/init.d/squid start
 perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
+perl -e "/var/ipfire/qos/bin/migrate.pl"