The size property on the DescribeVolumes
returns the allocated size, but I would like to开发者_Go百科 know the current used size so that I can plan for requesting an EBS size increase.
if you're looking for 'used' size, then you'll need to do this using an operating system command fired from the instance to which this EBS is attached to.
On unix you can use df -Th
and check the values against your mount point. On windows, you can just use the 'My Computer' page to check this
It sounds like the intent of this question is to determine how much allocated EBS space you are using so you can know when you're about to hit your limit. Since Amazon has a default limit of 20T, hitting it unexpectedly (as I did) is not pleasant.
If you have the command line tools, a little bash magic gets you the answer:
t=0; for i in `ec2-describe-volumes | grep VOLUME | awk '{print $3}'`; do t=`expr $t + $i`; done; echo $t
(get the ticks right!)
Though it would be nice if amazon told you in an easy-to-find spot what your current allocated and max allowed is.
EDIT: there are now standard and provisioned iops ebs. The command above shows you the cumulative allocated of both types.
For standard ebs only:
t=0; for i in `ec2-describe-volumes | grep VOLUME | grep standard | awk '{print $3}'`; do t=`expr $t + $i`; done; echo $t
for provisioned-iops ebs only:
t=0; for i in `ec2-describe-volumes | grep VOLUME | grep io1 | awk '{print $3}'`; do t=`expr $t + $i`; done; echo $t
Inspired by rdickeyvii@'s answer above, a simple solution summing using jq
Get all sizes
aws ec2 describe-volumes | jq '.Volumes[] | .Size'
If you just care about certain volume types:
aws ec2 describe-volumes | jq '.Volumes[] | select(.VolumeType="gp2") | [.Size] | add'
Printout with a sum using jq
's add
echo "Total volume is $(aws ec2 describe-volumes | jq '.Volumes[] | select(.VolumeType="gp2") | .Size' | jq --slurp 'add') GB"
Looks like:
Total volume is 89708 GB
精彩评论