From 0f3c7a547527d5fa1271a1a5b4f60eb5dab1660f Mon Sep 17 00:00:00 2001 From: Maniacikarus Date: Wed, 3 Sep 2008 23:12:25 +0200 Subject: [PATCH] Now migrating of qos rrds should work 2nd part done time for testing --- config/qos/migrate.pl | 79 ++++++++++++++++++++++++++++++ config/rootfiles/core/17/update.sh | 1 + 2 files changed, 80 insertions(+) create mode 100755 config/qos/migrate.pl diff --git a/config/qos/migrate.pl b/config/qos/migrate.pl new file mode 100755 index 0000000000..48ef5585e6 --- /dev/null +++ b/config/qos/migrate.pl @@ -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 = " 0003 + 10 + + + + bytes + COUNTER + 20 + 0.0000000000e+00 + NaN + + + + + 0 + + + + AVERAGE + 1 + + + 5.0000000000e-01 + + + + + NaN + NaN + 0 + + + +"; + foreach (@lines){ + if ( $_ =~ /\/ ){ + $fromhere = 1;next; + } + if ( $_ =~ /\<\/database\>/ ){ + $fromhere = 0;next; + } + if ( $fromhere eq "0" ){ + next; + }else{ + my @t = split(//,$_); + push(@newlines,$t[0]."".$t[1]."\n"); + } + } +push(@newlines," + +"); +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; diff --git a/config/rootfiles/core/17/update.sh b/config/rootfiles/core/17/update.sh index aed2378fc1..7622c197c9 100644 --- a/config/rootfiles/core/17/update.sh +++ b/config/rootfiles/core/17/update.sh @@ -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" -- 2.39.2