#!/usr/bin/perl -w =head1 Author: TechFly Name: nmoncopy.pl Description: Copy all nmon files from the /tmp/nmonout folders on the machiens listed in the machinelistfilename. This will create a directory on the destination if needed, and will use SCP to copy the files. Then it will use SSH and delete the files (less two days from runtime) from the source. Start date: 7-20-2010 Last updated Date: 7-20-2010 =cut use strict; use warnings; use Net::SCP qw(scp); use Net::SSH qw(ssh); my $scp; my $machinelist; my $machinelistfilename = "./machinelist.txt"; my $server; open($machinelist, "<", $machinelistfilename)||die $!; print("\n"); while($server = <$machinelist>){ chomp($server); if(-d "./$server"){ copydata(); }else{ mkdir($server)||die $!; copydata(); } } sub copydata{ $scp = Net::SCP->new($server, "username"); $scp->get("/tmp/nmonout/*", "/export/nmon/$server/") or die $scp->{errstr}; ssh($server, "find /tmp/nmonout/ -mtime +2 |xargs rm"); }