Optimise sort for log

This commit is contained in:
Nicolas Hennion 2014-03-09 10:03:47 +01:00
parent 473eb62b15
commit e8730ec58e
5 changed files with 14 additions and 20 deletions

View File

@ -42,7 +42,8 @@ def main(argv=None):
elif (core.is_client()):
# !!!
print "Client mode"
print(_("Glances client connected to %s:%s") % (core.server_ip, core.server_port))
print("TODO...")
elif (core.is_server()):
# Import the Glances server module
from .core.glances_server import GlancesServer
@ -51,7 +52,7 @@ def main(argv=None):
server = GlancesServer(bind_address=core.bind_ip,
bind_port=int(core.server_port),
cached_time=core.cached_time,
config=core.config)
config=core.get_config())
# print(_("Glances server is running on %s:%s with config file %s") % (core.bind_ip, core.server_port, core.config.get_config_path()))
print(_("Glances server is running on %s:%s") % (core.bind_ip, core.server_port))

View File

@ -108,16 +108,6 @@ class glancesLogs:
# Do no sort process for monitored prcesses list
self.sort_process_by = 'none'
# Sort processes
if (process_auto_by != 'none'):
# !!! Process list is sorted twise ???
# !!! Here and in the processlist plugin
topprocess = sorted(proc_list, key=lambda process: process[process_auto_by],
reverse=True)
else:
# !!! Never in v2 because MON are not logged...
topprocess = proc_list
# Add or update the log
item_index = self.__itemexist__(item_type)
if (item_index < 0):
@ -136,6 +126,10 @@ class glancesLogs:
item.append(item_value) # MIN
item.append(item_value) # SUM
item.append(1) # COUNT
# Process list is sorted automaticaly
# Overwrite the user choise
topprocess = sorted(proc_list, key=lambda process: process[process_auto_by],
reverse=True)
item.append(topprocess[0:3]) # TOP 3 PROCESS LIST
item.append(proc_desc) # MONITORED PROCESSES DESC
self.logs_list.insert(0, item)
@ -166,6 +160,10 @@ class glancesLogs:
self.logs_list[item_index][8] += 1
self.logs_list[item_index][5] = (self.logs_list[item_index][7] /
self.logs_list[item_index][8])
# Process list is sorted automaticaly
# Overwrite the user choise
topprocess = sorted(proc_list, key=lambda process: process[process_auto_by],
reverse=True)
# TOP PROCESS LIST
self.logs_list[item_index][9] = topprocess[0:3]
# MONITORED PROCESSES DESC

View File

@ -102,11 +102,10 @@ class GlancesMain(object):
if (self.is_standalone()):
# Stop the classical CLI loop
# !!! Uncomment
# screen.end()
pass
screen.end()
elif (self.is_client()):
# Stop the client loop
# !!! Uncomment
#~ client.client_quit()
pass
elif (self.is_server()):

View File

@ -195,10 +195,6 @@ class glancesProcesses:
"""
Return the processlist
"""
# if (sorted_by is not None):
# # Need to sort ?
# self.processlist = sorted(self.processlist, key=lambda process: process[sorted_by], reverse=True)
# return self.processlist
if (sortedby is None):
# No need to sort...

View File

@ -199,7 +199,7 @@ class GlancesInstance():
# Default behavior
raise AttributeError(item)
#!!! How to implement theses method in v2 ?
# !!! How to implement theses method in v2 ?
# def __getTimeSinceLastUpdate(self, IOType):
# assert(IOType in ['net', 'disk', 'process_disk'])