Skip to content

Commit

Permalink
experimentaton scripts
Browse files Browse the repository at this point in the history
uploaded scripts for the experiments (Amazon testbed)
  • Loading branch information
robo3945 committed Mar 13, 2016
1 parent b245211 commit 7c31fbf
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/AT-total.sh
Original file line number Diff line number Diff line change
@@ -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
72 changes: 72 additions & 0 deletions scripts/TotalEC2.sh
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions scripts/TotalHaltEC2.sh
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions scripts/TotalManageEC2.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions scripts/VM-run.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions scripts/removeJobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
for i in `atq | awk '{print $1}'`;do atrm $i;done
1 change: 1 addition & 0 deletions scripts/runParser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar Parser.jar $1
14 changes: 14 additions & 0 deletions scripts/swapOn.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7c31fbf

Please sign in to comment.