简体   繁体   English

在AWS中已经利用了AWS预留实例?

[英]Getting already utilized AWS Reserved Instances in AWS?

I am currently running the following query 我目前正在运行以下查询

aws ec2 describe-reserved-instances    \
  --filters "Name=state,Values=active" \
  --query "ReservedInstances[].{InstanceType:InstanceType,ProductDescription:ProductDescription,InstanceCount:InstanceCount}"

In order to obtain something resembling the following: 为了获得类似于以下内容的内容:

{
    "ProductDescription": "Linux/UNIX (Amazon VPC)",
    "InstanceType": "m3.medium",
    "InstanceCount": 44
}

I am looking to get the instances already utilized though as well and am not finding a sane way to do this I would like a report showing the following information. 我希望同时也能利用这些实例,但并没有找到一种明智的方式来完成此操作,我想要一份显示以下信息的报告。

{
    "ProductDescription": "Linux/UNIX (Amazon VPC)",
    "InstanceType": "m3.medium",
    "InstanceCount": 44,
    "InstancesUsed": 44,
    "UtilizationPercentage": "100%"
}

How would I end up with instances used along with utilization percentage? 我最终将如何使用实例以及利用率百分比?

NOTE 注意

In order to get percentage I can variable cast, then use the following... 为了获得百分比,我可以进行变量转换,然后使用以下方法...

Percentage() { echo "$((200*$1/$2 % 2 + 100*$1/$2))%" ; }

Percentage 44 44 //100%

Well, AWS doesn't work like this. 好吧,AWS不能这样工作。 Reserved instances are not "utilized" or "not utilized" on EC2 level. 在EC2级别上未“利用”或“未利用”保留的实例。 The magic happens in billing. 魔术发生在计费中。 When Amazon bills you, it will match instances that were running against instances that were reserved. 当Amazon向您收费时,它将匹配正在运行的实例与保留的实例。 That means that you can't get that information with aws ec2 . 这意味着您无法通过aws ec2获得该信息。 The only thing you can do is to try to calculate which running instances are covered by reserved instances by yourself. 您唯一可以做的就是尝试自己计算保留实例覆盖哪些正在运行的实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM