AMP for kernel process is not working #1261

pull/1269/head
nicolargo 2018-05-19 16:36:08 +02:00
parent 3db4e105d3
commit c4c0a2d5d3
4 changed files with 7 additions and 2 deletions

1
NEWS
View File

@ -59,6 +59,7 @@ Bugs corrected:
* Glances --browser crashed when more than 40 glances servers on screen 78x45 #1256 * Glances --browser crashed when more than 40 glances servers on screen 78x45 #1256
* OSX - Python 3 and empty percent and res #1251 * OSX - Python 3 and empty percent and res #1251
* Crashes when influxdb option set #1260 * Crashes when influxdb option set #1260
* AMP for kernel process is not working #1261
Backward-incompatible changes: Backward-incompatible changes:

View File

@ -27,7 +27,7 @@ import signal
import sys import sys
# Global name # Global name
__version__ = '3.0.rc4' __version__ = '3.0.rc5'
__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>' __author__ = 'Nicolas Hennion <nicolas@nicolargo.com>'
__license__ = 'LGPLv3' __license__ = 'LGPLv3'

View File

@ -112,9 +112,12 @@ class AmpsList(object):
# Do not update if the enable tag is set # Do not update if the enable tag is set
continue continue
try: try:
# Search in both cmdline and name (for kernel thread, see #1261)
amps_list = [p for p in processlist for c in p['cmdline'] if re.search(v.regex(), c) is not None] amps_list = [p for p in processlist for c in p['cmdline'] if re.search(v.regex(), c) is not None]
amps_list += [p for p in processlist if re.search(v.regex(), p['name']) is not None]
except (TypeError, KeyError): except (TypeError, KeyError):
continue continue
logger.info(amps_list)
if len(amps_list) > 0: if len(amps_list) > 0:
# At least one process is matching the regex # At least one process is matching the regex
logger.debug("AMPS: {} process detected (PID={})".format(k, amps_list[0]['pid'])) logger.debug("AMPS: {} process detected (PID={})".format(k, amps_list[0]['pid']))

View File

@ -95,6 +95,7 @@ class Plugin(GlancesPlugin):
'ior': '{:>4} ', 'ior': '{:>4} ',
'iow': '{:<4} ', 'iow': '{:<4} ',
'command': '{}', 'command': '{}',
'name': '[{}]'
} }
def __init__(self, args=None): def __init__(self, args=None):
@ -332,7 +333,7 @@ class Plugin(GlancesPlugin):
msg = ' ' + self.layout_stat['command'].format(arguments) msg = ' ' + self.layout_stat['command'].format(arguments)
ret.append(self.curse_add_line(msg, splittable=True)) ret.append(self.curse_add_line(msg, splittable=True))
else: else:
msg = self.layout_stat['command'].format(p['name']) msg = self.layout_stat['name'].format(p['name'])
ret.append(self.curse_add_line(msg, splittable=True)) ret.append(self.curse_add_line(msg, splittable=True))
except UnicodeEncodeError: except UnicodeEncodeError:
ret.append(self.curse_add_line('', splittable=True)) ret.append(self.curse_add_line('', splittable=True))