aboutsummaryrefslogtreecommitdiff
path: root/libvirt-mem
diff options
context:
space:
mode:
authorGuido G√ľnther <agx@sigxcpu.org>2008-10-30 16:50:57 +0100
committerGuido Guenther <agx@sigxcpu.org>2008-10-30 16:50:57 +0100
commit7858c461651c341537c158ffee1475251c880b0e (patch)
treebdfef8467347aee119e8a6c6cd82691b42cec354 /libvirt-mem
parentefc301ac547ed23808537c710f35acbfa2f109d9 (diff)
handle lookupById failures
xend seems to report wrong numbers, so ignore errors resolving ids to domains
Diffstat (limited to 'libvirt-mem')
-rw-r--r--libvirt-mem16
1 files changed, 12 insertions, 4 deletions
diff --git a/libvirt-mem b/libvirt-mem
index 5437987..6dfb9a0 100644
--- a/libvirt-mem
+++ b/libvirt-mem
@@ -55,8 +55,12 @@ total_pc.critical 95""" % dict(hostname=hostname)
ids = conn.listDomainsID()
draw = "AREA"
for id in ids:
- dom = conn.lookupByID(id)
- name = dom.name()
+ try:
+ dom = conn.lookupByID(id)
+ name = dom.name()
+ except libvirt.libvirtError, err:
+ print >>sys.stderr, "Id: %s: %s" % (id, err)
+ continue
print "%s_mem.label %s" % (canon(name), name)
print "%s_mem.type GAUGE" % canon(name)
print "%s_mem.min 0" % canon(name)
@@ -77,8 +81,12 @@ def fetch_values(uri):
hostmem = conn.getInfo()[1] * 1024 * 1024
print "host_mem.value %d" % hostmem
for id in ids:
- dom = conn.lookupByID(id)
- name = dom.name()
+ try:
+ dom = conn.lookupByID(id)
+ name = dom.name()
+ except libvirt.libvirtError, err:
+ print >>sys.stderr, "Id: %s: %s" % (id, err)
+ continue
mem = dom.info()[2] * 1024
print "%s_mem.value %d" % (canon(name), mem)
# ignore Xen's Dom0 when calcualting memory total and percentage