1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

added explaining comment for extra if

If no LXD disk information is present, the field is None instead of an
empty list. Iterating over it directly would fail.
This commit is contained in:
Felix Engelmann 2016-10-17 09:57:02 +02:00
parent 8b010aadbd
commit 3a48fa4eab

View file

@ -10,7 +10,7 @@ try:
except:
HAS_LIB=False
errors.append("no pylxd module")
c=None
HAS_ACCESS=True
try:
@ -39,7 +39,9 @@ if len(sys.argv) == 2 and sys.argv[1]=="config":
print("graph_info This shows the disk usage of storage in containers. Make sure to install pylxd in python3.")
for name in c.container_list():
info = c.container_info(name)
# first check if disk information list is available or None
if info['disk']:
# if no disk information is present, this would fail to iteration None
for disk in info['disk']:
print(name+"-"+disk+".label "+name)
print(name+"-"+disk+".draw LINE2")
@ -47,6 +49,8 @@ if len(sys.argv) == 2 and sys.argv[1]=="config":
for name in c.container_list():
info = c.container_info(name)
# first check if disk information list is available or None
if info['disk']:
# if no disk information is present, this would fail to iteration None
for disk in info['disk']:
print(name+"-"+disk+".value "+str(info['disk'][disk]['usage']))