diff options
author | Guido Günther <agx@sigxcpu.org> | 2008-10-27 20:17:14 +0100 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2008-10-27 20:17:14 +0100 |
commit | f76c15b2e93e36b2003ae737a666a13f1b855cfd (patch) | |
tree | bd35d008651b74a6ad16300534bd80e1824ccdb5 | |
parent | 4bed3d2665ce38b9dd51e9b35531641f3a2dbd29 (diff) | |
parent | 6d0909da57502ba90415a7e83fec8ffb427c0537 (diff) |
Merge branch 'master' into debian
-rw-r--r-- | INSTALL | 8 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README | 23 | ||||
-rw-r--r-- | libvirt-cputime | 14 | ||||
-rw-r--r-- | libvirt-mem | 44 |
5 files changed, 66 insertions, 25 deletions
@@ -3,11 +3,3 @@ Installation is simple: make PLUGINDIR=/etc/munin/plugins install /etc/init.d/munin-node restart -The default uri used to connect to libvirt is "qemu:///system". This can be -changed in the plugin configuration: - -cat <<EOF >/etc/munin/plugin-conf.d/libvirt -[libvirt-*] -env.uri xen:/// -EOF - @@ -1,4 +1,4 @@ -VERSION=0.0.2 +VERSION=0.0.3 PKG=munin-libvirt-plugins PLUGINDIR=/usr/share/munin/plugins/ @@ -0,0 +1,23 @@ +This is a set of munin plugins to monitor virtual machines managed via libvirt. + +See INSTALL for installation instructions. + +The default uri used to connect to libvirt is "qemu:///system". This can be +changed in the plugin configuration: + +cat <<EOF >/etc/munin/plugin-conf.d/libvirt +[libvirt-*] +env.uri xen:/// +EOF + +libvirt-mem and libvirt-cputime support limits[1] for critical and warning +values. These are set to 90% (warning) and 95% (critical) by default. However +you can change them in /etc/munin/munin.conf: + +[somehost.example.com] +libvirt_cputime.total_pc.warning 60 +libvirt_cputime.total_pc.critical 75 +libvirt_mem.total_pc.warning 25 +libvirt_mem.total_pc.critical 50 + +[1]: http://munin.projects.linpro.no/wiki/HowToContact diff --git a/libvirt-cputime b/libvirt-cputime index 8758b17..86394ac 100644 --- a/libvirt-cputime +++ b/libvirt-cputime @@ -26,7 +26,15 @@ def print_config(uri, stack): graph_vlabel CPU Time percentage graph_category Virtual Machines graph_info This graph shows the cpu time percentage of each virtual machine -graph_args --base 1000 -l 0""" +graph_args --base 1000 -l 0 +total_pc.type DERIVE +total_pc.graph no +total_pc.min 0 +total_pc.max 100 +total_pc.label total +total_pc.info cputime used by all virtual machines +total_pc.warning 90 +total_pc.critical 95""" draw = [ "LINE1", "AREA"][stack] conn = libvirt.openReadOnly(uri) @@ -41,10 +49,10 @@ graph_args --base 1000 -l 0""" if draw == "AREA": draw = "STACK" - def fetch_values(uri): conn = libvirt.openReadOnly(uri) ids = conn.listDomainsID() + total = 0 processors = float(conn.getInfo()[2]) for id in ids: @@ -52,7 +60,9 @@ def fetch_values(uri): name = dom.name() cputime = float(dom.info()[4]) cputime_percentage = 1.0e-7 * cputime / processors + total += cputime_percentage print "%s_cputime.value %.0f" % (canon(name), cputime_percentage) + print "total_pc.value %.0f" % total def main(sys): diff --git a/libvirt-mem b/libvirt-mem index 950cd60..c7bf63d 100644 --- a/libvirt-mem +++ b/libvirt-mem @@ -21,19 +21,37 @@ def canon(name): def print_config(uri): """print the plugin config, determine the domains""" - - print """graph_title Virtual Domain Memory Usage -graph_vlabel Memory Usage / Bytes -graph_category Virtual Machines -graph_info This graph shows the current amount of memory used by each virtual machine -graph_args --base 1024 -l 0""" - try: conn = libvirt.openReadOnly(uri) except libvirt.libvirtError, err: print >>sys.stderr, "Error opening to %s connection: %s" % (uri, err) return 1 + hostname = conn.getHostname() + + print """graph_title Virtual Domain Memory Usage +graph_vlabel Memory Usage / Bytes +graph_category Virtual Machines +graph_info This graph shows the current amount of memory used by each virtual machine +graph_args --base 1024 -l 0 +host_mem.label %(hostname)s (host) +host_mem.type GAUGE +host_mem.min 0 +host_mem.draw LINE1 +total.type GAUGE +total.label total +total.info memory used by virtual machines on host %(hostname)s +total.graph no +total.min 0 +total_pc.type GAUGE +total_pc.label used memory percentage +total_pc.info memory in percent used by virtual machines on host %(hostname)s +total_pc.graph no +total_pc.min 0 +total_pc.max 100 +total_pc.warning 90 +total_pc.critical 95""" % dict(hostname=hostname) + ids = conn.listDomainsID() draw = "AREA" for id in ids: @@ -45,16 +63,11 @@ graph_args --base 1024 -l 0""" print "%s_mem.draw %s" % (canon(name), draw) if draw == "AREA": draw = "STACK" - - hostname = conn.getHostname() - print "host_mem.label %s (host)" % hostname - print "host_mem.type GAUGE" - print "host_mem.min 0" - print "host_mem.draw LINE1" return 0 def fetch_values(uri): + total = 0 try: conn = libvirt.openReadOnly(uri) except libvirt.libvirtError, err: @@ -66,8 +79,11 @@ def fetch_values(uri): for id in ids: dom = conn.lookupByID(id) name = dom.name() - mem = float(dom.info()[2]) * 1024 + mem = dom.info()[2] * 1024 + total += mem print "%s_mem.value %d" % (canon(name), mem) + print "total.value %d" % total + print "total_pc.value %.0f" % (100.0 * total / float(hostmem)) return 0 |