From 7858c461651c341537c158ffee1475251c880b0e Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Thu, 30 Oct 2008 16:50:57 +0100 Subject: handle lookupById failures xend seems to report wrong numbers, so ignore errors resolving ids to domains --- libvirt-cputime | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'libvirt-cputime') 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 -- cgit v1.2.3