Commit 101f5a4b by Bach Dániel

fix __collectFromVMs()

parent c90bae3d
...@@ -185,56 +185,52 @@ class Client: ...@@ -185,56 +185,52 @@ class Client:
if ((self.beat % self.kvmCPU) is 0) and vm_proc.is_running(): if ((self.beat % self.kvmCPU) is 0) and vm_proc.is_running():
metrics.append(("vm." + metrics.append(("vm." +
vm[0] + "." + "memory.usage" + vm[0] + "." + "memory.usage" +
" %d" % ( " %f" % (
vm_proc.get_memory_percent() / 100 * vm[2]) vm_proc.get_memory_percent() / 100 * vm[2])
+ " %d" % (time.time()) + " %d" % (time.time())
)) ))
if ((self.beat % self.kvmMem) is 0) and vm_proc.is_running(): if ((self.beat % self.kvmMem) is 0) and vm_proc.is_running():
metrics.append(("vm." + metrics.append(("vm." +
vm[0] + "." + "cpu.usage" + vm[0] + "." + "cpu.usage" +
" %d" % (vm_proc.get_cpu_times().system + " %f" % (vm_proc.get_cpu_times().system +
vm_proc.get_cpu_times().user) vm_proc.get_cpu_times().user)
+ " %d" % (time.time()) + " %d" % (time.time())
)) ))
interfaces_list = psutil.network_io_counters( interfaces_list = psutil.network_io_counters(
pernic=True) pernic=True)
if ((self.beat % self.kvmNet) is 0) and vm_proc.is_running(): if ((self.beat % self.kvmNet) is 0):
for vm in running_vms: for vm in running_vms:
interfaces_list_enum = enumerate(interfaces_list) interfaces_list_enum = enumerate(interfaces_list)
for iname_index, iname in interfaces_list_enum: for iname_index, iname in interfaces_list_enum:
if vm[0] in iname: if vm[0] in iname:
metrics.append(("vm." + metrics.append(
vm[0] + ('vm.%(name)s.network.packets_sent_%(interface)s '
"." + "network.packages_sent" + '%(data)f %(time)d') % {
" %d" % interfaces_list[ 'name': vm[0],
iname].packets_sent 'interface': iname,
+ "." + iname 'time': time.time(),
+ " %d" % (time.time()) 'data': interfaces_list[iname].packets_sent})
)) metrics.append(
metrics.append(("vm." + ('vm.%(name)s.network.packets_recv_%(interface)s '
vm[0] + '%(data)f %(time)d') % {
"." + "network.packages_recv" + 'name': vm[0],
" %d" % interfaces_list[ 'interface': iname,
iname].packets_recv 'time': time.time(),
+ "." + iname 'data': interfaces_list[iname].packets_recv})
+ " %d" % (time.time()) metrics.append(
)) ('vm.%(name)s.network.bytes_sent_%(interface)s '
metrics.append(("vm." + '%(data)f %(time)d') % {
vm[0] + "." + "network" 'name': vm[0],
".bytes_sent" + 'interface': iname,
" %d" % interfaces_list[ 'time': time.time(),
iname].bytes_sent 'data': interfaces_list[iname].bytes_sent})
+ "." + iname metrics.append(
+ " %d" % (time.time()) ('vm.%(name)s.network.bytes_recv_%(interface)s '
)) '%(data)f %(time)d') % {
metrics.append(("vm." + 'name': vm[0],
vm[0] + "." + "network" 'interface': iname,
".bytes_recv" + 'time': time.time(),
" %d" % interfaces_list[ 'data': interfaces_list[iname].bytes_recv})
iname].bytes_recv
+ "." + iname
+ " %d" % (time.time())
))
return metrics return metrics
def getMaxFrequency(self, metricCollectors=[]): def getMaxFrequency(self, metricCollectors=[]):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment