Skip to content

Instantly share code, notes, and snippets.

Created May 10, 2016 03:09
What would you like to do?
[AWS] カスタムメトリクスでメールキュー監視するためのやつ
# EC2 のインスタンス ID を取得
instanceid=$(curl -s
# region を取得
az=$(curl -s
_length=$(echo $((${#az} - 1)))
region=$(echo ${az} | cut -c 1-${_length})
# mailq
mailq=$(mailq | grep 'Total requests' | awk '{print $3}')
aws cloudwatch put-metric-data \
--region ${region} \
--namespace "System/Linux" \
--dimensions InstanceId=${instanceid} \
--unit Count \
--metric-name "MailQueu" \
--value "$mailq"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment