Skip to content

Instantly share code, notes, and snippets.

@davidpelaez
Created June 12, 2014 09:00
Show Gist options
  • Save davidpelaez/41c4c3ac6c6f619f9244 to your computer and use it in GitHub Desktop.
Save davidpelaez/41c4c3ac6c6f619f9244 to your computer and use it in GitHub Desktop.
shell script to list all geard installed containers
#!/bin/bash
cd /var/lib/containers/units
units=$(find . -maxdepth 2 | grep '.service' | awk -F'/' '{print $3}')
keys=( LoadState ActiveState SubState UnitFileState )
result=""
for unit in $units; do
unit_info=$(systemctl show "$unit")
result="${result}${unit}"
#echo -n "$unit"
for query_key in "${keys[@]}"; do
result="$result $(echo "$unit_info" | grep $query_key | awk -F'=' '{printf " %s", $2}')"
done
result="$result\n"
done
echo -e "$result" | column -t -s ' '
@davidpelaez
Copy link
Author

Sampel output:

[root@localhost units]# gearls
ctr-busy.1.service    loaded    inactive    dead    enabled
ctr-busy.2.service    loaded    inactive    dead    enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment