レイテンシを測る必要のある状況ってあまりないと思いますが・・・・
vim latency-put.sh --- #!/bin/bash CHECK_URL="{レスポンスタイムを測りたいURL}" REGION="ap-northeast-1" STATUS="/tmp/latency_status" export AWS_ACCESS_KEY_ID="{accesskey}" export AWS_SECRET_ACCESS_KEY="{secretkey}" SERVER=`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id` LATENCY=`curl -kL "${CHECK_URL}" -o /dev/null -w "%{time_total}" 2> /dev/null` /usr/bin/aws cloudwatch put-metric-data --metric-name web-latency --namespace "EC2: MONITOR" --dimensions "InstanceId=$SERVER" --unit "Seconds" --value ${LATENCY} --region ${REGION} ---
crontab -e --- */1 * * * * /bin/bash -l /root/scripts/latency-put.sh 2>> /var/log/cloudwatch/latency-error.log ---