diff --git a/SWSCloudNode/compute/qemu/stats.py b/SWSCloudNode/compute/qemu/stats.py index 307aa09..1c7a813 100644 --- a/SWSCloudNode/compute/qemu/stats.py +++ b/SWSCloudNode/compute/qemu/stats.py @@ -49,14 +49,17 @@ class QemuStats(object): # dom = conn.lookupByID(5) dom = self.conn.lookupByName(dom_name) if not dom: - print('Failed to find the domain '+dom_name, file=sys.stderr) + print('Failed to find the domain ' + dom_name, file=sys.stderr) return results - stats = dom.getCPUStats(True) - - results['cpu_time'] = str(stats[0]['cpu_time'] / 100000) - results['system_time'] = str(stats[0]['system_time'] / 100000) - results['user_time'] = str(stats[0]['user_time'] / 10000) + try: + stats = dom.getCPUStats(True) + except: + pass + else: + results['cpu_time'] = str(stats[0]['cpu_time'] / 100000) + results['system_time'] = str(stats[0]['system_time'] / 100000) + results['user_time'] = str(stats[0]['user_time'] / 10000) return results @@ -70,7 +73,7 @@ class QemuStats(object): # dom = conn.lookupByID(5) dom = self.conn.lookupByName(dom_name) if not dom: - print('Failed to find the domain '+dom_name, file=sys.stderr) + print('Failed to find the domain ' + dom_name, file=sys.stderr) return results stats = dom.memoryStats() diff --git a/cloud_node_statistics.py b/cloud_node_statistics.py index d3d4212..34dcbf6 100644 --- a/cloud_node_statistics.py +++ b/cloud_node_statistics.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # coding: utf-8 -import requests from SWSCloudNode import Node, StatisticsReporter from SWSCloudNode import LXC from SWSCloudNode import Qemu @@ -15,7 +14,7 @@ for container in cls_lxc.list_containers(): # print container info = cls_lxc.info(container) info['container_id'] = info['name'] - print cls_node.report_container_stats(info['container_id'], info) + print (cls_node.report_container_stats(info['container_id'], info)) # print info @@ -26,10 +25,8 @@ curl localhost:8089/node_stats/v1/compute/vms/04ea5600-89c6-11e6-b1e1-fb8145d56e vms = cls_qemu.list().get('online') for vm in vms: dom = vms.get(vm).get('hostname') - data = dict( nework=QemuStats().network(dom), cpu=QemuStats().cpu(dom), memory=QemuStats().memory(dom)) - - print StatisticsReporter().send_vm_statistics(dom, data) + print (StatisticsReporter().send_vm_statistics(dom, data)) diff --git a/setup.py b/setup.py index 9db3de1..f5ab791 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup( name='SWSCloudNode', - version='3.3.0', + version='3.3.1', author='Vyacheslav Anzhiganov', author_email='vanzhiganov@ya.ru', packages=[