mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-01 14:08:34 +03:00
Merge branch 'desbma-develop' into develop
This commit is contained in:
commit
bb518bebde
@ -19,6 +19,7 @@
|
||||
|
||||
# Import Python lib
|
||||
import collections
|
||||
import operator
|
||||
import re
|
||||
|
||||
# Import psutil
|
||||
@ -704,21 +705,16 @@ class GlancesProcesses(object):
|
||||
# Sum of io_r + io_w
|
||||
try:
|
||||
# Sort process by IO rate (sum IO read + IO write)
|
||||
listsorted = sorted(self.processlist,
|
||||
key=lambda process: process[sortedby][0] -
|
||||
process[sortedby][2] + process[sortedby][1] -
|
||||
process[sortedby][3],
|
||||
reverse=sortedreverse)
|
||||
self.processlist.sort(key=lambda process: process[sortedby][0] -
|
||||
process[sortedby][2] + process[sortedby][1] -
|
||||
process[sortedby][3],
|
||||
reverse=sortedreverse)
|
||||
except Exception:
|
||||
listsorted = sorted(self.processlist,
|
||||
key=lambda process: process['cpu_percent'],
|
||||
reverse=sortedreverse)
|
||||
self.processlist.sort(key=operator.itemgetter('cpu_percent'),
|
||||
reverse=sortedreverse)
|
||||
else:
|
||||
# Others sorts
|
||||
listsorted = sorted(self.processlist,
|
||||
key=lambda process: process[sortedby],
|
||||
reverse=sortedreverse)
|
||||
|
||||
self.processlist = listsorted
|
||||
self.processlist.sort(key=operator.itemgetter(sortedby),
|
||||
reverse=sortedreverse)
|
||||
|
||||
return self.processlist
|
||||
|
@ -664,7 +664,7 @@ class _GlancesCurses(object):
|
||||
# Exit if:
|
||||
# - the plugin_stats message is empty
|
||||
# - the display tag = False
|
||||
if plugin_stats['msgdict'] == [] or not plugin_stats['display']:
|
||||
if not plugin_stats['msgdict'] or not plugin_stats['display']:
|
||||
# Exit
|
||||
return 0
|
||||
|
||||
|
@ -140,8 +140,8 @@ class GlancesHistory(object):
|
||||
# Find if anothers key ends with the key
|
||||
# Ex: key='tx' => 'ethernet_tx'
|
||||
# Add one curve per chart
|
||||
stats_history_filtered = sorted(
|
||||
[key for key in h.keys() if key.endswith('_' + i['name'])])
|
||||
stats_history_filtered = [key for key in h.keys() if key.endswith('_' + i['name'])]
|
||||
stats_history_filtered.sort()
|
||||
logger.debug("Generate graphs: %s %s" %
|
||||
(p, stats_history_filtered))
|
||||
if len(stats_history_filtered) > 0:
|
||||
|
@ -67,7 +67,7 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
# Build the string message
|
||||
# Header
|
||||
if self.stats == []:
|
||||
if not self.stats:
|
||||
msg = _("No warning or critical alert detected")
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
else:
|
||||
|
@ -103,7 +103,7 @@ class GlancesGrabBat(object):
|
||||
|
||||
def getcapacitypercent(self):
|
||||
"""Get batteries capacity percent."""
|
||||
if not self.initok or self.bat.stat == []:
|
||||
if not self.initok or not self.bat.stat:
|
||||
return []
|
||||
|
||||
# Init the bsum (sum of percent)
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
"""Disk I/O plugin."""
|
||||
|
||||
import operator
|
||||
|
||||
import psutil
|
||||
|
||||
# Import Glances libs
|
||||
@ -122,7 +124,7 @@ class Plugin(GlancesPlugin):
|
||||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if self.stats == [] or args.disable_diskio:
|
||||
if not self.stats or args.disable_diskio:
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
@ -134,7 +136,7 @@ class Plugin(GlancesPlugin):
|
||||
msg = '{0:>7}'.format(_("W/s"))
|
||||
ret.append(self.curse_add_line(msg))
|
||||
# Disk list (sorted by name)
|
||||
for i in sorted(self.stats, key=lambda diskio: diskio['disk_name']):
|
||||
for i in sorted(self.stats, key=operator.itemgetter('disk_name')):
|
||||
# Do not display hidden interfaces
|
||||
if self.is_hide(i['disk_name']):
|
||||
continue
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
"""File system plugin."""
|
||||
|
||||
import operator
|
||||
|
||||
import psutil
|
||||
|
||||
from glances.plugins.glances_plugin import GlancesPlugin
|
||||
@ -158,7 +160,7 @@ class Plugin(GlancesPlugin):
|
||||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if self.stats == [] or args.disable_fs:
|
||||
if not self.stats or args.disable_fs:
|
||||
return ret
|
||||
|
||||
# Max size for the fsname name
|
||||
@ -181,7 +183,7 @@ class Plugin(GlancesPlugin):
|
||||
ret.append(self.curse_add_line(msg))
|
||||
|
||||
# Disk list (sorted by name)
|
||||
for i in sorted(self.stats, key=lambda fs: fs['mnt_point']):
|
||||
for i in sorted(self.stats, key=operator.itemgetter('mnt_point')):
|
||||
# New line
|
||||
ret.append(self.curse_new_line())
|
||||
if i['device_name'] == '' or i['device_name'] == 'none':
|
||||
|
@ -88,7 +88,7 @@ class Plugin(GlancesPlugin):
|
||||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if self.stats == [] or args.disable_process:
|
||||
if not self.stats or args.disable_process:
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
@ -20,6 +20,7 @@
|
||||
"""Network plugin."""
|
||||
|
||||
import base64
|
||||
import operator
|
||||
|
||||
import psutil
|
||||
|
||||
@ -185,7 +186,7 @@ class Plugin(GlancesPlugin):
|
||||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if self.stats == [] or args.disable_network:
|
||||
if not self.stats or args.disable_network:
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
@ -223,7 +224,7 @@ class Plugin(GlancesPlugin):
|
||||
msg = '{0:>7}'.format(_("Tx/s"))
|
||||
ret.append(self.curse_add_line(msg))
|
||||
# Interface list (sorted by name)
|
||||
for i in sorted(self.stats, key=lambda network: network['interface_name']):
|
||||
for i in sorted(self.stats, key=operator.itemgetter('interface_name')):
|
||||
# Do not display hidden interfaces
|
||||
if self.is_hide(i['interface_name']):
|
||||
continue
|
||||
|
@ -130,7 +130,7 @@ class Plugin(GlancesPlugin):
|
||||
ret = []
|
||||
|
||||
# No per CPU stat ? Exit...
|
||||
if self.stats == []:
|
||||
if not self.stats:
|
||||
msg = _("PER CPU not available")
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
return ret
|
||||
|
@ -20,6 +20,7 @@
|
||||
"""Process list plugin."""
|
||||
|
||||
# Import sys libs
|
||||
import operator
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
@ -355,14 +356,11 @@ class Plugin(GlancesPlugin):
|
||||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if self.stats == [] or args.disable_process:
|
||||
if not self.stats or args.disable_process:
|
||||
return ret
|
||||
|
||||
# Compute the sort key
|
||||
if glances_processes.getmanualsortkey() is None:
|
||||
process_sort_key = glances_processes.getautosortkey()
|
||||
else:
|
||||
process_sort_key = glances_processes.getmanualsortkey()
|
||||
process_sort_key = glances_processes.getsortkey()
|
||||
sort_style = 'SORT'
|
||||
|
||||
# Header
|
||||
@ -427,30 +425,23 @@ class Plugin(GlancesPlugin):
|
||||
# Sum of io_r + io_w
|
||||
try:
|
||||
# Sort process by IO rate (sum IO read + IO write)
|
||||
listsorted = sorted(self.stats,
|
||||
key=lambda process: process[sortedby][0] -
|
||||
process[sortedby][2] + process[sortedby][1] -
|
||||
process[sortedby][3],
|
||||
reverse=sortedreverse)
|
||||
self.stats.sort(key=lambda process: process[sortedby][0] -
|
||||
process[sortedby][2] + process[sortedby][1] -
|
||||
process[sortedby][3],
|
||||
reverse=sortedreverse)
|
||||
except Exception:
|
||||
listsorted = sorted(self.stats,
|
||||
key=lambda process: process['cpu_percent'],
|
||||
reverse=sortedreverse)
|
||||
self.stats.sort(key=operator.itemgetter('cpu_percent'),
|
||||
reverse=sortedreverse)
|
||||
else:
|
||||
# Others sorts
|
||||
if tree:
|
||||
self.stats.set_sorting(sortedby, sortedreverse)
|
||||
else:
|
||||
try:
|
||||
listsorted = sorted(self.stats,
|
||||
key=lambda process: process[sortedby],
|
||||
reverse=sortedreverse)
|
||||
self.stats.sort(key=operator.itemgetter(sortedby),
|
||||
reverse=sortedreverse)
|
||||
except (KeyError, TypeError):
|
||||
listsorted = sorted(self.stats,
|
||||
key=lambda process: process['name'],
|
||||
reverse=False)
|
||||
|
||||
if not tree:
|
||||
self.stats = listsorted
|
||||
self.stats.sort(key=operator.itemgetter('name'),
|
||||
reverse=False)
|
||||
|
||||
return self.stats
|
||||
|
@ -125,7 +125,7 @@ class Plugin(GlancesPlugin):
|
||||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if self.stats == [] or args.disable_sensors:
|
||||
if not self.stats or args.disable_sensors:
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
Loading…
Reference in New Issue
Block a user