RDSで固まっているスレッドを検出して、個数をCloudWatchにプロットします。
閾値を600とします。
[rds-processlist-put.sh]
#!/bin/bash export EC2_REGION=ap-northeast-1 export AWS_CLOUDWATCH_HOME=/opt/aws/apitools/mon export JAVA_HOME=/usr/java/default PREFIX=".xxxxxxx.ap-northeast-1.rds.amazonaws.com" KEY=key.pem CERT=cert.pem HOST=$1 if [ "$HOST" = "" ]; then echo "usage: rds-processlist-put.sh {ID}" exit 1 fi RESULT=`mysql -h${HOST}${PREFIX} -u{user} -p{pass} -e "SELECT COUNT(*) FROM information_schema.PROCESSLIST where USER != 'rdsadmin' and TIME > 600;" | grep -v COUNT` ${AWS_CLOUDWATCH_HOME}/bin/mon-put-data --metric-name RDSProcessList --namespace "CustomAWS/RDS" --dimensions "DBInstanceIdentifier=${HOST}" --value $RESULT --ec2-private-key-file-path=${KEY} --ec2-cert-file-path=${CERT}
sh rds-processlist-put.sh {ID}
で実行します。