refactor: AMPs cleanup

This commit is contained in:
RazCrimson 2021-11-28 16:30:54 +05:30
parent 1bbba2043c
commit 1c9ae9a86e
4 changed files with 15 additions and 13 deletions

View File

@ -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)

View File

@ -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(';'):

View File

@ -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 doesnt 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.

View File

@ -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
---------------------