Commit d6655c03 by Gregory Nagy

cpuTimes added and syncronization added with celerymonitor

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