mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 18:07:20 +00:00
commit
5f432d0d6d
2 changed files with 94 additions and 0 deletions
48
plugins/lxd/lxd_disk
Executable file
48
plugins/lxd/lxd_disk
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
|
||||
errors=[]
|
||||
|
||||
HAS_LIB=True
|
||||
try:
|
||||
from pylxd import api
|
||||
except:
|
||||
HAS_LIB=False
|
||||
errors.append("no pylxd module")
|
||||
|
||||
c=None
|
||||
HAS_ACCESS=True
|
||||
try:
|
||||
c=api.API()
|
||||
c.container_list()
|
||||
except:
|
||||
HAS_ACCESS=False
|
||||
errors.append("no socket access")
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1]=="autoconf":
|
||||
if HAS_LIB and HAS_ACCESS:
|
||||
print("yes")
|
||||
else:
|
||||
print("no ("+" and ".join(errors)+")")
|
||||
sys.exit(0)
|
||||
|
||||
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_args --base 1000 --lower-limit 0")
|
||||
print("graph_vlabel Bytes")
|
||||
print("graph_category lxd")
|
||||
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():
|
||||
for disk in c.container_info(name)['disk']:
|
||||
print(name+"-"+disk+".label "+name)
|
||||
print(name+"-"+disk+".draw LINE2")
|
||||
sys.exit(0)
|
||||
|
||||
for name in c.container_list():
|
||||
for disk in c.container_info(name)['disk']:
|
||||
print(name+"-"+disk+".value "+str(c.container_info(name)['disk'][disk]['usage']))
|
46
plugins/lxd/lxd_mem
Executable file
46
plugins/lxd/lxd_mem
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
|
||||
errors=[]
|
||||
|
||||
HAS_LIB=True
|
||||
try:
|
||||
from pylxd import api
|
||||
except:
|
||||
HAS_LIB=False
|
||||
errors.append("no pylxd module")
|
||||
|
||||
c=None
|
||||
HAS_ACCESS=True
|
||||
try:
|
||||
c=api.API()
|
||||
c.container_list()
|
||||
except:
|
||||
HAS_ACCESS=False
|
||||
errors.append("no socket access")
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1]=="autoconf":
|
||||
if HAS_LIB and HAS_ACCESS:
|
||||
print("yes")
|
||||
else:
|
||||
print("no ("+" and ".join(errors)+")")
|
||||
sys.exit(0)
|
||||
|
||||
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_args --base 1024 --lower-limit 0")
|
||||
print("graph_vlabel Bytes")
|
||||
print("graph_category lxd")
|
||||
print("graph_info This shows the memory usage of each container. Make sure to install pylxd in python3.")
|
||||
for name in c.container_list():
|
||||
print(name+".label "+name)
|
||||
print(name+".draw AREASTACK")
|
||||
sys.exit(0)
|
||||
|
||||
for name in c.container_list():
|
||||
print(name+".value "+str(c.container_info(name)['memory']['usage']))
|
Loading…
Add table
Add a link
Reference in a new issue