mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-27 11:24:42 +00:00
corrected lxd_ autoconf with proper checks
the autoconf now checks for availablity of the pylxd module and access to the lxd socket. this ensures that the module will work properly. On failure, helpful errors are displayed
This commit is contained in:
parent
46983fdc99
commit
365e993200
2 changed files with 75 additions and 31 deletions
|
@ -1,15 +1,37 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
errors=[]
|
||||||
|
|
||||||
|
HAS_LIB=True
|
||||||
|
try:
|
||||||
from pylxd import api
|
from pylxd import api
|
||||||
|
except:
|
||||||
|
HAS_LIB=False
|
||||||
|
errors.append("no pylxd module")
|
||||||
|
|
||||||
|
c=None
|
||||||
|
HAS_ACCESS=True
|
||||||
|
try:
|
||||||
c=api.API()
|
c=api.API()
|
||||||
|
c.container_list()
|
||||||
|
except:
|
||||||
|
HAS_ACCESS=False
|
||||||
|
errors.append("no socket access")
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) == 2 and sys.argv[1]=="autoconf":
|
||||||
if sys.argv[1]=="autoconf":
|
if HAS_LIB and HAS_ACCESS:
|
||||||
print("yes")
|
print("yes")
|
||||||
|
else:
|
||||||
|
print("no ("+" and ".join(errors)+")")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif sys.argv[1]=="config":
|
|
||||||
|
if not (HAS_LIB and HAS_ACCESS):
|
||||||
|
# pylxd not installed or lxd socket not accessible
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if len(sys.argv) == 2 and sys.argv[1]=="config":
|
||||||
print("graph_title LXD container disk usage")
|
print("graph_title LXD container disk usage")
|
||||||
print("graph_args --base 1000 --lower-limit 0")
|
print("graph_args --base 1000 --lower-limit 0")
|
||||||
print("graph_vlabel Bytes")
|
print("graph_vlabel Bytes")
|
||||||
|
|
|
@ -1,15 +1,37 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
errors=[]
|
||||||
|
|
||||||
|
HAS_LIB=True
|
||||||
|
try:
|
||||||
from pylxd import api
|
from pylxd import api
|
||||||
|
except:
|
||||||
|
HAS_LIB=False
|
||||||
|
errors.append("no pylxd module")
|
||||||
|
|
||||||
|
c=None
|
||||||
|
HAS_ACCESS=True
|
||||||
|
try:
|
||||||
c=api.API()
|
c=api.API()
|
||||||
|
c.container_list()
|
||||||
|
except:
|
||||||
|
HAS_ACCESS=False
|
||||||
|
errors.append("no socket access")
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) == 2 and sys.argv[1]=="autoconf":
|
||||||
if sys.argv[1]=="autoconf":
|
if HAS_LIB and HAS_ACCESS:
|
||||||
print("yes")
|
print("yes")
|
||||||
|
else:
|
||||||
|
print("no ("+" and ".join(errors)+")")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif sys.argv[1]=="config":
|
|
||||||
|
if not (HAS_LIB and HAS_ACCESS):
|
||||||
|
# pylxd not installed or lxd socket not accessible
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if len(sys.argv) == 2 and sys.argv[1]=="config":
|
||||||
print("graph_title LXD container memory")
|
print("graph_title LXD container memory")
|
||||||
print("graph_args --base 1024 --lower-limit 0")
|
print("graph_args --base 1024 --lower-limit 0")
|
||||||
print("graph_vlabel Bytes")
|
print("graph_vlabel Bytes")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue