mirror of https://github.com/nicolargo/glances.git
Disable history when history size is set to 0 by configuration.
This commit is contained in:
parent
2254f899b6
commit
7382089129
|
|
@ -104,18 +104,18 @@ def setup_server_mode(args, mode):
|
|||
|
||||
|
||||
def maybe_trace_memleak(args, snapshot_begin):
|
||||
if args.memory_leak:
|
||||
if args.trace_malloc or args.memory_leak:
|
||||
snapshot_end = tracemalloc.take_snapshot()
|
||||
if args.memory_leak:
|
||||
snapshot_diff = snapshot_end.compare_to(snapshot_begin, 'filename')
|
||||
memory_leak = sum([s.size_diff for s in snapshot_diff])
|
||||
print(f"Memory consumption: {memory_leak / 1000:.1f}KB (see log for details)")
|
||||
logger.info("Memory consumption (top 5):")
|
||||
for stat in snapshot_diff[:5]:
|
||||
logger.info(stat)
|
||||
elif args.trace_malloc:
|
||||
if args.trace_malloc:
|
||||
# See more options here: https://docs.python.org/3/library/tracemalloc.html
|
||||
snapshot = tracemalloc.take_snapshot()
|
||||
top_stats = snapshot.statistics("filename")
|
||||
top_stats = snapshot_end.statistics("filename")
|
||||
print("[ Trace malloc - Top 10 ]")
|
||||
for stat in top_stats[:10]:
|
||||
print(stat)
|
||||
|
|
|
|||
|
|
@ -824,6 +824,10 @@ Examples of use:
|
|||
disable(args, 'memswap')
|
||||
disable(args, 'load')
|
||||
|
||||
# Unicode => No separator
|
||||
if args.disable_unicode:
|
||||
args.enable_separator = False
|
||||
|
||||
# Memory leak
|
||||
if getattr(args, 'memory_leak', False):
|
||||
logger.info('Memory leak detection enabled')
|
||||
|
|
@ -833,9 +837,14 @@ Examples of use:
|
|||
args.time = 1
|
||||
args.disable_history = True
|
||||
|
||||
# Unicode => No separator
|
||||
if args.disable_unicode:
|
||||
args.enable_separator = False
|
||||
# Disable history if history_size is 0
|
||||
if self.config.has_section('global'):
|
||||
if self.config.get_int_value('global', 'history_size', default=1200) == 0:
|
||||
args.disable_history = True
|
||||
|
||||
# Display an information message if history is disabled
|
||||
if args.disable_history:
|
||||
logger.info("Stats history is disabled")
|
||||
|
||||
def parse_args(self, args_begin_at):
|
||||
"""Parse command line arguments.
|
||||
|
|
|
|||
Loading…
Reference in New Issue