Created
June 28, 2012 15:24
-
-
Save kevinbringard/3011988 to your computer and use it in GitHub Desktop.
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
Put this on the jumphost for the environment you wish to gather numbers for: | |
#!/usr/bin/env bash | |
if [ -f /tmp/disk_utilization ]; then | |
rm /tmp/disk_utilization | |
fi | |
for i in $( ls -d /var/lib/nova/instances/instance* ); do | |
instance=$i | |
root_virtual=$( qemu-img info ${i}/disk | grep 'virtual size' | awk '{ print $3 }' ) | |
ephemeral_virtual=$( qemu-img info ${i}/disk.local | grep 'virtual size' | awk '{ print $3 }' ) | |
root_utilized=$( qemu-img info ${i}/disk | grep 'disk size' | awk '{ print $3 }' ) | |
ephemeral_utilized=$( qemu-img info ${i}/disk.local | grep 'disk size' | awk '{ print $3 }' ) | |
echo "$(hostname),$instance,$root_utilized,$ephemeral_utilized,$root_virtual,$ephemeral_virtual" >> /tmp/disk_utilization | |
done | |
cat /tmp/disk_utilization | |
This will create you a CSV with the following: | |
COMPUTE_HOSTNAME,INSTANCE,ROOT_UTILIZED,EPHEMERAL_UTILIZED,ROOT_ALLOCATED,EPHEMERAL_ALLOCATED | |
Get a list of compute hosts (you'll need to do this on the nova-controller): | |
sudo nova-manage service list | grep compute | awk '{ print $2 }' | |
c19p7 | |
c17p7 | |
... | |
c3p8 | |
c17p8 | |
c9p8 | |
Put that list in a file and iterate over it, running the script and then copying its output back to the jump host: | |
for i in $( cat ips ); do ssh jumpbox@${i} 'bash -s' < get_utilization.bash; scp jumpbox@${i}:/tmp/disk_utilization /tmp/disk_utilization.$i; done | |
Concatenate it all into a single file: | |
cd /tmp && for i in ls disk_utilization.*; do cat $i >> aggregated_disk_utilization; done | |
Run a quick see to get rid of the full directory path: | |
sed -i.bak aggregated_disk_utilization 's/\/var\/lib\/nova\/instances\/instance\///g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment