fix
This commit is contained in:
parent
f683840980
commit
4a5770cff6
1 changed files with 14 additions and 14 deletions
|
@ -14,14 +14,14 @@ class QemuStats(object):
|
|||
def __del__(self):
|
||||
self.conn.close()
|
||||
|
||||
def network(self, dom):
|
||||
def network(self, dom_name):
|
||||
results = dict(
|
||||
read_bytes=0, read_packets=0, read_errors=0, read_drops=0,
|
||||
write_bytes=0, write_packets=0, write_errors=0, write_drops=0)
|
||||
|
||||
dom = self.conn.lookupByName(dom)
|
||||
dom = self.conn.lookupByName(dom_name)
|
||||
# dom = conn.lookupByID(5)
|
||||
if dom == None:
|
||||
if not dom:
|
||||
return results
|
||||
|
||||
tree = ElementTree.fromstring(dom.XMLDesc())
|
||||
|
@ -39,17 +39,17 @@ class QemuStats(object):
|
|||
|
||||
return results
|
||||
|
||||
def cpu(self, dom):
|
||||
def cpu(self, dom_name):
|
||||
# http://libvirt.org/docs/libvirt-appdev-guide-python/en-US/html/libvirt_application_development_guide_using_python-Guest_Domains-Monitoring-vCPU.html
|
||||
results = dict(cpu_time=0, system_time=0, user_time=0)
|
||||
if self.conn == None:
|
||||
if not self.conn:
|
||||
print('Failed to open connection to qemu:///system', file=sys.stderr)
|
||||
return results
|
||||
|
||||
# dom = conn.lookupByID(5)
|
||||
dom = self.conn.lookupByName(dom)
|
||||
if dom == None:
|
||||
print('Failed to find the domain '+domName, file=sys.stderr)
|
||||
dom = self.conn.lookupByName(dom_name)
|
||||
if not dom:
|
||||
print('Failed to find the domain '+dom_name, file=sys.stderr)
|
||||
return results
|
||||
|
||||
stats = dom.getCPUStats(True)
|
||||
|
@ -60,17 +60,17 @@ class QemuStats(object):
|
|||
|
||||
return results
|
||||
|
||||
def memory(self, dom):
|
||||
def memory(self, dom_name):
|
||||
# http://libvirt.org/docs/libvirt-appdev-guide-python/en-US/html/libvirt_application_development_guide_using_python-Guest_Domains-Monitoring-Memory.html
|
||||
results = dict()
|
||||
if self.conn == None:
|
||||
if not self.conn:
|
||||
print('Failed to open connection to qemu:///system', file=sys.stderr)
|
||||
return results
|
||||
|
||||
# dom = conn.lookupByID(5)
|
||||
dom = self.conn.lookupByName(dom)
|
||||
if dom == None:
|
||||
print('Failed to find the domain '+domName, file=sys.stderr)
|
||||
dom = self.conn.lookupByName(dom_name)
|
||||
if not dom:
|
||||
print('Failed to find the domain '+dom_name, file=sys.stderr)
|
||||
return results
|
||||
|
||||
stats = dom.memoryStats()
|
||||
|
|
Loading…
Add table
Reference in a new issue