[kvmstats] use xargs instead of variables
This commit is contained in:
parent
a1c96fd929
commit
7ead702375
18
kvmstats
18
kvmstats
|
@ -47,16 +47,16 @@ done
|
|||
|
||||
for VM in $(virsh list --name --all)
|
||||
do
|
||||
CPU=$(virsh vcpucount --maximum --current "$VM")
|
||||
echo "$VM"
|
||||
virsh vcpucount --maximum --current "$VM"
|
||||
# libvirt store memory in KiB, POW must be lowered by 1
|
||||
RAM=$(virsh domstats --balloon "$VM" | awk 'BEGIN { FS="=" } /balloon.maximum/ { print $2 / '$((POW / 1024))'}')
|
||||
DSK=$(for BLK in $(virsh domblklist "$VM" | sed '1,2d;/-$/d;/^$/d' | cut -d\ -f1)
|
||||
do
|
||||
virsh domblkinfo "$VM" "$BLK"
|
||||
done | awk '/Physical:/ { size += $2 } END { print int(size / '${POW}') }')
|
||||
RUN=$(virsh domstate "$VM" | grep -q '^running$' && echo yes || echo no)
|
||||
echo "$VM" "$CPU" "$RAM" "$DSK" "$RUN"
|
||||
done | (
|
||||
virsh domstats --balloon "$VM" | awk 'BEGIN { FS="=" } /balloon.maximum/ { print $2 / '$((POW / 1024))'}'
|
||||
for BLK in $(virsh domblklist "$VM" | sed '1,2d;/-$/d;/^$/d' | cut -d\ -f1)
|
||||
do
|
||||
virsh domblkinfo "$VM" "$BLK"
|
||||
done | awk '/Physical:/ { size += $2 } END { print int(size / '${POW}') }'
|
||||
virsh domstate "$VM" | grep -q '^running$' && echo yes || echo no
|
||||
done | xargs -n5 | (
|
||||
echo vm vcpu ram disk running
|
||||
awk '{ print } /yes$/ { vcpu += $2; ram += $3; disk += $4; running++ } END { print "TOTAL(running)", vcpu, ram, disk, running }'
|
||||
if [ "$SHOW_AVAIL" ]
|
||||
|
|
Loading…
Reference in New Issue