Created
January 20, 2012 13:24
-
-
Save threetee/1647365 to your computer and use it in GitHub Desktop.
Opscode Chef - List/count EC2 instance AZ placement for your nodes with knife
This file contains 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/sh | |
# Prints the number of nodes you have in each EC2 AZ | |
knife exec -E 'nodes.transform("*:*") {|n| puts "#{n.ec2.placement_availability_zone}"}' | awk ' | |
{ | |
for (i=1;i<=NF;i++) | |
count[$i]++ | |
} | |
END { | |
for (i in count) | |
print count[i], i | |
}' $* | sort -r |
This file contains 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/sh | |
# Lists your nodes and their EC2 AZ placement | |
knife exec -E 'nodes.transform("*:*") {|n| puts "#{n.name}: #{n.ec2.placement_availability_zone}"}' | sort | |
# Note that you can get the same data with the knife search command below, but using knife exec lets you control the output format | |
# $ knife search node '*:*' -a ec2.placement_availability_zone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment