Upgraded hostap because of new madwifi hal release

Fixed and commented the migrate.pl
This commit is contained in:
Maniacikarus
2008-09-05 15:24:43 +02:00
parent 399aefdfe0
commit c8a726f165
4 changed files with 53 additions and 5 deletions

View File

@@ -1,18 +1,53 @@
#!/usr/bin/perl
###############################################################################
# #
# IPFire.org - A linux based firewall #
# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
# This skript will migrate all old rrd files with ADSL Optimizer Style to a
# custom IPFire one only collecting byte count for the QoS classes
# Fore testing purpose i recommend to copy your rrd files to /tmp and change
# the rrddir, then you are able to test the migration without problems
# Migration will take all classes rrd into count
my $rrddir = "/var/log/rrd";
my @files = `cd $rrddir && ls class_* `;
my @files = `cd $rrddir && ls class_*.rrd`;
# Ff migration was already done we will skip this to avoid errors
if ( -e "$rrddir/migrated" ){print "Already migrated rrd files -> exit.\n";exit 1;}
# Stop collectd and qos to ensure that no one further write to the rrds
system("/etc/init.d/collectd stop");
system("/usr/local/bin/qosctrl stop");
foreach (@files){
chomp($_);
# Dump the whole rrd file to human readable xml format into an array
my @lines = `rrdtool dump $rrddir/$_`;
# to ensure only needed raw data is extracted we will use a marker
my $fromhere = 0;
# because every rrd hase the same header we can use a general one deleting
# lastupdate and lastvalue they will be set the first time rrd is written
# after migration
my @newlines = "<!-- Round Robin Database Dump --><rrd> <version> 0003 </version>
<step> 10 </step> <!-- Seconds -->
<lastupdate> </lastupdate>
@@ -48,12 +83,18 @@ foreach (@files){
<database>
";
foreach (@lines){
# if database content line is found we will start to extract the values
if ( $_ =~ /\<database\>/ ){
$fromhere = 1;next;
}
# if database content is finished we will stop to extract the values
if ( $_ =~ /\<\/database\>/ ){
$fromhere = 0;next;
}
# if extraction is not set we will skip this line else we will extract
# only the first row and drop all the other ones, the new raw line
# will be written to and array
if ( $fromhere eq "0" ){
next;
}else{
@@ -61,19 +102,26 @@ foreach (@files){
push(@newlines,$t[0]."<v>".$t[1]."</row>\n");
}
}
# Add default footer to the array so a valid rrd xml file will be created
push(@newlines," </database>
</rra>
</rrd>");
# Now write the whole array to an xml file
open(DATEI, ">/tmp/rrd.xml") || die "Unable to create temp file";
print DATEI @newlines;
close(DATEI);
# Delete the old rrd file and restore a new one with content from the xml file
system("rm -f $rrddir/$_");
system("rrdtool restore -f /tmp/rrd.xml $rrddir/$_");
print "$_ ... resized\n";
}
# Now we can restart the collection
system("/etc/init.d/collectd start");
system("/usr/local/bin/qosctrl start");
# Finaly we will delete unneeded evt files and touch the migration file
system("rf $rrddir/*.evt");
system("touch $rrddir/migrated");
exit 0;