diff --git a/scripts/AT-total.sh b/scripts/AT-total.sh new file mode 100755 index 0000000..d44f77a --- /dev/null +++ b/scripts/AT-total.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "-- Time update" +ntpdate europe.pool.ntp.org north-america.pool.ntp.org + +# schedule the entire set + +echo "-- Scheduling Jobs" +for i in {0..0} +do + delta=`expr \( ${2} / 60 + ${2} / 60 / 4 + 10 \)` + echo "$4/VM-run.sh $1 $2 $4" | at now + `expr $3 + $delta \* $i` minutes +done \ No newline at end of file diff --git a/scripts/TotalEC2.sh b/scripts/TotalEC2.sh new file mode 100755 index 0000000..2825f2a --- /dev/null +++ b/scripts/TotalEC2.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +basedir=/home/ubuntu + +# host list + +ec2host[0]="ec2-54-228-0-152.eu-west-1.compute.amazonaws.com" +ec2host[1]="ec2-46-51-139-8.eu-west-1.compute.amazonaws.com" +ec2host[2]="ec2-54-228-59-234.eu-west-1.compute.amazonaws.com" +ec2host[3]="ec2-54-228-50-84.eu-west-1.compute.amazonaws.com" +ec2host[4]="ec2-54-228-55-25.eu-west-1.compute.amazonaws.com" +ec2host[5]="ec2-54-247-148-0.eu-west-1.compute.amazonaws.com" +ec2host[6]="ec2-54-228-48-26.eu-west-1.compute.amazonaws.com" + +# ip list + +ip[0]=10.227.166.59 +ip[1]=10.227.113.104 +ip[2]=10.227.115.172 +ip[3]=10.48.211.15 +ip[4]=10.226.117.136 +ip[5]=10.226.195.131 +ip[6]=10.48.237.19 + +# duration time + +delay[0]=1800 +delay[1]=3600 +delay[2]=5400 +delay[3]=7200 +delay[4]=10800 +delay[5]=14400 +delay[6]=21600 +delay[7]=28800 + + +# Synchronize the local dir to the EC2 hosts and Remove the JOBS +for h in ${ec2host[@]} +do + echo =============================== +echo ---- RemoveJobs +ssh -i ./key/T0.pem ubuntu@$h "for i in `atq | awk '{print $1}'`;do atrm $i;done" + echo ---- Managing Tasks + ssh -i ./key/T0.pem ubuntu@$h "stop cron ; pkill java ; rm * -rf" + echo ---- Synchronize $h + rsync -auvz --delete -e "ssh -i ./key/T0.pem " ./* ubuntu@$h:$basedir +echo ---- RemoveJobs +ssh -i ./key/T0.pem ubuntu@$h "for i in `atq | awk '{print $1}'`;do atrm $i;done" +done + + +# Execute the AT script on the remote host + +#delta after start +mins=10 +numtest=1 # it is the test number in AT-total.sh +for d in ${delay[@]} +do + echo "**************** TEST WITH ${d} SECONDS" + echo Delay hours are: $hours + + index=0 + for h in ${ec2host[@]} + do + echo ---- AT Command on $h + echo "=== SSH: $basedir/AT-total.sh ${ip[index]} ${d} ${mins}" + ssh -i ./key/T0.pem ubuntu@$h "$basedir/AT-total.sh ${ip[index]} ${d} $mins $basedir" + index=$index+1 + done + # calculate the delay time of a test set + mins=`expr $mins + \( ${d} / 60 + ${d} / 60 / 4 + 10 \) \* $numtest` +done \ No newline at end of file diff --git a/scripts/TotalHaltEC2.sh b/scripts/TotalHaltEC2.sh new file mode 100755 index 0000000..90ad13b --- /dev/null +++ b/scripts/TotalHaltEC2.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +basedir=/home/ubuntu + +# host list + +ec2host[0]="ec2-54-228-0-152.eu-west-1.compute.amazonaws.com" +ec2host[1]="ec2-46-51-139-8.eu-west-1.compute.amazonaws.com" +ec2host[2]="ec2-54-228-59-234.eu-west-1.compute.amazonaws.com" +ec2host[3]="ec2-54-228-50-84.eu-west-1.compute.amazonaws.com" +ec2host[4]="ec2-54-228-55-25.eu-west-1.compute.amazonaws.com" +ec2host[5]="ec2-54-247-148-0.eu-west-1.compute.amazonaws.com" +ec2host[6]="ec2-54-228-48-26.eu-west-1.compute.amazonaws.com" + +# ip list + +ip[0]=10.227.166.59 +ip[1]=10.227.113.104 +ip[2]=10.227.115.172 +ip[3]=10.48.211.15 +ip[4]=10.226.117.136 +ip[5]=10.226.195.131 +ip[6]=10.48.237.19 + + +# Synchronize the local dir to the EC2 hosts and Remove the JOBS +for h in ${ec2host[@]} +do + echo =============================== + echo ---- Halting Tasks + ssh -i ./key/T0.pem ubuntu@$h "reboot" +done \ No newline at end of file diff --git a/scripts/TotalManageEC2.sh b/scripts/TotalManageEC2.sh new file mode 100755 index 0000000..1f16b59 --- /dev/null +++ b/scripts/TotalManageEC2.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +basedir=/home/ubuntu + +# host list + +ec2host[0]="ec2-54-228-0-152.eu-west-1.compute.amazonaws.com" +ec2host[1]="ec2-46-51-139-8.eu-west-1.compute.amazonaws.com" +ec2host[2]="ec2-54-228-59-234.eu-west-1.compute.amazonaws.com" +ec2host[3]="ec2-54-228-50-84.eu-west-1.compute.amazonaws.com" +ec2host[4]="ec2-54-228-55-25.eu-west-1.compute.amazonaws.com" +ec2host[5]="ec2-54-247-148-0.eu-west-1.compute.amazonaws.com" +ec2host[6]="ec2-54-228-48-26.eu-west-1.compute.amazonaws.com" + +# ip list + +ip[0]=10.227.166.59 +ip[1]=10.227.113.104 +ip[2]=10.227.115.172 +ip[3]=10.48.211.15 +ip[4]=10.226.117.136 +ip[5]=10.226.195.131 +ip[6]=10.48.237.19 + + +# Synchronize the local dir to the EC2 hosts and Remove the JOBS +for h in ${ec2host[@]} +do + echo =============================== +echo ---- RemoveJobs +ssh -i ./key/T0.pem ubuntu@$h "for i in `atq | awk '{print $1}'`;do atrm $i;done" + +echo ---- Managing Tasks +ssh -i ./key/T0.pem ubuntu@$h "pkill java; rm * -rf" + +done \ No newline at end of file diff --git a/scripts/VM-run.sh b/scripts/VM-run.sh new file mode 100755 index 0000000..5889795 --- /dev/null +++ b/scripts/VM-run.sh @@ -0,0 +1,17 @@ +echo ">>>>>>>>>>> Now" >> $3/log/stat.txt +date >> $3/log/stat.txt +echo ">>>>>>>>>>> Kill java processes" >> $3/log/stat.txt +pkill java >> $3/log/stat.txt +echo ">>>>>>>>>>> Java processes" >> $3/log/stat.txt +ps aux>> $3/log/stat.txt +echo ">>>>>>>>>>> Start --> CloRoFor.jar" >> $3/log/stat.txt +vmstat >> $3/log/stat.txt +java -XX:ErrorFile=/root/java_error%p.log -Xmx256M -jar $3/CloRoFor.jar -kp "$3/clorofor.keystore" -tf $3/topology.prop.xml -tIp $1 -d $2 -td $3/traces/ -cfg "$3/config.prop.xml" +vmstat >> $3/log/stat.txt +echo ">>>>>>>>>>> End --> CloRoFor.jar" >> "$3/log/stat.txt" +echo ">>>>>>>>>>> Netstat" >> $3/log/stat.txt +netstat -u -s >> $3/log/stat.txt +echo ">>>>>>>>>>> /proc/net/snmp" >> $3/log/stat.txt +cat /proc/net/snmp >> $3/log/stat.txt +echo ">>>>>>>>>>> Calculate traces" >> $3/log/stat.txt +./runParser.sh ./traces >> $3/log/stat.txt \ No newline at end of file diff --git a/scripts/removeJobs.sh b/scripts/removeJobs.sh new file mode 100755 index 0000000..060c0e9 --- /dev/null +++ b/scripts/removeJobs.sh @@ -0,0 +1,2 @@ +#!/bin/bash +for i in `atq | awk '{print $1}'`;do atrm $i;done \ No newline at end of file diff --git a/scripts/runParser.sh b/scripts/runParser.sh new file mode 100755 index 0000000..56f0cc7 --- /dev/null +++ b/scripts/runParser.sh @@ -0,0 +1 @@ +java -jar Parser.jar $1 \ No newline at end of file diff --git a/scripts/swapOn.sh b/scripts/swapOn.sh new file mode 100755 index 0000000..9261d8b --- /dev/null +++ b/scripts/swapOn.sh @@ -0,0 +1,14 @@ +echo "swap off" +sudo swapoff -a + +echo "restore the fstab" +sudo sh -c "sed -e '/^\/var\/swapfile.*$/,/^/d' /etc/fstab > /etc/fstab.new" +sudo cp /etc/fstab.new /etc/fstab + +echo "set the new Swap" +sudo dd if=/dev/zero of=/var/swapfile bs=1M count=3072 && +sudo chmod 600 /var/swapfile && +sudo mkswap /var/swapfile && +echo /var/swapfile none swap defaults 0 0 | sudo tee -a /etc/fstab && +sudo swapon -a +sudo swapon -s \ No newline at end of file