From ca71d12f290f1169a225e70b4418423afcbfc5e4 Mon Sep 17 00:00:00 2001 From: Felix Engelmann Date: Wed, 3 Aug 2016 12:49:53 +0200 Subject: [PATCH] added lxd memory plugin the lxd deamon provides a REST interface which can be queried by pylxd to get container related information. It stacks all containers, so the total memory footprint of lxd is visible. This plugin depends on python3 pylxd --- plugins/lxd/lxd_mem | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 plugins/lxd/lxd_mem diff --git a/plugins/lxd/lxd_mem b/plugins/lxd/lxd_mem new file mode 100755 index 00000000..9895133f --- /dev/null +++ b/plugins/lxd/lxd_mem @@ -0,0 +1,24 @@ +#!/usr/bin/python3 + +import sys +from pylxd import api + +c=api.API() + +if len(sys.argv) == 2: + if sys.argv[1]=="autoconf": + print("yes") + sys.exit(0) + elif 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']))