#!/usr/bin/perl -w

use strict;
use File::Glob qw( :glob );
use File::Basename;

my $RRA_RESIZE = "./rra_resize.pl";

my @hosts = qw(
	host1
	host2
);

my $rra_root = '/usr/local/cacti/rra';
my $new_root = '/usr/local/cacti/resize_script/new';

my @target_files;

foreach my $host ( @hosts ) {
	my $search = "$rra_root/${host}_traffic_*";
	$search =~ s/\./_/g;
	$search =~ tr/-//d;
	$search .= '.rrd';
	my @list = bsd_glob( $search ) ;

	push @target_files, @list;
}


foreach my $input_file ( @target_files ) {
	my $basename = basename( $input_file );
	my $output_file = "$new_root/$basename";
	my $in_size = -s $input_file;
	my $out_size = -s $output_file;
	print STDERR "$input_file ($in_size)\n    to $output_file ($out_size)\n";
	system "$RRA_RESIZE $input_file $output_file";
}

local $, = "\n";
print @target_files;
print "\n";
