提交 30c5890a 编写于 作者: N nicolargo

Merge branch 'issue948' into develop

......@@ -22,6 +22,7 @@ Enhancements and news features:
* Make the log logger configurable (issue #900)
* System uptime in export (issue #890)
* Deprecated platform method in Python 3.7 (issue #945)
* Refactor the --disable-* options (issue #948)
Bugs corrected:
......
......@@ -99,54 +99,54 @@ Start the client browser (browser mode):\n\
parser.add_argument('-C', '--config', dest='conf_file',
help='path to the configuration file')
# Enable or disable option on startup
parser.add_argument('-3', '--disable-quicklook', action='store_true', default=False,
dest='disable_quicklook', help='disable quick look module')
parser.add_argument('-4', '--full-quicklook', action='store_true', default=False,
dest='full_quicklook', help='disable all but quick look and load')
parser.add_argument('--disable-alert', action='store_true', default=False,
dest='disable_alert', help='disable alert module')
parser.add_argument('--disable-amps', action='store_true', default=False,
dest='disable_amps', help='disable applications monitoring process (AMP) module')
parser.add_argument('--disable-cpu', action='store_true', default=False,
dest='disable_cpu', help='disable CPU module')
parser.add_argument('--disable-mem', action='store_true', default=False,
dest='disable_mem', help='disable memory module')
parser.add_argument('--disable-swap', action='store_true', default=False,
dest='disable_swap', help='disable swap module')
parser.add_argument('--disable-load', action='store_true', default=False,
dest='disable_load', help='disable load module')
parser.add_argument('--disable-network', action='store_true', default=False,
dest='disable_network', help='disable network module')
parser.add_argument('--disable-wifi', action='store_true', default=False,
dest='disable_wifi', help='disable wifi module')
parser.add_argument('--disable-ports', action='store_true', default=False,
dest='disable_ports', help='disable ports scanner module')
parser.add_argument('--disable-ip', action='store_true', default=False,
dest='disable_ip', help='disable IP module')
parser.add_argument('--disable-diskio', action='store_true', default=False,
dest='disable_diskio', help='disable disk I/O module')
parser.add_argument('--disable-irq', action='store_true', default=False,
dest='disable_irq', help='disable IRQ module'),
parser.add_argument('--disable-docker', action='store_true', default=False,
dest='disable_docker', help='disable Docker module')
parser.add_argument('--disable-folders', action='store_true', default=False,
dest='disable_folders', help='disable folder module')
parser.add_argument('--disable-fs', action='store_true', default=False,
dest='disable_fs', help='disable filesystem module')
parser.add_argument('--disable-folder', action='store_true', default=False,
dest='disable_folder', help='disable folder module')
parser.add_argument('--disable-sensors', action='store_true', default=False,
dest='disable_sensors', help='disable sensors module')
parser.add_argument('--disable-hddtemp', action='store_true', default=False,
dest='disable_hddtemp', help='disable HD temperature module')
parser.add_argument('--disable-ip', action='store_true', default=False,
dest='disable_ip', help='disable IP module')
parser.add_argument('--disable-irq', action='store_true', default=False,
dest='disable_irq', help='disable IRQ module'),
parser.add_argument('--disable-load', action='store_true', default=False,
dest='disable_load', help='disable load module')
parser.add_argument('--disable-mem', action='store_true', default=False,
dest='disable_mem', help='disable memory module')
parser.add_argument('--disable-memswap', action='store_true', default=False,
dest='disable_memswap', help='disable memory swap module')
parser.add_argument('--disable-network', action='store_true', default=False,
dest='disable_network', help='disable network module')
parser.add_argument('--disable-ports', action='store_true', default=False,
dest='disable_ports', help='disable ports scanner module')
parser.add_argument('--disable-process', action='store_true', default=False,
dest='disable_process', help='disable process module')
parser.add_argument('--disable-raid', action='store_true', default=False,
dest='disable_raid', help='disable RAID module')
parser.add_argument('--disable-docker', action='store_true', default=False,
dest='disable_docker', help='disable Docker module')
parser.add_argument('-5', '--disable-top', action='store_true',
default=False, dest='disable_top',
help='disable top menu (QL, CPU, MEM, SWAP and LOAD)')
parser.add_argument('--disable-sensors', action='store_true', default=False,
dest='disable_sensors', help='disable sensors module')
parser.add_argument('--disable-wifi', action='store_true', default=False,
dest='disable_wifi', help='disable wifi module')
parser.add_argument('-2', '--disable-left-sidebar', action='store_true',
default=False, dest='disable_left_sidebar',
help='disable network, disk I/O, FS and sensors modules')
parser.add_argument('--disable-process', action='store_true', default=False,
dest='disable_process', help='disable process module')
parser.add_argument('--disable-amps', action='store_true', default=False,
dest='disable_amps', help='disable applications monitoring process (AMP) module')
parser.add_argument('--disable-log', action='store_true', default=False,
dest='disable_log', help='disable log module')
parser.add_argument('-3', '--disable-quicklook', action='store_true', default=False,
dest='disable_quicklook', help='disable quick look module')
parser.add_argument('-4', '--full-quicklook', action='store_true', default=False,
dest='full_quicklook', help='disable all but quick look and load')
parser.add_argument('-5', '--disable-top', action='store_true',
default=False, dest='disable_top',
help='disable top menu (QL, CPU, MEM, SWAP and LOAD)')
parser.add_argument('--disable-history', action='store_true', default=False,
dest='disable_history', help='disable stats history')
parser.add_argument('--disable-bold', action='store_true', default=False,
......
......@@ -317,12 +317,12 @@ class _GlancesCurses(object):
self.args.disable_quicklook = False
self.args.disable_cpu = True
self.args.disable_mem = True
self.args.disable_swap = True
self.args.disable_memswap = True
else:
self.args.disable_quicklook = False
self.args.disable_cpu = False
self.args.disable_mem = False
self.args.disable_swap = False
self.args.disable_memswap = False
elif self.pressedkey == ord('5'):
# '5' > Enable/disable top menu
logger.info(self.args.disable_top)
......@@ -331,13 +331,13 @@ class _GlancesCurses(object):
self.args.disable_quicklook = True
self.args.disable_cpu = True
self.args.disable_mem = True
self.args.disable_swap = True
self.args.disable_memswap = True
self.args.disable_load = True
else:
self.args.disable_quicklook = False
self.args.disable_cpu = False
self.args.disable_mem = False
self.args.disable_swap = False
self.args.disable_memswap = False
self.args.disable_load = False
elif self.pressedkey == ord('/'):
# '/' > Switch between short/long name for processes
......@@ -382,7 +382,7 @@ class _GlancesCurses(object):
elif self.pressedkey == ord('f'):
# 'f' > Show/hide fs / folder stats
self.args.disable_fs = not self.args.disable_fs
self.args.disable_folder = not self.args.disable_folder
self.args.disable_folders = not self.args.disable_folders
elif self.pressedkey == ord('g'):
# 'g' > Export graphs to file
self.graph_tag = not self.graph_tag
......@@ -397,8 +397,8 @@ class _GlancesCurses(object):
# 'I' > Show/hide IP module
self.args.disable_ip = not self.args.disable_ip
elif self.pressedkey == ord('l'):
# 'l' > Show/hide log messages
self.args.disable_log = not self.args.disable_log
# 'l' > Show/hide alert/log messages
self.args.disable_alert = not self.args.disable_alert
elif self.pressedkey == ord('m'):
# 'm' > Sort processes by MEM usage
glances_processes.auto_sort = False
......@@ -639,7 +639,7 @@ class _GlancesCurses(object):
mem_width = 0
else:
mem_width = self.get_stats_display_width(stats_mem)
if self.args.disable_swap:
if self.args.disable_memswap:
swap_width = 0
else:
swap_width = self.get_stats_display_width(stats_memswap)
......@@ -655,7 +655,7 @@ class _GlancesCurses(object):
stats_number = (
int(not self.args.disable_cpu and stats_cpu['msgdict'] != []) +
int(not self.args.disable_mem and stats_mem['msgdict'] != []) +
int(not self.args.disable_swap and stats_memswap['msgdict'] != []) +
int(not self.args.disable_memswap and stats_memswap['msgdict'] != []) +
int(not self.args.disable_load and stats_load['msgdict'] != []))
if not self.args.disable_quicklook:
......@@ -728,7 +728,7 @@ class _GlancesCurses(object):
self.args.disable_diskio and
self.args.disable_fs and
self.args.disable_irq and
self.args.disable_folder and
self.args.disable_folders and
self.args.disable_raid and
self.args.disable_sensors) and not self.args.disable_left_sidebar:
for s in (stats_network, stats_wifi, stats_ports, stats_diskio, stats_fs, stats_irq, stats_folders, stats_raid, stats_sensors, stats_now):
......
......@@ -60,7 +60,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if display plugin enable...
if args.disable_log:
if not self.stats and self.is_disable():
return ret
# Build the string message
......
......@@ -97,7 +97,7 @@ class Plugin(GlancesPlugin):
# Only process if stats exist and display plugin enable...
ret = []
if not self.stats or args.disable_process or args.disable_amps:
if not self.stats or args.disable_process or self.is_disable():
return ret
# Build the string message
......
......@@ -68,8 +68,6 @@ class Plugin(GlancesPlugin):
"""Init the CPU plugin."""
super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -94,9 +92,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_cpu:
return self.stats
# Grab stats into self.stats
if self.input_method == 'local':
self.update_local()
......@@ -230,7 +225,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and plugin not disable
if not self.stats or args.disable_cpu:
if not self.stats or self.is_disable():
return ret
# Build the string message
......
......@@ -51,8 +51,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -74,9 +72,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_diskio:
return self.stats
if self.input_method == 'local':
# Update stats using the standard system lib
# Grab the stat using the PsUtil disk_io_counters method
......@@ -175,7 +170,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or args.disable_diskio:
if not self.stats or self.is_disable():
return ret
# Build the string message
......
......@@ -160,7 +160,7 @@ class Plugin(GlancesPlugin):
docker_tag = False
# The Docker-py lib is mandatory
if not docker_tag or (self.args is not None and self.args.disable_docker):
if not docker_tag:
return self.stats
if self.input_method == 'local':
......@@ -491,7 +491,9 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist (and non null) and display plugin enable...
if not self.stats or args.disable_docker or len(self.stats['containers']) == 0:
if not self.stats \
or len(self.stats['containers']) == 0 \
or self.is_disable():
return ret
# Build the string message
......
......@@ -33,8 +33,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -61,9 +59,6 @@ class Plugin(GlancesPlugin):
# Reset the list
self.reset()
if self.args is not None and self.args.disable_folder:
return self.stats
if self.input_method == 'local':
# Folder list only available in a full Glances environment
# Check if the glances_folder instance is init
......@@ -103,7 +98,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or args.disable_folder:
if not self.stats or self.is_disable():
return ret
# Build the string message
......
......@@ -75,8 +75,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -98,9 +96,6 @@ class Plugin(GlancesPlugin):
# Reset the list
self.reset()
if self.args is not None and self.args.disable_fs:
return self.stats
if self.input_method == 'local':
# Update stats using the standard system lib
......@@ -210,7 +205,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or args.disable_fs:
if not self.stats or self.is_disable():
return ret
# Max size for the fsname name
......
......@@ -92,10 +92,6 @@ class GlancesGrabHDDTemp(object):
# Reset the list
self.reset()
# Only update if --disable-hddtemp is not set
if self.args is None or self.args.disable_hddtemp:
return
# Fetch the data
# data = ("|/dev/sda|WDC WD2500JS-75MHB0|44|C|"
# "|/dev/sdb|WDC WD2500JS-75MHB0|35|C|"
......
......@@ -62,8 +62,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -87,9 +85,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_ip:
return self.stats
if self.input_method == 'local' and netifaces_tag:
# Update stats using the netifaces lib
try:
......@@ -131,7 +126,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or args.disable_ip:
if not self.stats or self.is_disable():
return ret
# Build the string message
......
......@@ -40,8 +40,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -69,7 +67,6 @@ class Plugin(GlancesPlugin):
# IRQ plugin only available on GNU/Linux
# Correct issue #947: IRQ file do not exist on OpenVZ container
if not LINUX \
or (self.args is not None and self.args.disable_irq) \
or not os.path.exists(self.IRQ_FILE):
return self.stats
......@@ -120,7 +117,7 @@ class Plugin(GlancesPlugin):
return ret
# Only process if stats exist and display plugin enable...
if not self.stats or args.disable_irq:
if not self.stats or self.is_disable():
return ret
if max_width is not None and max_width >= 23:
......
......@@ -58,8 +58,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -83,9 +81,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_load:
return self.stats
if self.input_method == 'local':
# Update stats using the standard system lib
......@@ -143,7 +138,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist, not empty (issue #871) and plugin not disabled
if not self.stats or (self.stats == {}) or args.disable_load:
if not self.stats or (self.stats == {}) or self.is_disable():
return ret
# Build the string message
......
......@@ -66,8 +66,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -85,9 +83,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_mem:
return self.stats
if self.input_method == 'local':
# Update stats using the standard system lib
# Grab MEM using the PSUtil virtual_memory method
......@@ -189,7 +184,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and plugin not disabled
if not self.stats or args.disable_mem:
if not self.stats or self.is_disable():
return ret
# Build the string message
......
......@@ -54,8 +54,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -73,9 +71,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_swap:
return self.stats
if self.input_method == 'local':
# Update stats using the standard system lib
# Grab SWAP using the PSUtil swap_memory method
......@@ -160,7 +155,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and plugin not disabled
if not self.stats or args.disable_swap:
if not self.stats or self.is_disable():
return ret
# Build the string message
......
......@@ -59,8 +59,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -85,9 +83,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_network:
return self.stats
if self.input_method == 'local':
# Update stats using the standard system lib
......@@ -272,7 +267,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or args.disable_network:
if not self.stats or self.is_disable():
return ret
# Max size for the interface name
......
......@@ -35,8 +35,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -58,9 +56,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_cpu:
return self.stats
# Grab per-CPU stats using psutil's cpu_percent(percpu=True) and
# cpu_times_percent(percpu=True) methods
if self.input_method == 'local':
......@@ -76,10 +71,6 @@ class Plugin(GlancesPlugin):
# Init the return message
ret = []
# Only process if plugin not disable
if args.disable_cpu:
return ret
# No per CPU stat ? Exit...
if not self.stats:
msg = 'PER CPU not available'
......
......@@ -87,7 +87,7 @@ class GlancesPlugin(object):
return None
def is_enable(self):
"""Return true if plugin is enable"""
"""Return true if plugin is enabled"""
try:
d = getattr(self.args, 'disable_' + self.plugin_name)
except AttributeError:
......@@ -95,6 +95,10 @@ class GlancesPlugin(object):
else:
return d is False
def is_disable(self):
"""Return true if plugin is disabled"""
return not self.is_enable()
def _json_dumps(self, d):
"""Return the object 'd' in a JSON format
Manage the issue #815 for Windows OS"""
......
......@@ -66,9 +66,6 @@ class Plugin(GlancesPlugin):
def update(self):
"""Update the ports list."""
if self.args is not None and self.args.disable_ports:
return self.stats
if self.input_method == 'local':
# Only refresh:
# * if there is not other scanning thread
......
......@@ -108,7 +108,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist...
if not self.stats or args.disable_quicklook:
if not self.stats or self.is_disable():
return ret
# Define the bar
......
......@@ -41,8 +41,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -60,9 +58,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
if self.args is not None and self.args.disable_raid:
return self.stats
if self.input_method == 'local':
# Update stats using the PyMDstat lib (https://github.com/nicolargo/pymdstat)
try:
......@@ -87,8 +82,8 @@ class Plugin(GlancesPlugin):
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or args.disable_raid:
# Only process if stats exist...
if not self.stats:
return ret
# Build the string message
......
......@@ -53,8 +53,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args)
self.args = args
# Init the sensor class
self.glancesgrabsensors = GlancesGrabSensors()
......@@ -87,9 +85,6 @@ class Plugin(GlancesPlugin):
# Reset the stats
self.reset()
if self.args is not None and self.args.disable_sensors:
return self.stats
if self.input_method == 'local':
# Update stats using the dedicated lib
self.stats = []
......
......@@ -49,8 +49,6 @@ class Plugin(GlancesPlugin):
"""Init the plugin."""
super(Plugin, self).__init__(args=args)
self.args = args
# We want to display the stat in the curse interface
self.display_curse = True
......@@ -84,7 +82,7 @@ class Plugin(GlancesPlugin):
self.reset()
# Exist if we can not grab the stats
if not wifi_tag or (self.args is not None and self.args.disable_wifi):
if not wifi_tag:
return self.stats
if self.input_method == 'local':
......
......@@ -150,7 +150,11 @@ class GlancesStats(object):
# For standalone and server modes
# For each plugins, call the update method
for p in self._plugins:
# logger.debug("Update %s stats" % p)
if self._plugins[p].is_disable():
# If current plugin is disable
# then continue to next plugin
continue
# Update the stats
self._plugins[p].update()
def export(self, input_stats=None):
......
......@@ -100,9 +100,16 @@ class GlancesStatsClientSNMP(GlancesStats):
"""Update the stats using SNMP."""
# For each plugins, call the update method
for p in self._plugins:
if self._plugins[p].is_disable():
# If current plugin is disable
# then continue to next plugin
continue
# Set the input method to SNMP
self._plugins[p].input_method = 'snmp'
self._plugins[p].short_system_name = self.system_name
# Update the stats
try:
self._plugins[p].update()
except Exception as e:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册