diff options
Diffstat (limited to 'glances')
101 files changed, 8552 insertions, 8263 deletions
diff --git a/glances/README.txt b/glances/README.txt index c5fd13eb..3e6de7eb 100644 --- a/glances/README.txt +++ b/glances/README.txt @@ -12,7 +12,7 @@ globals.py Share variables upon modules main.py Main script to rule them up... client.py Glances client server.py Glances server -webserver.py Glances web server (Bottle-based) +webserver.py Glances web server (Based on FastAPI) autodiscover.py Glances autodiscover module (via zeroconf) standalone.py Glances standalone (curses interface) password.py Manage password for Glances client/server @@ -27,7 +27,7 @@ plugins outputs => Glances UI glances_curses.py The curses interface - glances_bottle.py The web interface + glances_restful-api.py The HTTP/API & Web based interface ... exports => Glances exports diff --git a/glances/__init__.py b/glances/__init__.py index 9ae141aa..23bbd18c 100644 --- a/glances/__init__.py +++ b/glances/__init__.py @@ -21,6 +21,7 @@ import sys # Version should start and end with a numerical char # See https://packaging.python.org/specifications/core-metadata/#version __version__ = '4.0.0_beta01' +__apiversion__ = '4' __author__ = 'Nicolas Hennion <nicolas@nicolargo.com>' __license__ = 'LGPLv3' @@ -108,7 +109,7 @@ def start(config, args): # Start the main loop logger.debug("Glances started in {} seconds".format(start_duration.get())) if args.stop_after: - logger.info('Glances will be stopped in ~{} seconds'.format(args.stop_after * args.time * args.memory_leak * 2)) + logger.info('Glances will be stopped in ~{} seconds'.format(args.stop_after * args.time)) if args.memory_leak: print( diff --git a/glances/amps/glances_amp.py b/glances/amps/amp.py index 078e08a9..41881ea8 100644 --- a/glances/amps/glances_amp.py +++ b/glances/amps/amp.py @@ -42,7 +42,7 @@ class GlancesAmp(object): # AMP name (= module name without glances_) if name is None: - self.amp_name = self.__class__.__module__[len('glances_') :] + self.amp_name = self.__class__.__module__ else: self.amp_name = name diff --git a/glances/amps/glances_default.py b/glances/amps/default/__init__.py index dac41b38..886f0c8a 100644 --- a/glances/amps/glances_default.py +++ b/glances/amps/default/__init__.py @@ -29,7 +29,7 @@ from subprocess import check_output, STDOUT, CalledProcessError from glances.globals import u, to_ascii from glances.logger import logger -from glances.amps.glances_amp import GlancesAmp +from glances.amps.amp import GlancesAmp class Amp(GlancesAmp): diff --git a/glances/amps/glances_nginx.py b/glances/amps/nginx/__init__.py index 04ff5236..770c4aca 100644 --- a/glances/amps/glances_nginx.py +++ b/glances/amps/nginx/__init__.py @@ -47,7 +47,7 @@ status_url=http://localhost/nginx_status import requests from glances.logger import logger -from glances.amps.glances_amp import GlancesAmp +from glances.amps.amp import GlancesAmp class Amp(GlancesAmp): diff --git a/glances/amps/glances_systemd.py b/glances/amps/systemd/__init__.py index 736666a5..3df7a8ae 100644 --- a/glances/amps/glances_systemd.py +++ b/glances/amps/systemd/__init__.py @@ -39,7 +39,7 @@ from subprocess import check_output, CalledProcessError from glances.logger import logger from glances.globals import iteritems, to_ascii -from glances.amps.glances_amp import GlancesAmp +from glances.amps.amp import GlancesAmp class Amp(GlancesAmp): diff --git a/glances/amps/glances_systemv.py b/glances/amps/systemv/__init__.py index afd8abe0..78df6795 100644 --- a/glances/amps/glances_systemv.py +++ b/glances/amps/systemv/__init__.py @@ -38,7 +38,7 @@ from subprocess import check_output, STDOUT from glances.logger import logger from glances.globals import iteritems -from glances.amps.glances_amp import GlancesAmp +from glances.amps.amp import GlancesAmp class Amp(GlancesAmp): diff --git a/glances/amps_list.py b/glances/amps_list.py index c3c63627..41f82c37 100644 --- a/glances/amps_list.py +++ b/glances/amps_list.py @@ -45,41 +45,30 @@ class AmpsList(object): if self.config is None: return False - # Display a warning (deprecated) message if the monitor section exist - if "monitor" in self.config.sections(): - logger.warning( - "A deprecated [monitor] section exists in the Glances configuration file. You should use the new \ - Applications Monitoring Process module instead \ - (http://glances.readthedocs.io/en/develop/aoa/amps.html)." - ) - - # TODO: Change the way AMP are loaded (use folder/module instead of glances_foo.py file) - # See https://github.com/nicolargo/glances/issues/1930 - header = "glances_" # For each AMP script, call the load_config method for s in self.config.sections(): if s.startswith("amp_"): # An AMP section exists in the configuration file - # If an AMP script exist in the glances/amps folder, use it - amp_conf_name = s[4:] - amp_script = os.path.join(amps_path, header + s[4:] + ".py") - if not os.path.exists(amp_script): + # If an AMP module exist in amps_path (glances/amps) folder then use it + amp_name = s[4:] + amp_module = os.path.join(amps_path, amp_name) + if not os.path.exists(amp_module): # If not, use the default script - amp_script = os.path.join(amps_path, "glances_default.py") + amp_module = os.path.join(amps_path, "default") try: - amp = __import__(os.path.basename(amp_script)[:-3]) + amp = __import__(os.path.basename(amp_module)) except ImportError as e: - logger.warning("Missing Python Lib ({}), cannot load {} AMP".format(e, amp_conf_name)) + logger.warning("Missing Python Lib ({}), cannot load AMP {}".format(e, amp_name)) except Exception as e: - logger.warning("Cannot load {} AMP ({})".format(amp_conf_name, e)) + logger.warning("Cannot load AMP {} ({})".format(amp_name, e)) else: # Add the AMP to the dictionary # The key is the AMP name # for example, the file glances_xxx.py # generate self._amps_list["xxx"] = ... - self.__amps_dict[amp_conf_name] = amp.Amp(name=amp_conf_name, args=self.args) + self.__amps_dict[amp_name] = amp.Amp(name=amp_name, args=self.args) # Load the AMP configuration - self.__amps_dict[amp_conf_name].load_config(self.config) + self.__amps_dict[amp_name].load_config(self.config) # Log AMPs list logger.debug("AMPs list: {}".format(self.getList())) diff --git a/glances/events.py b/glances/events.py index b1a9ba3b..2dbc5100 100644 --- a/glances/events.py +++ b/glances/events.py @@ -105,14 +105,14 @@ class GlancesEvents(object): event_index = self.__event_exist(event_type) if event_index < 0: # Event did not exist, add it - self._create_event(event_state, event_type, event_value, proc_list, proc_desc, peak_time) + self._create_event(event_state, event_type, event_value, proc_desc) else: # Event exist, update it self._update_event(event_index, event_state, event_type, event_value, proc_list, proc_desc, peak_time) return self.len() - def _create_event(self, event_state, event_type, event_value, proc_list, proc_desc, peak_time): + def _create_event(self, event_state, event_type, event_value, proc_desc): """Add a new item in the log list. Item is added only if the criticality (event_state) is WARNING or CRITICAL. diff --git a/glances/exports/couchdb/__init__.py b/glances/exports/couchdb/__init__.py index 7f3a216a..5cc65529 100644 --- a/glances/exports/couchdb/__init__.py +++ b/glances/exports/couchdb/__init__.py @@ -36,9 +36,7 @@ class Export(GlancesExport): # Load the CouchDB configuration file section # User and Password are mandatory with CouchDB 3.0 and higher - self.export_enable = self.load_conf('couchdb', - mandatories=['host', 'port', 'db', - 'user', 'password']) + self.export_enable = self.load_conf('couchdb', mandatories=['host', 'port', 'db', 'user', 'password']) if not self.export_enable: sys.exit(2) @@ -51,8 +49,7 @@ class Export(GlancesExport): return None # @TODO: https - server_uri = 'http://{}:{}@{}:{}/'.format(self.user, self.password, - self.host, self.port) + server_uri = 'http://{}:{}@{}:{}/'.format(self.user, self.password, self.host, self.port) try: s = pycouchdb.Server(server_uri) diff --git a/glances/exports/export.py b/glances/exports/export.py index b4db4790..45a08c77 100644 --- a/glances/exports/export.py +++ b/glances/exports/export.py @@ -36,12 +36,13 @@ class GlancesExport(object): 'processlist', 'psutilversion', 'quicklook', + 'version', ] def __init__(self, config=None, args=None): """Init the export class.""" # Export name (= module name without glances_) - self.export_name = self.__class__.__module__[len('glances_') :] + self.export_name = self.__class__.__module__ logger.debug("Init export module %s" % self.export_name) # Init the config & args @@ -115,7 +116,7 @@ class GlancesExport(object): def parse_tags(self, tags): """Parse tags into a dict. - :param tags: a comma separated list of 'key:value' pairs. Example: foo:bar,spam:eggs + :param tags: a comma-separated list of 'key:value' pairs. Example: foo:bar,spam:eggs :return: a dict of tags. Example: {'foo': 'bar', 'spam': 'eggs'} """ |