Commit d6655c03 by Gregory Nagy

cpuTimes added and syncronization added with celerymonitor

parent 101f5a4b
...@@ -3,6 +3,7 @@ Debug = True ...@@ -3,6 +3,7 @@ Debug = True
[Metrics] [Metrics]
cpuUsage = 5 cpuUsage = 5
cpuTimes = 5
memoryUsage = 5 memoryUsage = 5
userCount = 60 userCount = 60
swapUsage = 30 swapUsage = 30
......
...@@ -176,26 +176,21 @@ class Client: ...@@ -176,26 +176,21 @@ class Client:
except IndexError: except IndexError:
pass pass
if ((self.beat % 30) is 0): if ((self.beat % 30) is 0):
metrics.append((self.name + "." + "vmcount" + metrics.append("%s.vmcount %d %d"
" %d" % len(running_vms) % (self.name, len(running_vms), time.time()))
+ " %d" % (time.time())
))
for vm in running_vms: for vm in running_vms:
vm_proc = psutil.Process(vm[1]) vm_proc = psutil.Process(vm[1])
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.%s.memory.usage %f %d"
vm[0] + "." + "memory.usage" + % (vm[0],
" %f" % ( vm_proc.get_memory_percent() / 100 * vm[2]),
vm_proc.get_memory_percent() / 100 * vm[2]) 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." + systemtime = vm_proc.get_cpu_times().system
vm[0] + "." + "cpu.usage" + usertime = vm_proc.get_cpu_times().user
" %f" % (vm_proc.get_cpu_times().system + sumCpu = systemtime + usertime
vm_proc.get_cpu_times().user) metrics.append("vm.%s.cpu.usage %f %d"
+ " %d" % (time.time()) % (sumCpu, 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): if ((self.beat % self.kvmNet) is 0):
......
...@@ -9,6 +9,7 @@ def importConf(path_to_file): ...@@ -9,6 +9,7 @@ def importConf(path_to_file):
metrics = {} metrics = {}
params["debugMode"] = config.get("Client", "Debug") params["debugMode"] = config.get("Client", "Debug")
metrics["cpu.usage"] = int(config.get("Metrics", "cpuUsage")) metrics["cpu.usage"] = int(config.get("Metrics", "cpuUsage"))
metrics["cpu.times"] = int(config.get("Metrics", "cpuTimes"))
metrics["memory.usage"] = int(config.get("Metrics", "memoryUsage")) metrics["memory.usage"] = int(config.get("Metrics", "memoryUsage"))
metrics["user.count"] = int(config.get("Metrics", "userCount")) metrics["user.count"] = int(config.get("Metrics", "userCount"))
metrics["swap.usage"] = int(config.get("Metrics", "swapUsage")) metrics["swap.usage"] = int(config.get("Metrics", "swapUsage"))
......
...@@ -37,12 +37,19 @@ class Collection(object): ...@@ -37,12 +37,19 @@ class Collection(object):
class std(Collection): class std(Collection):
class cpu(Collection.Group): class cpu(Collection.Group):
class usage(Collection.Group.Metric): class usage(Collection.Group.Metric):
name = "cpu.usage" name = "cpu.usage"
collector_function = ps.cpu_percent collector_function = ps.cpu_percent
collector_function_arguments = {'interval': 0.0} collector_function_arguments = {'interval': 0.0}
class times(Collection.Group.Metric):
name = "cpu.times"
@classmethod
def harvest(cls):
return Metrics(cls.name,
ps.cpu_times().user + ps.cpu_times().system)
class memory(Collection.Group): class memory(Collection.Group):
class usage(Collection.Group.Metric): class usage(Collection.Group.Metric):
name = "memory.usage" name = "memory.usage"
...@@ -65,12 +72,12 @@ class std(Collection): ...@@ -65,12 +72,12 @@ class std(Collection):
class network(Collection.Group): class network(Collection.Group):
class packages_sent(Collection.Group.Metric): class packages_sent(Collection.Group.Metric):
name = "network.packages_sent" name = "network.packets_sent"
collector_function = ps.network_io_counters collector_function = ps.network_io_counters
collector_function_result_attr = "packets_sent" collector_function_result_attr = "packets_sent"
class packages_received(Collection.Group.Metric): class packages_received(Collection.Group.Metric):
name = "network.packages_received" name = "network.packets_recv"
collector_function = ps.network_io_counters collector_function = ps.network_io_counters
collector_function_result_attr = "packets_recv" collector_function_result_attr = "packets_recv"
......
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