Commit 34d2ee59 by root

Fixed collectables error: list hash and scheduler

parent 34f94315
[Client] [Client]
Debug = True Debug = False
[Metrics] [Metrics]
cpuUsage = True cpuUsage = 5
memoryUsage = True memoryUsage = 5
userCount = True userCount = 60
swapUsage = True swapUsage = 30
systemBootTime = True systemBootTime = 120
packageTraffic = True packageTraffic = 10
dataTraffic = True dataTraffic = 10
...@@ -60,7 +60,7 @@ class Client: ...@@ -60,7 +60,7 @@ class Client:
""" """
Send the message given in the parameters. Send the message given in the parameters.
""" """
self.channel.basic_publish(exchange=self. amqp_queue, self.channel.basic_publish(exchange=self.amqp_queue,
routing_key='', body="\n".join(message)) routing_key='', body="\n".join(message))
def __collectFromNode(self, metricCollectors): def __collectFromNode(self, metricCollectors):
...@@ -96,9 +96,9 @@ class Client: ...@@ -96,9 +96,9 @@ class Client:
% (self.server_address + ":" + str(self.server_port))) % (self.server_address + ":" + str(self.server_port)))
else: else:
print("Connection established to %s on port %s. \ print("Connection established to %s on port %s. \
Report frequency is %d sec. Clientname: %s" Clientname: %s"
% (self.server_address, self.server_port, % (self.server_address, self.server_port,
self.delay, self.name)) self.name))
try: try:
maxFrequency = self.getMaxFrequency(metricCollectors) maxFrequency = self.getMaxFrequency(metricCollectors)
while True: while True:
......
...@@ -21,7 +21,7 @@ def importConf(path_to_file): ...@@ -21,7 +21,7 @@ def importConf(path_to_file):
except configparser.ParsingError: except configparser.ParsingError:
print("Config file contains error! Reason: Cannot parse.") print("Config file contains error! Reason: Cannot parse.")
raise raise
except configparser.MissingSectionHeader: except configparser.MissingSectionHeaderError:
print("Config file contains error! Reason: Missing section-header.") print("Config file contains error! Reason: Missing section-header.")
raise raise
......
...@@ -32,15 +32,15 @@ class collectables: ...@@ -32,15 +32,15 @@ class collectables:
@staticmethod @staticmethod
def provide(requests=[]): def provide(requests=[]):
#valid_keys = collectables.listKeys() #valid_keys = collectables.listKeys()
reqs = [request for request, value in requests.items() reqs = []
if value > 0] for requests, value in requests.items():
if value>0:
reqs.append([requests, value])
collectors = [] collectors = []
for request in reqs: for request in reqs:
for item in collectables.__collectables[request]: for item in collectables.__collectables[request[0]]:
collectors.append([item.harvest, value]) collectors.append([item.harvest, request[1]])
seen = set() return collectors
seen_add = seen.add
return [x for x in collectors if x not in seen and not seen_add(x)]
@staticmethod @staticmethod
def provideAll(): def provideAll():
......
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