-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch-results.sh
executable file
·105 lines (97 loc) · 2.63 KB
/
fetch-results.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
#
# Script to fetch experiment results from the testbed
#
usage () {
echo "usage: $0 [ -d dir ]"
echo " options:"
echo " -d dir: directory containing the generated logs, if not specified the"
echo " 'RESULTS' directory will be used"
exit 1
}
while getopts ":d:" o; do
case "${o}" in
d)
DIR=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${DIR}" ]
then
DIR="RESULTS"
fi
echo -n `date +"%Y-%m-%d %H:%M:%S"`; echo " Fetching results from the control node"
if [ -d $DIR ]
then
echo "The output directory already exists, if you contiue all it's contents will be deleted."
read -p "Delete the output dir? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -r $DIR
else
exit 1
fi
fi
scp -F ssh-config -r node0:$DIR . > /dev/null
if [ $? -ne 0 ]
then
echo -n `date +"%Y-%m-%d %H:%M:%S"`; echo " Error copying the files, exiting"
exit 1
fi
# Extraction of the logfiles, the Directory structure is:
# OUTPUTDIR/runRUNNUMBER/[ tgz, logs ]
# eg. RESULTS/run3/tgz will contain the original compressed files
# RESULTS/run3/logs will contain all the raw logs ready to be analyzed
#
echo -n `date +"%Y-%m-%d %H:%M:%S"`; echo " Extracting the files"
cd $DIR
#ls
for d in `ls | grep run`
do
cd $d
for f in `ls *.tgz`
do
tar xzf $f
done
mkdir tgz
mkdir logs
#ls
mv *.tgz tgz/
mv node*-logs/* logs/
rm -r node*-logs
cd ..
done
cd ..
# Logs extracted, if this run is related to a Fabrikant topology we need to remove the logs related to the nodes used
# to generate the change in the network. These nodes are always the last three with highest ID.
echo "Extraction done. If this simulation is related to a Fabrikant topology, we need to remove the logs related to"
echo "the nodes used to generate the change in the network."
read -p "Is this simulation based on a Fabrikant topology? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
cd $DIR
for d in `ls | grep run`
do
cd ${d}/logs
# We have to remove the last three logfiles, but we must move the "RECONF" message from these nodes to the last
# node on the gadget
GADGETLAST=`ls | cut -d "_" -f3 | cut -d "." -f1 | sort -n | tail -4 | head -1`
GADGETLOG="log_h_${GADGETLAST}.log"
grep RECONF * | sed -E 's/^.*log://' >> $GADGETLOG
for f in `ls | cut -d "_" -f3 | cut -d "." -f1 | sort -n | tail -3`
do
LOGREMOVAL="log_h_${f}.log"
#echo "removing $LOGREMOVAL"
rm $LOGREMOVAL > /dev/null
done
cd ../../
done
cd ..
fi
echo -n `date +"%Y-%m-%d %H:%M:%S"`; echo " Fetching and extraction done. You can now analyze and plot the logs."