diff options
author | Guido Günther <agx@sigxcpu.org> | 2020-03-30 09:49:11 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2020-03-30 09:52:40 +0200 |
commit | acae25af33bbc7f397bd979d4944bcfb568e522d (patch) | |
tree | 6121796effd26e1357b1724b35c04dde2e409e59 /libvirt-blkstat | |
parent | dac37a8697332f88f8387c377fab8a303b091f10 (diff) |
Run python3-futurize
Diffstat (limited to 'libvirt-blkstat')
-rw-r--r-- | libvirt-blkstat | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/libvirt-blkstat b/libvirt-blkstat index 42ec1b4..5e236c0 100644 --- a/libvirt-blkstat +++ b/libvirt-blkstat @@ -12,6 +12,7 @@ #%# capabilities=autoconf #%# family=contrib +from __future__ import print_function import re, sys, os import libvirt import libxml2 @@ -22,10 +23,10 @@ def canon(name): def print_config(uri): """print the plugin config, determine the domains""" - print """graph_title Virtual Domain Block Device I/O + print("""graph_title Virtual Domain Block Device I/O graph_vlabel Bytes read (-)/ written (+) per ${graph_period} graph_category Virtual Machines -graph_info This graph shows the block device I/O of the virtual machines""" +graph_info This graph shows the block device I/O of the virtual machines""") conn = libvirt.openReadOnly(uri) ids = conn.listDomainsID() @@ -33,21 +34,21 @@ graph_info This graph shows the block device I/O of the virtual machines""" try: dom = conn.lookupByID(id) name = dom.name() - except libvirt.libvirtError, err: - print >>sys.stderr, "Id: %s: %s" % (id, err) + except libvirt.libvirtError as err: + print("Id: %s: %s" % (id, err), file=sys.stderr) continue if name == "Domain-0": continue - print "%s_read.label %s" % (canon(name), name) - print "%s_read.type DERIVE" % canon(name) - print "%s_read.min 0" % canon(name) - print "%s_read.graph no" % canon(name) - print "%s_read.draw LINE1" % canon(name) - print "%s_write.label %s" % (canon(name), name) - print "%s_write.type DERIVE" % canon(name) - print "%s_write.min 0" % canon(name) - print "%s_write.negative %s_read" % (canon(name), canon(name)) - print "%s_write.draw LINE1" % canon(name) + print("%s_read.label %s" % (canon(name), name)) + print("%s_read.type DERIVE" % canon(name)) + print("%s_read.min 0" % canon(name)) + print("%s_read.graph no" % canon(name)) + print("%s_read.draw LINE1" % canon(name)) + print("%s_write.label %s" % (canon(name), name)) + print("%s_write.type DERIVE" % canon(name)) + print("%s_write.min 0" % canon(name)) + print("%s_write.negative %s_read" % (canon(name), canon(name))) + print("%s_write.draw LINE1" % canon(name)) def get_disks(dom): xml = dom.XMLDesc(0) @@ -84,8 +85,8 @@ def fetch_values(uri): try: dom = conn.lookupByID(id) name = dom.name() - except libvirt.libvirtError, err: - print >>sys.stderr, "Id: %s: %s" % (id, err) + except libvirt.libvirtError as err: + print("Id: %s: %s" % (id, err), file=sys.stderr) continue if name == "Domain-0": continue @@ -97,9 +98,9 @@ def fetch_values(uri): rd += rd_bytes wr += wr_bytes except TypeError: - print >>sys.stderr, "Cannot get blockstats for '%s' on '%s'" % (disk, name) - print "%s_read.value %d" % (canon(name), rd) - print "%s_write.value %d" % (canon(name), wr) + print("Cannot get blockstats for '%s' on '%s'" % (disk, name), file=sys.stderr) + print("%s_read.value %d" % (canon(name), rd)) + print("%s_write.value %d" % (canon(name), wr)) def main(sys): @@ -108,10 +109,10 @@ def main(sys): if len(sys) > 1: if sys[1] in [ 'autoconf', 'detect' ]: if libvirt.openReadOnly(uri): - print "yes" + print("yes") return 0 else: - print "no" + print("no") return 1 elif sys[1] == 'config': print_config(uri) |