From 1c9ae9a86ec550fc5614e86ccb8099bdb81d81a6 Mon Sep 17 00:00:00 2001 From: RazCrimson <52282402+RazCrimson@users.noreply.github.com> Date: Sun, 28 Nov 2021 16:30:54 +0530 Subject: [PATCH] refactor: AMPs cleanup --- glances/amps/glances_amp.py | 18 ++++++++++-------- glances/amps/glances_default.py | 4 ++-- glances/amps/glances_nginx.py | 4 ++-- glances/amps/glances_systemv.py | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/glances/amps/glances_amp.py b/glances/amps/glances_amp.py index ccbee541..040940c7 100644 --- a/glances/amps/glances_amp.py +++ b/glances/amps/glances_amp.py @@ -47,7 +47,7 @@ class GlancesAmp(object): EMAIL = '?' def __init__(self, name=None, args=None): - """Init AMP classe.""" + """Init AMP class.""" logger.debug("AMP - Init {} version {}".format(self.NAME, self.VERSION)) # AMP name (= module name without glances_) @@ -69,7 +69,7 @@ class GlancesAmp(object): def load_config(self, config): """Load AMP parameters from the configuration file.""" - # Read AMP confifuration. + # Read AMP configuration. # For ex, the AMP foo should have the following section: # # [foo] @@ -77,12 +77,11 @@ class GlancesAmp(object): # regex=\/usr\/bin\/nginx # refresh=60 # - # and optionnaly: + # and optionally: # # one_line=false # option1=opt1 - # ... - # + amp_section = 'amp_' + self.amp_name if (hasattr(config, 'has_section') and config.has_section(amp_section)): @@ -137,7 +136,7 @@ class GlancesAmp(object): return self.get('refresh') def one_line(self): - """Return True|False if the AMP shoukd be displayed in oneline (one_lineline=true|false).""" + """Return True|False if the AMP should be displayed in one line (one_line=true|false).""" ret = self.get('one_line') if ret is None: return False @@ -149,7 +148,9 @@ class GlancesAmp(object): return self.timer.get() def should_update(self): - """Return True is the AMP should be updated: + """Return True is the AMP should be updated + + Conditions for update: - AMP is enable - only update every 'refresh' seconds """ @@ -177,7 +178,8 @@ class GlancesAmp(object): def set_result(self, result, separator=''): """Store the result (string) into the result key of the AMP - if one_line is true then replace \n by separator + + If one_line is true then it replaces `\n` by the separator """ if self.one_line(): self.configs['result'] = u(result).replace('\n', separator) diff --git a/glances/amps/glances_default.py b/glances/amps/glances_default.py index d942939a..8f4b4bb2 100644 --- a/glances/amps/glances_default.py +++ b/glances/amps/glances_default.py @@ -21,7 +21,7 @@ r""" Default AMP ========= -Monitor a process by executing a command line. This is the default AMP's behavor +Monitor a process by executing a command line. This is the default AMP's behavior if no AMP script is found. Configuration file example @@ -75,7 +75,7 @@ class Amp(GlancesAmp): sum([p['memory_percent'] for p in process_list]))) return self.result() # Run command(s) - # Comman separated commands can be executed + # Comma separated commands can be executed try: msg = '' for cmd in res.split(';'): diff --git a/glances/amps/glances_nginx.py b/glances/amps/glances_nginx.py index 6cc5fb3b..6911cd12 100644 --- a/glances/amps/glances_nginx.py +++ b/glances/amps/glances_nginx.py @@ -26,8 +26,8 @@ Monitor the Nginx process using the status page. How to read the stats --------------------- -Active connections – Number of all open connections. This doesn’t mean number of users. -A single user, for a single pageview can open many concurrent connections to your server. +Active connections – Number of all open connections. This doesn't mean number of users. +A single user, for a single page-view can open many concurrent connections to your server. Server accepts handled requests – This shows three values. First is total accepted connections. Second is total handled connections. Usually first 2 values are same. diff --git a/glances/amps/glances_systemv.py b/glances/amps/glances_systemv.py index c28a4fde..abd3a2da 100644 --- a/glances/amps/glances_systemv.py +++ b/glances/amps/glances_systemv.py @@ -21,7 +21,7 @@ r""" SystemV AMP =========== -Monitor the state of the Syste V init system and service. +Monitor the state of the System V init system and service. How to read the stats ---------------------