Created
January 25, 2017 11:36
-
-
Save hokkai7go/03346e0a442aa7bf5dc38fa3ad1d909c to your computer and use it in GitHub Desktop.
DynamoDBのストレージ容量(バイト単位)と項目数を出したときのスクリプト
This file contains hidden or 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/bash | |
table_list=`AWS_PROFILE=hoge aws dynamodb list-tables | jq -r '.TableNames[]'` | |
for table in $table_list | |
do | |
table_size=`AWS_PROFILE=hoge aws dynamodb describe-table --table-name $table| jq -r '.[].TableSizeBytes'` | |
if expr $table_size \< 1024 > /dev/null | |
then | |
table_size="${table_size} Bytes" | |
elif expr $table_size \< 10238976 > /dev/null | |
then | |
table_size=`expr $table_size / 1024` | |
table_size="${table_size} KB" | |
elif expr $table_size \< 10484711424 > /dev/null | |
then | |
table_size=`expr $table_size / 1048576` | |
table_size="${table_size} MB" | |
elif expr $table_size \< 10736344498176 > /dev/null | |
then | |
table_size=`expr $table_size / 1073741824` | |
table_size="${table_size} GB" | |
fi | |
table_item_count=`AWS_PROFILE=hoge aws dynamodb describe-table --table-name $table| jq -r '.[].ItemCount'` | |
echo "$table,$table_size,$table_item_count" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment