Created
May 10, 2016 03:09
-
-
Save wokamoto/6b0cc19abe53128db959db3b1455079c to your computer and use it in GitHub Desktop.
[AWS] カスタムメトリクスでメールキュー監視するためのやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# EC2 のインスタンス ID を取得 | |
instanceid=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
# region を取得 | |
az=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone) | |
_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