Commit 2c5ae1f7 by Gregory Nagy

Client.conf file KVM section added.

client.py pip8 formated
cnfparse.py pip8 formated
collectables.py fixed bug and pip formated
parent 743a2c72
......@@ -9,3 +9,7 @@ swapUsage = 30
systemBootTime = 120
packageTraffic = 10
dataTraffic = 10
[KVM]
cpuUsage =5
memoryUsage = 5
#!/usr/bin/python
# import platform
# import collections
import time
import socket
import pika
......@@ -14,7 +12,6 @@ logging.basicConfig()
class Client:
def __init__(self, config):
"""
Constructor of the client requires a configuration provided by cnfparse
......@@ -89,14 +86,14 @@ class Client:
memory = [cmd_param_index for cmd_param_index, cmd_param in
enumerate(entry.as_dict()["cmdline"])
if cmd_param == "-m"]
running_vms.append([entry.as_dict()["cmdline"][search[0]+1],
running_vms.append([entry.as_dict()["cmdline"][search[0] + 1],
entry.pid,
int(entry.as_dict()["cmdline"][memory[0]+1])])
int(entry.as_dict()["cmdline"][memory[0] + 1])])
for vm in running_vms:
vm_proc = psutil.Process(vm[1])
metrics.append((self.name + "." + "kvm." +
vm[0] + "." + "memory.usage." +
" %d" % (vm_proc.get_memory_percent()/100*vm[2])
" %d" % (vm_proc.get_memory_percent() / 100 * vm[2])
+ " %d" % (time.time())
))
metrics.append((self.name + "." + "kvm." +
......
......@@ -15,8 +15,8 @@ def importConf(path_to_file):
metrics["system.boot_time"] = int(config.get("Metrics",
"systemBootTime"))
metrics["network"] = int(config.get("Metrics", "dataTraffic"))
metrics["kvmCpuUsage"] = int(config.get("KVM", "cpuUsage"))
metrics["kvmMemoryUsage"] = int(config.get("KVM", "memoryUsage"))
params["kvmCpuUsage"] = int(config.get("KVM", "cpuUsage"))
params["kvmMemoryUsage"] = int(config.get("KVM", "memoryUsage"))
except configparser.NoSectionError:
print("Config file contains error! Reason: Missing section.")
raise
......
......@@ -2,7 +2,6 @@ from metrics import *
class collectables:
__collectables = {
std.cpu.usage.name: [std.cpu.usage],
std.memory.usage.name: [std.memory.usage],
......@@ -34,7 +33,7 @@ class collectables:
#valid_keys = collectables.listKeys()
reqs = []
for requests, value in requests.items():
if value>0:
if value > 0:
reqs.append([requests, value])
collectors = []
for request in reqs:
......
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