-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_instances.sh
56 lines (45 loc) · 1.37 KB
/
check_instances.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
#!/bin/sh
# check_instances.sh
#
# Copyright(c) 2013 Uptime Technologies, LLC.
. ./env.sh
function wait_for_instances()
{
MASTER=`grep ^INSTANCE /tmp/ec2-run-instances.log | awk '{ print $2 }' | head -1`
SLAVE=`grep ^INSTANCE /tmp/ec2-run-instances.log | awk '{ print $2 }' | tail -1`
while [ 1 ];
do cat /dev/null > /tmp/ec2-describe-instance-status.log
echo "Checking master node..."
echo "[instance]"
ec2-describe-instances \
--region ap-northeast-1 \
-O $AWS_ACCESS_KEY -W $AWS_SECRET_KEY \
$MASTER
echo "[status]"
ec2-describe-instance-status \
--region ap-northeast-1 \
-O $AWS_ACCESS_KEY -W $AWS_SECRET_KEY \
$MASTER \
| tee -a /tmp/ec2-describe-instance-status.log
echo
echo "Checking slave node..."
echo "[instance]"
ec2-describe-instances \
--region ap-northeast-1 \
-O $AWS_ACCESS_KEY -W $AWS_SECRET_KEY \
$SLAVE
echo "[status]"
ec2-describe-instance-status \
--region ap-northeast-1 \
-O $AWS_ACCESS_KEY -W $AWS_SECRET_KEY \
$SLAVE \
| tee -a /tmp/ec2-describe-instance-status.log
NUM=`grep INSTANCE /tmp/ec2-describe-instance-status.log | grep -v INSTANCESTATUS| awk '{ print $7 }' | grep -c ok`
echo "$NUM instance(s) ok."
if [ $NUM -eq 2 ]; then
break;
fi
sleep 10;
done;
}
wait_for_instances