2 # Copyright (C) 2006 Eric Clément
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # purpose : automatic generation of traces with LTT in a network.
16 # you need SSH connection without password for all computers that you want
17 # trace. You might put le name of those computers (uname -n) in a file
18 # (liste.txt by default). LTT might be installed in the same way for those
20 # You can customize your path. This script can also generate traffic TCP and
21 # UDP. A UDP monitor is use to validate the result (this is the first computer
22 # in the file (liste.txt)).
24 # usage: ./lttclt_distributed.sh time freq mode_generator {options}
26 # time (seconds) : duration a the tracing
27 # freq (nb packet/second or nb packet/ms) : communication frequency when TCP
28 # generator is used, 0 otherwise
29 # mode_generator : 1 : traffic generator off
30 # 2 : traffic generator TCP on (nb packet/second)
31 # 3 : traffic generator TCP on (nb packet/ms)
33 # options (optional): 1 : enable the UDP monitor (1packet/second is generated
36 # you need : ssh, scp and zip
44 PATH_TRACE
=/root
/trace-ltt
/
45 PATH_DEBUGFS
=/debugfs
/ltt
/
46 SET_LTT_FACILITIES
="export LTT_FACILITIES=/home/ercle/NEW_GENERATION_LTTV/share/LinuxTraceToolkitViewer/facilities/"
47 SET_LTT_DAEMON
="export LTT_DAEMON=/home/ercle/NEW_GENERATION_LTTV/bin/lttd"
49 START_DAEMON
="/home/ercle/NEW_GENERATION_LTTV/bin/lttctl -d -n \
50 trace1 -t $PATH_TRACE -l $PATH_DEBUGFS >/dev/null"
52 STOP_DAEMON
="/home/ercle/NEW_GENERATION_LTTV/bin/lttctl -n trace1 -q >/dev/null"
53 REMOVE_DAEMON
="/home/ercle/NEW_GENERATION_LTTV/bin/lttctl -n trace1 -r >/dev/null"
54 REMOVE_TRACE
="rm -rf $PATH_TRACE"
59 TRACE_DAEMON
=/tmp
/daemon-
63 echo "usage: $0 time freq mode_generator {options}"
67 echo "usage: $0 time freq mode_generator {options}"
84 #create script generator
87 if [ $mode_generator -eq 3 ]
89 TCP_CLIENT
=tcpclient_ms
93 for line
in $
( cat $FILE_LISTE );
97 echo $REMOVE_TRACE > "$FILE_OUT$line.sh"
98 echo mkdir
$PATH_TRACE >> "$FILE_OUT$line.sh"
99 echo $SET_LTT_FACILITIES >> "$FILE_OUT$line.sh"
100 echo $SET_LTT_DAEMON >> "$FILE_OUT$line.sh"
101 echo $START_DAEMON >> "$FILE_OUT$line.sh"
103 chmod +x
"$FILE_OUT$line.sh"
105 if [ $mode_generator -ge 2 ] #if generator de trafic enable (2 or 3)
107 if [ $nb_node -eq 1 -a $mode_monitor -eq 1 ]
110 echo "/tmp/$UDP_SERVER >/dev/null &" >> "$FILE_OUT$line.sh"
111 scp
"$UDP_SERVER" $line:/tmp
/
113 echo "sleep $time" >> "$FILE_OUT$line.sh"
114 echo "kill \`ps -A |grep $UDP_SERVER | awk '{ print \$1 }'\`" >> "$FILE_OUT$line.sh"
116 if [ $mode_monitor -eq 1 ]
118 echo "/tmp/$UDP_CLIENT $monitor $time 1 >/dev/null & " >> "$FILE_OUT$line.sh"
119 scp
"$UDP_CLIENT" $line:/tmp
/
122 echo "/tmp/$TCP_SERVER >/dev/null &" >> "$FILE_OUT$line.sh"
123 scp
"$TCP_SERVER" $line:/tmp
/
125 for line2
in $
( cat $FILE_LISTE );
128 if [ $compteur -gt $nb_node ]
130 echo "/tmp/$TCP_CLIENT $line2 $time $freq >/dev/null &" >> "$FILE_OUT$line.sh"
131 scp
"$TCP_CLIENT" $line:/tmp
/
135 echo "sleep $time" >> "$FILE_OUT$line.sh"
136 echo "kill \`ps -A |grep $TCP_SERVER | awk '{ print \$1 }'\`" >> "$FILE_OUT$line.sh"
140 echo $STOP_DAEMON >> "$FILE_OUT$line.sh"
141 echo $REMOVE_DAEMON >> "$FILE_OUT$line.sh"
143 #script for get node information
145 echo 'FILE_OUT=`uname -n`.info' >> "$FILE_OUT$line.sh"
146 echo 'ENDIAN=endian' >> "$FILE_OUT$line.sh"
147 echo ' exec 6>&1' >> "$FILE_OUT$line.sh"
148 echo ' exec > /tmp/$FILE_OUT' >> "$FILE_OUT$line.sh"
149 echo ' echo `uname -n`' >> "$FILE_OUT$line.sh"
150 echo '' >> "$FILE_OUT$line.sh"
151 echo ' /tmp/$ENDIAN || ( echo >&6 && echo "** ERROR **: problem occur with /tmp/$ENDIAN" >&6 && echo >&6)' >> "$FILE_OUT$line.sh"
152 echo '' >> "$FILE_OUT$line.sh"
153 echo -e ' /sbin/ifconfig | grep addr: | awk \047{print $2}\047 | sed /127.0.0.1/d | sed s/addr:// | sed /^$/d #english' >> "$FILE_OUT$line.sh"
154 echo -e ' /sbin/ifconfig | grep adr: | awk \047{print $2}\047 | sed /127.0.0.1/d | sed s/adr:// | sed /^$/d #french' >> "$FILE_OUT$line.sh"
155 echo ' echo END' >> "$FILE_OUT$line.sh"
156 echo '' >> "$FILE_OUT$line.sh"
157 echo ' exec 1>&6 6>&-' >> "$FILE_OUT$line.sh"
158 echo '' >> "$FILE_OUT$line.sh"
159 echo ' echo "$FILE_OUT done"' >> "$FILE_OUT$line.sh"
160 echo '' >> "$FILE_OUT$line.sh"
163 if [ $mode_generator -ge 2 -a $nb_node -eq 1 -a $mode_monitor -eq 1 ]
165 echo mv /tmp
/'`uname -n`'.info
/tmp
/'`uname -n`'.monitor
>> "$FILE_OUT$line.sh"
166 echo scp
/tmp
/'`uname -n`'.monitor
`uname -n`:`pwd`/ >> "$FILE_OUT$line.sh"
168 echo scp
/tmp
/'`uname -n`'.info
`uname -n`:`pwd`/ >> "$FILE_OUT$line.sh"
171 echo ' exit 0' >> "$FILE_OUT$line.sh"
173 scp
"$FILE_OUT$line.sh" $line:/tmp
/
174 scp
"$ENDIAN" $line:/tmp
/
175 rm "$FILE_OUT$line.sh"
177 #end script generator
182 for line
in $
( cat $FILE_LISTE );
184 echo ssh -f "$line $TRACE_DAEMON$line.sh "
185 ssh -f $line "$TRACE_DAEMON$line.sh"
189 echo "error: file $FILE_LISTE doesn't exist"
197 # is all daemon stop ?
198 for line
in $
( cat $FILE_LISTE );
201 daemon_present
="true"
203 while [ $daemon_present == "true" ]
205 daemon_present
="false"
206 (ssh $line ps
-A |
grep lttd
) && daemon_present
="true"
215 for line
in $
( cat $FILE_LISTE );
217 mkdir
`pwd`/$line 2>/dev
/null
218 scp
-q -r $line:$PATH_TRACE/ `pwd`/$line
219 zip_path
="$zip_path $line"
223 #get network informatioin
225 FILE_OUT
=network.trace
227 exec 3> $FILE_TMP #open FILE_TMP (Write)
229 ls *.monitor
>&3 2>/dev
/null
231 #get the list of .info file to parse
232 ls *.info
>&3 ||
(echo EMPTY
>&3)
235 exec 3>&- #close FILE_TMP
237 exec 3< $FILE_TMP #open FILE_TMP (Read)
239 if [ "$line" = "EMPTY" ]
242 exec 3>&- #close FILE_TMP
247 exec 5> $FILE_OUT #open FILE_OUT (Write)
249 echo -e "Nb IP\tName\t\endianness\tIP ..."
250 echo -e "Nb IP\tName\tendianness\tIP ..." >&5
252 while [ "$line" != "END" ]
254 echo "++++++++++++++++++++"
258 nb_ip
=-2 #1st line => name, 2 line => endianness
262 while [ "$answer" != "END" ]
264 nb_ip
=`expr $nb_ip + 1`
265 output
="$output\n$answer"
269 echo -e "$nb_ip$output"
270 echo -e "$nb_ip$output" >&5
272 mv $line "$line.read"
274 echo "---------------------"
277 exec 3>&- #close FILE_TMP
280 exec 5<&- #close FILE_OUT
284 cd $root && echo $root
285 nomfic
="trace__nb_computer"$nb_computer"__time"$time"__freq"$freq"__"`uname -n``date '+__%d%b__%H-%M-%S'`$options".zip"
287 zip -r $nomfic $zip_path *.info.
read *.monitor.
read *.trace
>/dev
/null
288 echo -e "zip done $zip_path\n$root/$nomfic"
This page took 0.071766 seconds and 4 git commands to generate.