diff --git a/kvmstats b/kvmstats index dba85c1..588ef86 100755 --- a/kvmstats +++ b/kvmstats @@ -1,16 +1,25 @@ #!/bin/sh -# NOTE: kvmstats relies on the hxselect command to parse virsh' xml +# NOTE: kvmstats relies on the hxselect(1) command to parse virsh' xml # files. On Debian, this command is provided by the 'html-xml-utils' # package. set -e -u usage () { - echo 'usage: kvmstats.sh [-u K|M|G]' + echo 'usage: kvmstats.sh [-a] [-u K|M|G]' exit 1 } +for DEP in hxselect lvs tempfile bc +do + if [ -z "$(which $DEP)" ] + then + echo "kvmstats.sh: $DEP not found in \$PATH" 1>&2 + exit 1 + fi +done + POW=$(echo 1024 ^ 3 | bc) while [ $# -ne 0 ] && echo "$1" | grep -q '^-[[:alnum:]]' do @@ -42,15 +51,6 @@ done # since libvirt seems to store memoy in KiB, POW must be lowered by 1 POW=$((POW / 1024)) -for DEP in hxselect lvs tempfile -do - if [ -z "$(which $DEP)" ] - then - echo "kvmstats.sh: $DEP not found in \$PATH" 1>&2 - exit 1 - fi -done - TMPFILE=$(tempfile -s kvmstats) LVSOUT=$(tempfile -s kvmstats)