fix stats

This commit is contained in:
Vyacheslav Anzhiganov 2016-10-12 23:34:07 +03:00
parent 4a5770cff6
commit f7c2d6e911
3 changed files with 13 additions and 13 deletions

View file

@ -52,8 +52,11 @@ class QemuStats(object):
print('Failed to find the domain ' + dom_name, file=sys.stderr)
return results
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)

View file

@ -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))

View file

@ -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=[