aboutsummaryrefslogtreecommitdiff
path: root/libvirt-cputime
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-cputime
parentefc301ac547ed23808537c710f35acbfa2f109d9 (diff)
handle lookupById failures
xend seems to report wrong numbers, so ignore errors resolving ids to domains
Diffstat (limited to 'libvirt-cputime')
-rw-r--r--libvirt-cputime16
1 files changed, 12 insertions, 4 deletions
diff --git a/libvirt-cputime b/libvirt-cputime
index 86394ac..6693602 100644
--- a/libvirt-cputime
+++ b/libvirt-cputime
@@ -40,8 +40,12 @@ total_pc.critical 95"""
conn = libvirt.openReadOnly(uri)
ids = conn.listDomainsID()
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_cputime.label %s" % (canon(name), name)
print "%s_cputime.type DERIVE" % canon(name)
print "%s_cputime.min 0" % canon(name)
@@ -56,8 +60,12 @@ def fetch_values(uri):
processors = float(conn.getInfo()[2])
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
cputime = float(dom.info()[4])
cputime_percentage = 1.0e-7 * cputime / processors
total += cputime_percentage