aboutsummaryrefslogtreecommitdiff
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
parentefc301ac547ed23808537c710f35acbfa2f109d9 (diff)
handle lookupById failures
xend seems to report wrong numbers, so ignore errors resolving ids to domains
-rw-r--r--libvirt-blkstat16
-rw-r--r--libvirt-cputime16
-rw-r--r--libvirt-ifstat16
-rw-r--r--libvirt-mem16
4 files changed, 48 insertions, 16 deletions
diff --git a/libvirt-blkstat b/libvirt-blkstat
index a3e3b4c..42ec1b4 100644
--- a/libvirt-blkstat
+++ b/libvirt-blkstat
@@ -30,8 +30,12 @@ graph_info This graph shows the block device I/O of the virtual machines"""
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
if name == "Domain-0":
continue
print "%s_read.label %s" % (canon(name), name)
@@ -77,8 +81,12 @@ def fetch_values(uri):
for id in ids:
rd = 0
wr = 0
- 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
if name == "Domain-0":
continue
disks = get_disks(dom)
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
diff --git a/libvirt-ifstat b/libvirt-ifstat
index 696dd79..4fd2f93 100644
--- a/libvirt-ifstat
+++ b/libvirt-ifstat
@@ -30,8 +30,12 @@ graph_info This graph shows the network I/O of the virtual machines"""
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
if name == "Domain-0":
continue
print "%s_rx.label %s" % (canon(name), name)
@@ -77,8 +81,12 @@ def fetch_values(uri):
for id in ids:
rd = 0
wr = 0
- 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
if name == "Domain-0":
continue
ifaces = get_ifaces(dom)
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