AS Monitoring-Svr Script


while true
rm req-values
#Get instance list
as-describe-auto-scaling-groups unni-autoscale-test | awk {‘print $2’} | grep -v unni-autoscale-test > inst-list

#retrieving public ip address from the instance address
for i in `cat /home/unni/as-test/inst-list`; do
ec2-describe-instances $i  | awk ‘{print $4}’ | grep >> ip-list

#retrieving access log values
for i in `cat /home/unni/as-test/ip-list`; do
ssh -i unni.pem -o StrictHostKeyChecking=no ubuntu@$i source /home/ubuntu/ >> req-values
done is the name of the script running in the host machines.

rm ip-list

#taking average and uploading it to cloudwatch
avg=`awk ‘{s+=$1} END {print “Average: ” s/NR}’ req-values | awk ‘{print $2}’`

mon-put-data -m “RequestCount” –namespace UnniCustomMetric –dimensions “instance=i-virtual01,servertype=apache” –value $avg -u Bytes



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s