fix stats
This commit is contained in:
parent
4a5770cff6
commit
f7c2d6e911
3 changed files with 13 additions and 13 deletions
|
@ -49,14 +49,17 @@ class QemuStats(object):
|
||||||
# dom = conn.lookupByID(5)
|
# dom = conn.lookupByID(5)
|
||||||
dom = self.conn.lookupByName(dom_name)
|
dom = self.conn.lookupByName(dom_name)
|
||||||
if not dom:
|
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
|
return results
|
||||||
|
|
||||||
stats = dom.getCPUStats(True)
|
try:
|
||||||
|
stats = dom.getCPUStats(True)
|
||||||
results['cpu_time'] = str(stats[0]['cpu_time'] / 100000)
|
except:
|
||||||
results['system_time'] = str(stats[0]['system_time'] / 100000)
|
pass
|
||||||
results['user_time'] = str(stats[0]['user_time'] / 10000)
|
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
|
return results
|
||||||
|
|
||||||
|
@ -70,7 +73,7 @@ class QemuStats(object):
|
||||||
# dom = conn.lookupByID(5)
|
# dom = conn.lookupByID(5)
|
||||||
dom = self.conn.lookupByName(dom_name)
|
dom = self.conn.lookupByName(dom_name)
|
||||||
if not dom:
|
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
|
return results
|
||||||
|
|
||||||
stats = dom.memoryStats()
|
stats = dom.memoryStats()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import requests
|
|
||||||
from SWSCloudNode import Node, StatisticsReporter
|
from SWSCloudNode import Node, StatisticsReporter
|
||||||
from SWSCloudNode import LXC
|
from SWSCloudNode import LXC
|
||||||
from SWSCloudNode import Qemu
|
from SWSCloudNode import Qemu
|
||||||
|
@ -15,7 +14,7 @@ for container in cls_lxc.list_containers():
|
||||||
# print container
|
# print container
|
||||||
info = cls_lxc.info(container)
|
info = cls_lxc.info(container)
|
||||||
info['container_id'] = info['name']
|
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
|
# 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')
|
vms = cls_qemu.list().get('online')
|
||||||
for vm in vms:
|
for vm in vms:
|
||||||
dom = vms.get(vm).get('hostname')
|
dom = vms.get(vm).get('hostname')
|
||||||
|
|
||||||
data = dict(
|
data = dict(
|
||||||
nework=QemuStats().network(dom),
|
nework=QemuStats().network(dom),
|
||||||
cpu=QemuStats().cpu(dom),
|
cpu=QemuStats().cpu(dom),
|
||||||
memory=QemuStats().memory(dom))
|
memory=QemuStats().memory(dom))
|
||||||
|
print (StatisticsReporter().send_vm_statistics(dom, data))
|
||||||
print StatisticsReporter().send_vm_statistics(dom, data)
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -4,7 +4,7 @@ from setuptools import setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='SWSCloudNode',
|
name='SWSCloudNode',
|
||||||
version='3.3.0',
|
version='3.3.1',
|
||||||
author='Vyacheslav Anzhiganov',
|
author='Vyacheslav Anzhiganov',
|
||||||
author_email='vanzhiganov@ya.ru',
|
author_email='vanzhiganov@ya.ru',
|
||||||
packages=[
|
packages=[
|
||||||
|
|
Loading…
Add table
Reference in a new issue