diff --git a/NEWS b/NEWS index 30bc9cf58fe4ad7d05ce08e7f7b37fe726fb04f4..36935cb82630cc13ef7d70050524d26490a3f1a4 100644 --- a/NEWS +++ b/NEWS @@ -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 631b8979a843827cb32dbace5d1bab45ef59f968..00bd1552aa6bcec4b7e1af021ded2f74ac7cfa3c 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 d327e14bcbfa1763725bf3da7c67bf99617bfded..e5e62a945fc5a246bea79d768e7916aa8923c013 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 ' __license__ = 'LGPLv3' diff --git a/glances/amps/glances_default.py b/glances/amps/glances_default.py index ea3e9879cef99818c8efc7e8045c81ade084ed45..5466f6fb3177ee58db9e51a1d8a01374502a76e6 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 8fc63ac57ed141f0ea9d0ce55fd52b2e630fb3c6..56d9b2d5ffcd52bbaa33854cc6b054dbe950d7f7 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)