diff options
author | nicolargo <nicolas@nicolargo.com> | 2018-09-04 23:15:55 +0200 |
---|---|---|
committer | nicolargo <nicolas@nicolargo.com> | 2018-09-04 23:15:55 +0200 |
commit | 9b29f15130319f59421c4e4c7df668873105b0b1 (patch) | |
tree | a0faefe88392be5cc334b24791e7a3d3eaeb482f | |
parent | 7903295f2abfd7e19c3902e427882065d300f08a (diff) | |
parent | ccd83bf1ff61370ffb24edb3f31f1894dea8c160 (diff) |
Merge branch 'hotfix/issue1314'v3.0.1
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | docs/man/glances.1 | 2 | ||||
-rw-r--r-- | glances/__init__.py | 2 | ||||
-rw-r--r-- | glances/amps/glances_default.py | 2 | ||||
-rw-r--r-- | glances/amps_list.py | 44 |
5 files changed, 43 insertions, 14 deletions
@@ -2,6 +2,13 @@ Glances Version 3 ============================================================================== +Version 3.0.1 +============= + +Bug corrected: + + * AMPs error if no output are provided by the system call #1314 + Version 3.0 =========== diff --git a/docs/man/glances.1 b/docs/man/glances.1 index 631b8979..00bd1552 100644 --- a/docs/man/glances.1 +++ b/docs/man/glances.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLANCES" "1" "Sep 01, 2018" "3.0" "Glances" +.TH "GLANCES" "1" "Sep 04, 2018" "3.0.1" "Glances" .SH NAME glances \- An eye on your system . diff --git a/glances/__init__.py b/glances/__init__.py index d327e14b..e5e62a94 100644 --- a/glances/__init__.py +++ b/glances/__init__.py @@ -27,7 +27,7 @@ import signal import sys # Global name -__version__ = '3.0' +__version__ = '3.0.1' __author__ = 'Nicolas Hennion <nicolas@nicolargo.com>' __license__ = 'LGPLv3' diff --git a/glances/amps/glances_default.py b/glances/amps/glances_default.py index ea3e9879..5466f6fb 100644 --- a/glances/amps/glances_default.py +++ b/glances/amps/glances_default.py @@ -59,7 +59,7 @@ class Amp(GlancesAmp): def update(self, process_list): """Update the AMP""" # Get the systemctl status - logger.debug('{}: Update stats using service {}'.format(self.NAME, self.get('service_cmd'))) + logger.debug('{}: Update AMP stats using service {}'.format(self.NAME, self.get('service_cmd'))) try: res = self.get('command') except OSError as e: diff --git a/glances/amps_list.py b/glances/amps_list.py index 8fc63ac5..56d9b2d5 100644 --- a/glances/amps_list.py +++ b/glances/amps_list.py @@ -104,22 +104,17 @@ class AmpsList(object): def update(self): """Update the command result attributed.""" - # Search application monitored processes by a regular expression + # Get the current processes list (once) processlist = glances_processes.getlist() + # 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: - # Search in both cmdline and name (for kernel thread, see #1261) - amps_list = [p['pid'] for p in processlist - for c in p['cmdline'] - if ((re.search(v.regex(), c) is not None) or - (re.search(v.regex(), p['name']) is not None))] - amps_list = list(set(amps_list)) - except (TypeError, KeyError): - continue + + amps_list = self._build_amps_list(v, processlist) + if len(amps_list) > 0: # At least one process is matching the regex logger.debug("AMPS: {} processes {} detected ({})".format(len(amps_list), @@ -132,11 +127,38 @@ class AmpsList(object): # Set the process number to 0 v.set_count(0) if v.count_min() is not None and v.count_min() > 0: - # Only display the "No running process message" is countmin is defined + # Only display the "No running process message" if countmin is defined v.set_result("No running process") return self.__amps_dict + def _build_amps_list(self, amp_value, processlist): + """Return the AMPS process list according to the amp_value + + Search application monitored processes by a regular expression + """ + ret = [] + try: + # Search in both cmdline and name (for kernel thread, see #1261) + for p in processlist: + add_it = False + if (re.search(amp_value.regex(), p['name']) is not None): + add_it = True + else: + for c in p['cmdline']: + if (re.search(amp_value.regex(), c) is not None): + add_it = True + break + if add_it: + ret.append({'pid': p['pid'], + 'cpu_percent': p['cpu_percent'], + 'memory_percent': p['memory_percent']}) + + except (TypeError, KeyError) as e: + logger.debug("Can not build AMPS list ({})".format(e)) + + return ret + def getList(self): """Return the AMPs list.""" return listkeys(self.__amps_dict) |