>>> pixel fairy <pixel...@gmail.com> schrieb am 18.02.2020 um 06:04 in Nachricht
<13889_1582002262_5E4B7056_13889_59_1_2104823c-c9c1-4fc9-aa9c-090863f09825@googl
groups.com>:
> trying to see how much space is allocated, not actually used in all the
> qubes. is there an easy command for this? something like qvm-volume info
> but for all the qubes?
What about "PFree" in output of "pvs"?
#!/usr/bin/env python3
import subprocess
# older python doesnt have capture_output in subprocess.run
output = subprocess.check_output(['sudo','lvs'], universal_newlines=True)
lines = output.split('\n')
allocated = 0.0
for line in lines:
l = line.split()
# headers and the empty line at the end
if len(l) < 3:
continue
name = l[0]
size = l[3]
# we only care about vm- volumes
if name[:2] != "vm":
continue
# we only care about persistent volumes, -root and -private
if name[-5:] != "-root" and name[-8:] != "-private":
continue
# lop of the g at the end. check for G in case lvs output changes
if size[-1] != 'g' and size[-1] != 'G':
print(name,size,"size is not in gigs. rewrite script")
exit(1)
size = float(size[:-1])
allocated += size
print("{:7.2f} {}".format(size,name))
print("{:7.2f} total".format(allocated))