mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-27 03:04:16 +03:00
Optimise sort for log
This commit is contained in:
parent
473eb62b15
commit
e8730ec58e
@ -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))
|
||||
|
||||
|
@ -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
|
||||
|
@ -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()):
|
||||
|
@ -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...
|
||||
|
Loading…
Reference in New Issue
Block a user