diff --git a/NEWS b/NEWS index 93a162dd..870784b9 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,7 @@ Bugs corrected: * Glances RAID plugin Traceback (issue #927) * Default AMP crashes when 'command' given (issue #933) + * Default AMP ignores `enable` setting (issue #932) Version 2.7.1 ============= diff --git a/glances/amps/glances_default.py b/glances/amps/glances_default.py index 7392d796..8b388c46 100644 --- a/glances/amps/glances_default.py +++ b/glances/amps/glances_default.py @@ -35,7 +35,7 @@ one_line=false command=foo status """ -from subprocess import check_output, STDOUT +from subprocess import check_output, STDOUT, CalledProcessError from glances.compat import u, to_ascii from glances.logger import logger @@ -66,8 +66,11 @@ class Amp(GlancesAmp): logger.debug('{}: Error while executing service ({})'.format(self.NAME, e)) else: if res is not None: - msg = u(check_output(res.split(), stderr=STDOUT)) - self.set_result(to_ascii(msg.rstrip())) + try: + msg = u(check_output(res.split(), stderr=STDOUT)) + self.set_result(to_ascii(msg.rstrip())) + except CalledProcessError as e: + self.set_result(e.output) else: # Set the default message if command return None # Default sum of CPU and MEM for the matching regex diff --git a/glances/amps_list.py b/glances/amps_list.py index c9020717..cbb0fe22 100644 --- a/glances/amps_list.py +++ b/glances/amps_list.py @@ -106,9 +106,11 @@ class AmpsList(object): """Update the command result attributed.""" # Search application monitored processes by a regular expression processlist = glances_processes.getalllist() - # Iter upon the AMPs dict for k, v in iteritems(self.get()): + if not v.enable(): + # Do not update if the enable tag is set + continue try: amps_list = [p for p in processlist for c in p['cmdline'] if re.search(v.regex(), c) is not None] except TypeError: