1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#!/bin/bash
set -x
set -e
declare -a machines
declare -a files
declare -a dotfiles
export PERL5LIB=lib:$PERL5LIB
PROGNAME="$(basename "$0")"
TEMP=`getopt --shell sh \
-o hvm --long with-vm,merge-only: \
-n "$PROGNAME" -- "$@"`
eval set -- "$TEMP"
WITH_VM=0
MERGE_ONLY=0
while true ; do
case "$1" in
-h|--help) usage ; exit 0 ;;
-v|--with-vm) WITH_VM=1 ;;
-m|--merge-only) MERGE_ONLY=1 ;;
--) shift ; break ;;
*) echo "Unknown option/argument '$1'" ; exit 1 ;;
esac
shift;
done
for m in "$@"; do
machines+=( "$m" )
if [ $WITH_VM = 1 ]; then
domain="$(echo "$m" | sed -e 's/^[^.]*//')"
machines+=( $(ssh "$m" virsh -c qemu:///system list | grep running | awk '{print $2"'"$domain"'" }' | sort ) )
fi
done
for m in "${machines[@]}"; do
f="$(echo "$m" | sed -e 's/[.].*//')"
files+=("$f")
dotfiles+=("/tmp/$f.dot")
if [ $MERGE_ONLY != 1 ]; then
bin/storage2dot --remote "$m" -c --record /tmp/$f.rawdata -o /tmp/$f.data
bin/storage2dot --data /tmp/$f.data -o /tmp/$f.dot
dot -Tpdf > /tmp/$f.pdf /tmp/$f.dot
fi
done
if [ ${#machines[@]} -gt 1 ]; then
f="${files[0]}"-all
bin/storage-merge-dots "${dotfiles[@]}" > /tmp/"$f".dot
dot -Tpdf > /tmp/"$f".pdf /tmp/"$f".dot
fi
echo "*** evince /tmp/"$f".pdf"
|