提交 2acdbe9c 编写于 作者: N nicolargo

Default AMP ignores enable setting #932

上级 3a4bf77b
......@@ -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
=============
......
......@@ -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
......
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册