stop-experiment 2.77 KB
Newer Older
1
#!/usr/bin/perl -w
Mike Hibler's avatar
Mike Hibler committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2006, 2007 University of Utah and the Flux Group.
Mike Hibler's avatar
Mike Hibler committed
5 6
# All rights reserved.
#
7 8

use strict;
9
use Getopt::Std;
10 11 12 13

my $TEVC = "/usr/testbed/bin/tevc";
my $LOGHOLE = "/usr/testbed/bin/loghole";

14
my $optlist = "nt";
15
my $nologs = 0;
16
my $sanityChecks = 0;
17 18 19 20 21 22 23 24 25

#
# Parse command arguments.
#
my %options = ();
if (!getopts($optlist, \%options)) {
    print "error: cannot parse options\n";
    exit(1);
}
26 27 28 29 30 31 32 33
#
# Require the pid and eid
#
if (@ARGV != 2) {
    die "Usage: $0 pid eid\n";
}
my ($pid, $eid) = @ARGV;

34 35 36 37
if (defined($options{"n"})) {
    $nologs = 1;
}

38 39 40 41
if (defined($options{"t"})) {
    $sanityChecks = 1;
}

42 43 44 45
#
# Stop the stubs and monitors
#
print "##### Stopping stubs and monitors\n";
46 47 48 49 50 51 52
if (system "$TEVC -e $pid/$eid now plabstubs stop") {
    die "Error running tevc\n";
}
if (system "$TEVC -e $pid/$eid now planetstubs stop") {
    die "Error running tevc\n";
}
if (system "$TEVC -e $pid/$eid now monitorgroup stop") {
53 54 55 56 57 58
    die "Error running tevc\n";
}

#
# Stop link tracing
#
59
print "##### Stopping link tracing\n";
60
if (system "$TEVC -e $pid/$eid now planet-tracemon snapshot") {
61 62
    die "Error running tevc\n";
}
63
if (system "$TEVC -e $pid/$eid now planet-tracemon stop") {
64 65
    die "Error running tevc\n";
}
66 67 68 69 70 71 72 73 74 75 76 77
if (system "$TEVC -e $pid/$eid now plabc-tracemon snapshot") {
    die "Error running tevc\n";
}
if (system "$TEVC -e $pid/$eid now plabc-tracemon stop") {
    die "Error running tevc\n";
}
if (system "$TEVC -e $pid/$eid now elabc-tracemon snapshot") {
    die "Error running tevc\n";
}
if (system "$TEVC -e $pid/$eid now elabc-tracemon stop") {
    die "Error running tevc\n";
}
78

79 80 81 82 83 84 85 86
#
# Smack down host tcpdumps
#
print "##### Stopping host tcpdumps\n";
if (system "$TEVC -e $pid/$eid now tdhosts stop") {
    die "Error running tevc\n";
}

87 88 89 90 91
print "##### Stopping sanity check tcpdumps\n";
if (system "$TEVC -e $pid/$eid now sanityCheckDumps stop") {
    die "Error running tevc\n";
}

92 93 94 95 96 97 98 99
#
# Stop running servers
#
print "##### Stopping servers\n";
if (system "$TEVC -e $pid/$eid now allservers stop") {
    die "Error running tevc\n";
}

100 101 102
#
# Grab logfiles
#
103 104
if (!$nologs) {
    print "##### Gathering logfiles\n";
105
    if (system "$LOGHOLE -e $pid/$eid sync -P") {
106 107
	die "Error running loghole\n";
    }
108

109 110 111 112 113 114 115 116
    # Run cross-correlation checks on the collected Tcpdump files.
    if ($sanityChecks) {
        print "##### Running cross-correlation sanity checks\n";
        if (system "python SanityCheck.py -t -u /proj/$pid/exp/$eid/") {
            die "Error running cross-correlation sanity check\n";
        }
    }

117 118 119 120
    #
    # Create an archive containing these logfiles
    #
    print "##### Creating archive\n";
121 122 123
    if (system "$LOGHOLE -e $pid/$eid archive") {
	die "Error running loghole\n";
    }
124 125
} else {
    print "##### Ignoring logfiles\n";
126 127
}

128

129 130
print "##### Done\n";