diff options
Diffstat (limited to 'glances')
94 files changed, 44766 insertions, 1352 deletions
diff --git a/glances/README.txt b/glances/README.txt index b512e62b..bbf94ebf 100644 --- a/glances/README.txt +++ b/glances/README.txt @@ -7,32 +7,44 @@ https://github.com/nicolargo/glances/blob/master/docs/glances-doc.rst __init__.py Global module init __main__.py Entry point for Glances module -core/ - => Glances core folder - glances_config.py Manage configuration file - glances_globals.py Share variables upon modules - glances_limits.py Manage limits - glances_logs.py Manage logs - glances_main.py Main script to rule them up... - glances_client.py Glances client - glances_server.py Glances server - glances_standalone.py Glances standalone (with curse interface) - glances_stats.py The stats manager - glances_timer.py Manage timer - ... -plugins/ +config.py Manage the configuration file +compat.py Python2/3 compatibility shims module +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) +autodiscover.py Glances autodiscover module (via zeroconf) +standalone.py Glances standalone (curses interface) +password.py Manage password for Glances client/server +stats.py The stats manager +timer.py The timer class +actions.py Manage trigger actions (via mustache) +snmp.py Glances SNMP client (via pysnmp) +... +plugins => Glances data providers glances_plugins.py "Father class" for others plugins glances_cpu.py Manage CPU stats - glances_load.py Manage LOAD stats - glances_mem.py Manage MEM (both RAM and SWAP) stats + glances_load.py Manage load stats + glances_mem.py Manage RAM stats + glances_memswap.py Manage swap stats + glances_network.py Manage network stats + glances_fs.py Manage file system stats + glances_diskio.py Manage disk I/O stats + glances_docker.py Glances Docker plugin (via docker-py) + glances_raid.py Glances RAID plugin (via pymdstat) ... -outputs/ +outputs => Glances UI - glances_curse.py The Curse interface - glances_html.py The HTML interface + glances_curses.py The curses interface + glances_bottle.py The web interface ... -exports/ +exports => Glances export interfaces glances_csv.py The CSV export module + glances_influxdb.py The InfluxDB export module + glances_opentsdb.py The OpenTSDB export module + glances_rabbitmq.py The RabbitMQ export module + glances_statsd.py The StatsD export module ... diff --git a/glances/__init__.py b/glances/__init__.py index 96467d73..c937e820 100644 --- a/glances/__init__.py +++ b/glances/__init__.py @@ -16,20 +16,21 @@ # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +# """Init the Glances software.""" -__appname__ = 'glances' -__version__ = '2.5.1' -__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>' -__license__ = 'LGPL' - -# Import system lib import locale import platform import signal import sys +# Global name +__appname__ = 'glances' +__version__ = '2.6' +__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>' +__license__ = 'LGPL' + # Import psutil try: from psutil import __version__ as __psutil_version @@ -39,8 +40,8 @@ except ImportError: # Import Glances libs # Note: others Glances libs will be imported optionally -from glances.core.glances_logging import logger -from glances.core.glances_main import GlancesMain +from glances.logger import logger +from glances.main import GlancesMain try: locale.setlocale(locale.LC_ALL, '') @@ -52,6 +53,13 @@ if sys.version_info < (2, 6) or (3, 0) <= sys.version_info < (3, 3): print('Glances requires at least Python 2.6 or 3.3 to run.') sys.exit(1) +if sys.version_info[:2] == (2, 6): + import warnings + warnings.warn('Python 2.6 support will be dropped. Please switch ' + 'to at least Python 2.7 or 3.3+ as soon as possible. ' + 'See http://www.snarky.ca/stop-using-python-2-6 ' + 'for more information.') + # Check PSutil version psutil_min_version = (2, 0, 0) psutil_version = tuple([int(num) for num in __psutil_version.split('.')]) @@ -115,7 +123,7 @@ def main(): logger.info("Start standalone mode") # Import the Glances standalone module - from glances.core.glances_standalone import GlancesStandalone + from glances.standalone import GlancesStandalone # Init the standalone mode standalone = GlancesStandalone(config=core.get_config(), @@ -129,7 +137,7 @@ def main(): logger.info("Start client mode (browser)") # Import the Glances client browser module - from glances.core.glances_client_browser import GlancesClientBrowser + from glances.client_browser import GlancesClientBrowser # Init the client client = GlancesClientBrowser(config=core.get_config(), @@ -139,7 +147,7 @@ def main(): logger.info("Start client mode") # Import the Glances client module - from glances.core.glances_client import GlancesClient + from glances.client import GlancesClient # Init the client client = GlancesClient(config=core.get_config(), @@ -160,7 +168,7 @@ def main(): logger.info("Start server mode") # Import the Glances server module - from glances.core.glances_server import GlancesServer + from glances.server import GlancesServer args = core.get_args() @@ -183,7 +191,7 @@ def main(): logger.info("Start web server mode") # Import the Glances web server module - from glances.core.glances_webserver import GlancesWebServer + from glances.webserver import GlancesWebServer # Init the web server mode webserver = GlancesWebServer(config=core.get_config(), diff --git a/glances/__main__.py b/glances/__main__.py index 871dea89..0568476d 100644 --- a/glances/__main__.py +++ b/glances/__main__.py @@ -30,9 +30,9 @@ if __package__ is None and not hasattr(sys, "frozen"): # It is a direct call to __main__.py import os.path path = os.path.realpath(os.path.abspath(__file__)) - sys.path.append(os.path.dirname(os.path.dirname(path))) + sys.path.insert(0, os.path.dirname(os.path.dirname(path))) -import glances +import glances # noqa if __name__ == '__main__': glances.main() diff --git a/glances/core/glances_actions.py b/glances/actions.py index dabcd1ba..4fea8d61 100644 --- a/glances/core/glances_actions.py +++ b/glances/actions.py @@ -19,11 +19,10 @@ """Manage on alert actions.""" -# Import system lib from subprocess import Popen -# Import Glances lib -from glances.core.glances_logging import logger +from glances.logger import logger +from glances.timer import Timer try: import pystache @@ -38,7 +37,7 @@ class GlancesActions(object): """This class manage action if an alert is reached.""" - def __init__(self): + def __init__(self, args=None): """Init GlancesActions class.""" # Dict with the criticity status # - key: stat_name @@ -46,6 +45,13 @@ class GlancesActions(object): # Goal: avoid to execute the same command twice self.status = {} + # Add a timer to avoid any trigger when Glances is started (issue#732) + # Action can be triggered after refresh * 2 seconds + if hasattr(args, 'time'): + self.start_timer = Timer(args.time * 2) + else: + self.start_timer = Timer(3) + def get(self, stat_name): """Get the stat_name criticity.""" try: @@ -67,7 +73,7 @@ class GlancesActions(object): Return True if the commands have been ran. """ - if self.get(stat_name) == criticity: + if self.get(stat_name) == criticity or not self.start_timer.finished(): # Action already executed => Exit return False diff --git a/glances/core/glances_autodiscover.py b/glances/autodiscover.py index 244aa713..fa1414d4 100644 --- a/glances/core/glances_autodiscover.py +++ b/glances/autodiscover.py @@ -19,10 +19,12 @@ """Manage autodiscover Glances server (thk to the ZeroConf protocol).""" -# Import system libs import socket import sys +from glances.globals import appname, BSD +from glances.logger import logger + try: from zeroconf import ( __version__ as __zeroconf_version, @@ -34,10 +36,6 @@ try: except ImportError: zeroconf_tag = False -# Import Glances libs -from glances.core.glances_globals import appname, is_freebsd -from glances.core.glances_logging import logger - # Zeroconf 0.17 or higher is needed if zeroconf_tag: zeroconf_min_version = (0, 17, 0) @@ -194,9 +192,9 @@ class GlancesAutoDiscoverClient(object): |