aboutsummaryrefslogtreecommitdiff
path: root/libvirt-mem
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2008-11-17 11:28:56 +0100
committerGuido Guenther <agx@sigxcpu.org>2008-11-17 11:28:56 +0100
commit62d3469cf60a0ca8bdea429a2feb4131e2722619 (patch)
tree67373aed33f8b885eb703ccc1707924a898eaa12 /libvirt-mem
parent4c1513b20fe86924f721c4b9f6d87c0bda5d98b8 (diff)
also calculate the maximum memory vms can balloon to
as absolute and percent value.
Diffstat (limited to 'libvirt-mem')
-rw-r--r--libvirt-mem29
1 files changed, 23 insertions, 6 deletions
diff --git a/libvirt-mem b/libvirt-mem
index 0c2073c..88bc2c2 100644
--- a/libvirt-mem
+++ b/libvirt-mem
@@ -38,19 +38,29 @@ host_mem.label %(hostname)s (host)
host_mem.type GAUGE
host_mem.min 0
host_mem.draw LINE1
+host_mem.info total memory of host '%(hostname)s'
total.type GAUGE
-total.label total
-total.info memory used by virtual machines on host %(hostname)s
+total.label total memory
+total.info total 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.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)
+total_pc.critical 95
+total_max.type GAUGE
+total_max.label total max. mem
+total_max.info maximum memory virtual machines can balloon to on host '%(hostname)s'
+total_max.min 0
+total_max_pc.type GAUGE
+total_max_pc.label total maximum memory percentage
+total_max_pc.graph no
+total_max_pc.info maximum memory in percent virtual machines can balloon to on host '%(hostname)s'
+total_max_pc.min 0""" % dict(hostname=hostname)
ids = conn.listDomainsID()
draw = "AREA"
@@ -67,6 +77,7 @@ total_pc.critical 95""" % dict(hostname=hostname)
print "%s_mem.type GAUGE" % canon(name)
print "%s_mem.min 0" % canon(name)
print "%s_mem.draw %s" % (canon(name), draw)
+ print "%s_mem.info memory used by virtual machine '%s'" % (canon(name), name)
if draw == "AREA":
draw = "STACK"
return 0
@@ -74,6 +85,7 @@ total_pc.critical 95""" % dict(hostname=hostname)
def fetch_values(uri):
total = 0
+ total_max = 0
try:
conn = libvirt.openReadOnly(uri)
except libvirt.libvirtError, err:
@@ -91,11 +103,16 @@ def fetch_values(uri):
continue
if name == "Domain-0":
continue
- mem = dom.info()[2] * 1024
- print "%s_mem.value %d" % (canon(name), mem)
+ maxmem, mem = dom.info()[1:3]
+ mem *= 1024
+ maxmem *= 1024
total += mem
+ total_max += maxmem
+ print "%s_mem.value %d" % (canon(name), mem)
print "total.value %d" % total
print "total_pc.value %.0f" % (100.0 * total / float(hostmem))
+ print "total_max.value %d" % total_max
+ print "total_max_pc.value %.0f" % (100.0 * total_max / float(hostmem))
return 0