Commit 97fff4d1 authored by Robert Ricci's avatar Robert Ricci

New script: savelogs. Copies .run capure logs for all nodes in an experiment to

/proj/<proj>/tiplogs/<exp>/ . If set, virutal node name are used for the
destination filename.

Run by batch_daemon on experiment termination, and also available to users
(through paperbag/plasticwrap) any time during an experiment.
parent 29403fd8
......@@ -1047,6 +1047,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tbsetup/tbreport tbsetup/named_setup tbsetup/exports_setup \
tbsetup/checkpass/GNUmakefile tbsetup/assign_wrapper tbsetup/ptopgen \
tbsetup/frisbeelauncher tbsetup/node_update tbsetup/webnodeupdate \
tbsetup/savelogs \
tip/GNUmakefile \
tmcd/GNUmakefile tmcd/freebsd/GNUmakefile tmcd/linux/GNUmakefile \
tmcd/netbsd/GNUmakefile \
......
......@@ -169,6 +169,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tbsetup/tbreport tbsetup/named_setup tbsetup/exports_setup \
tbsetup/checkpass/GNUmakefile tbsetup/assign_wrapper tbsetup/ptopgen \
tbsetup/frisbeelauncher tbsetup/node_update tbsetup/webnodeupdate \
tbsetup/savelogs \
tip/GNUmakefile \
tmcd/GNUmakefile tmcd/freebsd/GNUmakefile tmcd/linux/GNUmakefile \
tmcd/netbsd/GNUmakefile \
......
......@@ -24,7 +24,8 @@ my $TB = "@prefix@";
"node_update" => "$TB/bin/node_update",
"os_load" => "$TB/bin/os_load",
"create_image" => "$TB/bin/create_image",
"delay_config" => "$TB/bin/delay_config"
"delay_config" => "$TB/bin/delay_config",
"savelogs" => "$TB/bin/savelogs"
);
# Need to provide a simple path, because some scripts we call need one
......
......@@ -12,10 +12,10 @@ SUBDIRS = checkpass ns2ir
BIN_STUFF = power snmpit tbend tbswapin tbswapout tbprerun tbreport \
os_load savevlans startexp endexp batchexp killbatchexp \
node_reboot nscheck node_update
node_reboot nscheck node_update savelogs
# Stuff that mere users get on plastic.
USERBINS = os_load node_reboot nscheck node_update
USERBINS = os_load node_reboot nscheck node_update savelogs
SBIN_STUFF = resetvlans console_setup.proxy sched_reload named_setup \
batch_daemon exports_setup reload_daemon sched_reserve \
......
......@@ -41,6 +41,7 @@ my $tbbindir = "$TB/bin/";
my $batchdir = "$TB/batch";
my $startexp = "$TB/bin/startexp";
my $endexp = "$TB/bin/endexp";
my $savelogs = "$TB/bin/savelogs";
my $avail = "$TB/sbin/avail";
my $batchlog = "$TB/log/batchlog";
my $projroot = "/proj";
......@@ -410,7 +411,12 @@ sub startexp($)
sub endexp($)
{
my(%exphash) = @_;
#
# Save tiplogs
#
system("$savelogs $pid $eid");
system("$endexp -b $pid $eid");
my $exit_status = $? >> 8;
......
#!/usr/bin/perl
# Save the tiplogs from an experiment
sub usage {
print "Usage: $0 pid eid\n";
exit(-1);
}
#
# Configure variables
#
my $TB = "@prefix@";
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use libdb;
use libtestbed;
if (@ARGV != 2) {
&usage;
}
my ($pid,$eid) = @ARGV;
# XXX: This may need to be changed for use outside Utah
my $logdir = "/n/plastic/var/log/tiplogs";
my $tiplogdir = "/proj/$pid/tiplogs";
my $savedir = "$tiplogdir/$eid";
# Make sure the user is in the correct project
if (! ProjMember($pid)) {
die "You must be a member of project $pid to use this script\n";
}
# Now, we get a list of all nodes...
my $sth = DBQueryFatal("SELECT node_id, vname FROM reserved " .
"WHERE pid='$pid' AND eid='$eid'");
if ($sth->numrows == 0) {
die "No nodes found for experiment $eid in project $pid!\n";
}
print "Saving tiplogs for $pid/$eid to $savedir\n";
# We don't want directory creation to be modified by the user's umask,
# because the tiplogs directory needs to be kept group-writable.
my $savemask = umask 000;
# Create the directory (and its parent) if they don't exist
foreach $dir ($tiplogdir, $savedir) {
if (! -d $dir) {
print "Making directory $dir ...\n";
if (!mkdir($dir,0770)) {
die "Unable to make directory $dir: $!\n";
}
}
}
# Restore the saved umask
umask $savemask;
# Make sure the user can write to it
if (! -w $savedir) {
die "Unable to write to directory $savedir\n";
}
while (@row = $sth->fetchrow) {
my ($node, $vname) = @row;
if (!$vname) { # In case they don't have a vname...
$vname = $node;
}
my $runfile = "$logdir/$node.run";
my $savefile = "$savedir/$vname.log";
print "Copying $runfile to $savefile ...\n";
# Test to make sure the .run file exists
if (! (-e $runfile && -r $runfile) ) {
warn "Warning: $savefile does not exist or is not " .
"readable, skipping.\n";
next;
}
system "cp $runfile $savefile";
}
......@@ -24,7 +24,8 @@ my $TB = "@prefix@";
"node_update" => "$TB/bin/node_update",
"os_load" => "$TB/bin/os_load",
"create_image" => "$TB/bin/create_image",
"delay_config" => "$TB/bin/delay_config"
"delay_config" => "$TB/bin/delay_config",
"savelogs" => "$TB/bin/savelogs"
);
# Need to provide a simple path, because some scripts we call need one
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment