是否有任何命令/工具/脚本来对ec2-describe-images
或ec2-describe-instances
的大量输出进行分类。分类ec2-describe-images或ec2-describe-instances的输出
我有大约100个服务器的列表,每个细节都有。我想将它们归类为合适的标题,例如 - RESERVATION
,INSTANCE
,BLOCKDEVICE
,TAG
(无论输出中是否有可用的类别)。
是否有任何命令/工具/脚本来对ec2-describe-images
或ec2-describe-instances
的大量输出进行分类。分类ec2-describe-images或ec2-describe-instances的输出
我有大约100个服务器的列表,每个细节都有。我想将它们归类为合适的标题,例如 - RESERVATION
,INSTANCE
,BLOCKDEVICE
,TAG
(无论输出中是否有可用的类别)。
这是awk
(或perl
,python
或其他通用脚本语言)的工作。
awk
可以处理各种记录/字段长度的记录,可以创建关联数组,它是一种报告语言,通常安装在每个* nix上。
你是否得到这个排序?如果不是......
运行EC2-描述图像的选项--headers给你的类别
ec2-describe-images --private-key ~/private.key --cert ~/my.crt --region us-west-1 --headers
如果你只是想某些领域则刚管的上方通过输出linux命令截取选取你之后的字段(列)。假设你需要ImageID,Name和Architecture,那么这些将是上面输出的字段2,3和8。例。
ec2-describe-images --private-key ~/private.key --cert ~/my.crt --region us-west-1 --headers | cut -f2,3,8 -s
做了EC2-描述-情况同样是相似的。
添加到您的〜/ .bashrc或者〜/ .bash_profile:
ez-ec2-describe-instances() {
ec2-describe-instances $* --headers | egrep '(ReservationID|running|pending)'|cut -f 2,3,4,6,7,10,12;
}
注销/登录或运行 “在〜/ .bashrc”。然后你可以使用:
$ ez-ec2-describe-instances
ReservationID Owner Groups
i-6f194113 ami-1624987f ec2-107-20-75-13.compute-1.amazonaws.com running t1.micro us-east-1a
您可以将参数传递给EZ-EC2-描述,实例,就像你把它们传递到正规的EC2-描述-实例。例如:
$ ez-ec2-describe-instances --region eu-west-1
ReservationID Owner Groups
i-e4fd6eaf ami-c37474b7 ec2-54-246-38-35.eu-west-1.compute.amazonaws.com pending t1.micro eu-west-1a
请举一个'ec2-describe-images'输出的例子。 如果您可以在此处报告您发布在http://www.linuxquestions.org/questions/showthread.php?p=4574853#post4574853上的同一问题的回复,我们也将非常感激。 – olibre 2012-01-15 20:55:15