Default AMP ignores enable setting #932

This commit is contained in:
nicolargo 2016-10-01 09:56:48 +02:00
parent 3a4bf77b79
commit 2acdbe9cf6
3 changed files with 10 additions and 4 deletions

1
NEWS
View File

@ -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
=============

View File

@ -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

View File

@ -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: