OpenStack One-Liners

One-line bash commands for managing, deploying and testing OpenStack and related components, hypervisors and containers.  Some simple and obvious, some cool and questionable, hopefully all useful.  Check back on this post, I’ll likely add more.

#1 – Watch Nova Compute for Non-Active Instances on Openstack

Outputs total instance count and non-active instances. Useful for keeping an eye on potential problem VMs in a PAUSED, ERROR, SHUTOFF or other non-active state.

Command:
watch --interval=1 'nova list --all-tenants | wc -l && nova list --all-tenants | grep -v "ACTIVE"'

nova-tenant-list

#2 – Ping a List of Hosts Forever:  1-Line Loop

A simple one-line while loop containing a for loop to ping a list of hosts each with one packet, followed by a 1/4 second iteration delay and an output text filter.

Command:
while true; do for h in bcu vxu rbu; do ping ${h} -c 1 | grep ttl; sleep 0.25; done; done;

ping-output

 

#3 – Watch Cinder Volumes and Snapshots and Glance Images in Openstack

Useful for working with volumes, snapshots and images in small Openstack deployments.

watch --interval=1 "cinder list && cinder snapshot-list && glance image-list"

command output, cinder & glance lists

command output, cinder & glance lists

 

#4 – Watch Linux Containers and Directory-Backed Storage

I find this one handy when I need to monitor LXC containers on Ubuntu Server – Precise Pangolin, Trusty Tahr, Utopic Unicorn and later.  The Ubuntu Server Guide has a detailed section on LXC usage.

watch "sudo lxc-ls --fancy --nesting && sudo ls -Ralh /var/lib/lxc/"

 

#5 – Watch Your Disk Space Disappear 🙂

This is a tail-style output of the free space on /.

while true; do df -h / | grep '\/' | awk '{ print $4 }'; sleep 1; done

6.1G
6.1G
6.0G
6.0G
5.9G
5.8G
5.7G
5.7G

 

Comment is closed.