Created
December 18, 2011 18:25
-
-
Save iconara/1494095 to your computer and use it in GitHub Desktop.
How many cores do you have, punk?
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
EC2 = { | |
'm1.small' => {:ram => 1.7, :ecus => 1.0, :cores => 1, :storage => 160}, | |
'm1.large' => {:ram => 7.5, :ecus => 4.0, :cores => 2, :storage => 850}, | |
'm1.xlarge' => {:ram => 15.0, :ecus => 8.0, :cores => 4, :storage => 1690}, | |
't1.micro' => {:ram => 0.6, :ecus => 2.0, :cores => 1, :storage => 0}, # 613/1024 Gb RAM and actually less than 2 CPUs, but bursting up to 2 | |
'm2.xlarge' => {:ram => 17.1, :ecus => 6.5, :cores => 2, :storage => 420}, | |
'm2.2xlarge' => {:ram => 34.2, :ecus => 13.0, :cores => 4, :storage => 850}, | |
'm2.4xlarge' => {:ram => 68.4, :ecus => 26.0, :cores => 8, :storage => 1690}, | |
'c1.medium' => {:ram => 1.7, :ecus => 5.0, :cores => 2, :storage => 350}, | |
'c1.xlarge' => {:ram => 7.0, :ecus => 20.0, :cores => 8, :storage => 1690}, | |
'cc1.4xlarge' => {:ram => 23.0, :ecus => 33.5, :cores => 8, :storage => 1690}, # 2 x Intel Xeon X5570 quad-core “Nehalem” architecture CPUs | |
'cc2.8xlarge' => {:ram => 60.5, :ecus => 88.0, :cores => 16, :storage => 3370}, # 2 x eight-core Intel Xeon CPUs | |
'cg1.4xlarge' => {:ram => 22.0, :ecus => 33.5, :cores => 8, :storage => 1690} # 2 x Intel Xeon X5570, quad-core “Nehalem” architecture CPUs (+ 2 x NVIDIA Tesla “Fermi” M2050 GPUs) | |
} | |
instance_types = Hash.new(0) | |
blob = %x<ec2-describe-instances | grep running> | |
blob.split("\n").each do |line| | |
instance_type = line.split(/\s+/)[8] | |
instance_types[instance_type] += 1 | |
end | |
data = instance_types.reduce(Hash.new(0)) do |acc, (type, count)| | |
EC2[type].each do |metric, value| | |
acc[metric] += count * value | |
end | |
acc | |
end | |
p data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment