summaryrefslogtreecommitdiffstats
path: root/glances
diff options
context:
space:
mode:
Diffstat (limited to 'glances')
-rw-r--r--glances/README.txt8
-rw-r--r--glances/__init__.py35
-rw-r--r--glances/core/glances_actions.py23
-rw-r--r--glances/core/glances_autodiscover.py81
-rw-r--r--glances/core/glances_client.py98
-rw-r--r--glances/core/glances_client_browser.py94
-rw-r--r--glances/core/glances_config.py224
-rw-r--r--glances/core/glances_cpu_percent.py49
-rw-r--r--glances/core/glances_globals.py12
-rw-r--r--glances/core/glances_logging.py30
-rw-r--r--glances/core/glances_logs.py66
-rw-r--r--glances/core/glances_main.py120
-rw-r--r--glances/core/glances_monitor_list.py36
-rw-r--r--glances/core/glances_password.py8
-rw-r--r--glances/core/glances_processes.py620
-rw-r--r--glances/core/glances_server.py2
-rw-r--r--glances/core/glances_snmp.py2
-rw-r--r--glances/core/glances_standalone.py62
-rw-r--r--glances/core/glances_staticlist.py13
-rw-r--r--glances/core/glances_stats.py45
-rw-r--r--glances/core/glances_webserver.py2
-rw-r--r--glances/exports/glances_csv.py19
-rw-r--r--glances/exports/glances_export.py45
-rw-r--r--glances/exports/glances_history.py31
-rw-r--r--glances/exports/glances_influxdb.py86
-rw-r--r--glances/exports/glances_rabbitmq.py112
-rw-r--r--glances/exports/glances_statsd.py24
-rw-r--r--glances/outputs/bottle/base.tpl61
-rw-r--r--glances/outputs/bottle/plugin_table.tpl22
-rw-r--r--glances/outputs/bottle/plugin_text.tpl11
-rw-r--r--glances/outputs/glances_bars.py72
-rw-r--r--glances/outputs/glances_bottle.py160
-rw-r--r--glances/outputs/glances_colorconsole.py12
-rw-r--r--glances/outputs/glances_curses.py358
-rw-r--r--glances/outputs/static/css/style.css141
-rw-r--r--glances/outputs/static/html/components/monitor_process.html4
-rw-r--r--glances/outputs/static/html/help.html63
-rw-r--r--glances/outputs/static/html/index.html28
-rw-r--r--glances/outputs/static/html/plugins/alert.html7
-rw-r--r--glances/outputs/static/html/plugins/alerts.html2
-rw-r--r--glances/outputs/static/html/plugins/cpu.html44
-rw-r--r--glances/outputs/static/html/plugins/cpu_more.html26
-rw-r--r--glances/outputs/static/html/plugins/diskio.html10
-rw-r--r--glances/outputs/static/html/plugins/docker.html20
-rw-r--r--glances/outputs/static/html/plugins/fs.html12
-rw-r--r--glances/outputs/static/html/plugins/ip.html1
-rw-r--r--glances/outputs/static/html/plugins/load.html24
-rw-r--r--glances/outputs/static/html/plugins/mem.html20
-rw-r--r--glances/outputs/static/html/plugins/mem_more.html18
-rw-r--r--glances/outputs/static/html/plugins/memswap.html20
-rw-r--r--glances/outputs/static/html/plugins/monitor.html3
-rw-r--r--glances/outputs/static/html/plugins/network.html12
-rw-r--r--glances/outputs/static/html/plugins/processcount.html6
-rw-r--r--glances/outputs/static/html/plugins/processlist.html33
-rw-r--r--glances/outputs/static/html/plugins/sensors.html13
-rw-r--r--glances/outputs/static/html/plugins/system.html3
-rw-r--r--glances/outputs/static/html/plugins/uptime.html1
-rw-r--r--glances/outputs/static/html/stats.html64
-rw-r--r--glances/outputs/static/images/glances.pngbin0 -> 43588 bytes
-rw-r--r--glances/outputs/static/js/app.js13
-rw-r--r--glances/outputs/static/js/directives.js78
-rw-r--r--glances/outputs/static/js/filters.js86
-rwxr-xr-xglances/outputs/static/js/modernizr.custom.js4
-rw-r--r--glances/outputs/static/js/stats_controller.js294
-rw-r--r--glances/outputs/static/js/variables.js30
-rw-r--r--glances/outputs/static/js/vendors/angular-route.min.js15
-rw-r--r--glances/outputs/static/js/vendors/angular-route.min.js.map8
-rw-r--r--glances/outputs/static/js/vendors/angular.min.js218
-rw-r--r--glances/outputs/static/js/vendors/angular.min.js.map8
-rw-r--r--glances/outputs/static/js/vendors/lodash.min.js137
-rw-r--r--glances/plugins/glances_alert.py28
-rw-r--r--glances/plugins/glances_batpercent.py17
-rw-r--r--glances/plugins/glances_core.py10
-rw-r--r--glances/plugins/glances_cpu.py51
-rw-r--r--glances/plugins/glances_diskio.py40
-rw-r--r--glances/plugins/glances_docker.py236
-rw-r--r--glances/plugins/glances_fs.py96
-rw-r--r--glances/plugins/glances_hddtemp.py19
-rw-r--r--glances/plugins/glances_help.py162
-rw-r--r--glances/plugins/glances_ip.py123
-rw-r--r--glances/plugins/glances_load.py26
-rw-r--r--glances/plugins/glances_mem.py38
-rw-r--r--glances/plugins/glances_memswap.py37
-rw-r--r--glances/plugins/glances_monitor.py10
-rw-r--r--glances/plugins/glances_network.py108
-rw-r--r--glances/plugins/glances_now.py4
-rw-r--r--glances/plugins/glances_percpu.py26
-rw-r--r--glances/plugins/glances_plugin.py239
-rw-r--r--glances/plugins/glances_processcount.py38
-rw-r--r--glances/plugins/glances_processlist.py139
-rw-r--r--glances/plugins/glances_psutilversion.py6
-rw-r--r--glances/plugins/glances_quicklook.py107
-rw-r--r--glances/plugins/glances_raid.py21
-rw-r--r--glances/plugins/glances_sensors.py81
-rw-r--r--glances/plugins/glances_system.py82
-rw-r--r--glances/plugins/glances_uptime.py28
96 files changed, 4046 insertions, 1835 deletions
diff --git a/glances/README.txt b/glances/README.txt
index fe29ae0e..b512e62b 100644
--- a/glances/README.txt
+++ b/glances/README.txt
@@ -1,6 +1,7 @@
-You are in the main Glances's source folder. This page is **ONLY** for developpers purposes.
+You are in the main Glances source folder. This page is **ONLY** for developers.
-If you are looking for the user manual, please follow this link: https://github.com/nicolargo/glances/blob/master/docs/glances-doc.rst
+If you are looking for the user manual, please follow this link:
+https://github.com/nicolargo/glances/blob/master/docs/glances-doc.rst
===
@@ -9,11 +10,10 @@ __main__.py Entry point for Glances module
core/
=> Glances core folder
glances_config.py Manage configuration file
- glances_globals.py Share variables uppon modules
+ 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_stats.py Inteface to grab stats
glances_client.py Glances client
glances_server.py Glances server
glances_standalone.py Glances standalone (with curse interface)
diff --git a/glances/__init__.py b/glances/__init__.py
index 30636edb..68a8803f 100644
--- a/glances/__init__.py
+++ b/glances/__init__.py
@@ -20,12 +20,11 @@
"""Init the Glances software."""
__appname__ = 'glances'
-__version__ = '2.3'
+__version__ = '2.4'
__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>'
__license__ = 'LGPL'
# Import system lib
-import gettext
import locale
import platform
import signal
@@ -40,23 +39,24 @@ except ImportError:
# Import Glances libs
# Note: others Glances libs will be imported optionally
-from glances.core.glances_globals import gettext_domain, locale_dir
from glances.core.glances_logging import logger
from glances.core.glances_main import GlancesMain
-# Get PSutil version
-psutil_min_version = (2, 0, 0)
-psutil_version = tuple([int(num) for num in __psutil_version.split('.')])
+try:
+ locale.setlocale(locale.LC_ALL, '')
+except locale.Error:
+ print("Warning: Unable to set locale. Expect encoding problems.")
-# First log with Glances and PSUtil version
-logger.info('Start Glances {0}'.format(__version__))
-logger.info('{0} {1} and PSutil {2} detected'.format(platform.python_implementation(),
- platform.python_version(),
- __psutil_version))
+# Check Python version
+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)
# Check PSutil version
+psutil_min_version = (2, 0, 0)
+psutil_version = tuple([int(num) for num in __psutil_version.split('.')])
if psutil_version < psutil_min_version:
- logger.critical('PSutil 2.0 or higher is needed. Glances cannot start.')
+ print('PSutil 2.0 or higher is needed. Glances cannot start.')
sys.exit(1)
@@ -94,9 +94,12 @@ def main():
Select the mode (standalone, client or server)
Run it...
"""
- # Setup translations
- locale.setlocale(locale.LC_ALL, '')
- gettext.install(gettext_domain, locale_dir)
+ # Log Glances and PSutil version
+ logger.info('Start Glances {0}'.format(__version__))
+ logger.info('{0} {1} and PSutil {2} detected'.format(
+ platform.python_implementation(),
+ platform.python_version(),
+ __psutil_version))
# Share global var
global core, standalone, client, server, webserver
@@ -164,7 +167,7 @@ def main():
server = GlancesServer(cached_time=core.cached_time,
config=core.get_config(),
args=args)
- print(_("Glances server is running on {0}:{1}").format(args.bind_address, args.port))
+ print('Glances server is running on {0}:{1}'.format(args.bind_address, args.port))
# Set the server login/password (if -P/--password tag)
if args.password != "":
diff --git a/glances/core/glances_actions.py b/glances/core/glances_actions.py
index 1a762b70..dabcd1ba 100644
--- a/glances/core/glances_actions.py
+++ b/glances/core/glances_actions.py
@@ -19,11 +19,12 @@
"""Manage on alert actions."""
+# Import system lib
+from subprocess import Popen
+
# Import Glances lib
from glances.core.glances_logging import logger
-# Import system lib
-from subprocess import Popen
try:
import pystache
except ImportError:
@@ -35,11 +36,10 @@ else:
class GlancesActions(object):
- """This class manage action if an alert is reached"""
+ """This class manage action if an alert is reached."""
def __init__(self):
- """Init GlancesActions class"""
-
+ """Init GlancesActions class."""
# Dict with the criticity status
# - key: stat_name
# - value: criticity
@@ -47,25 +47,26 @@ class GlancesActions(object):
self.status = {}
def get(self, stat_name):
- """Get the stat_name criticity"""
+ """Get the stat_name criticity."""
try:
return self.status[stat_name]
except KeyError:
return None
def set(self, stat_name, criticity):
- """Set the stat_name to criticity"""
+ """Set the stat_name to criticity."""
self.status[stat_name] = criticity
def run(self, stat_name, criticity, commands, mustache_dict=None):
- """Run the commands (in background)
+ """Run the commands (in background).
+
- stats_name: plugin_name (+ header)
- criticity: criticity of the trigger
- commands: a list of command line with optional {{mustache}}
- mustache_dict: Plugin stats (can be use within {{mustache}})
- Return True if the commands have been ran"""
-
+ Return True if the commands have been ran.
+ """
if self.get(stat_name) == criticity:
# Action already executed => Exit
return False
@@ -75,7 +76,7 @@ class GlancesActions(object):
criticity,
mustache_dict))
- # Ran all actions in background
+ # Run all actions in background
for cmd in commands:
# Replace {{arg}} by the dict one (Thk to {Mustache})
if pystache_tag:
diff --git a/glances/core/glances_autodiscover.py b/glances/core/glances_autodiscover.py
index f9659f08..3648e35f 100644
--- a/glances/core/glances_autodiscover.py
+++ b/glances/core/glances_autodiscover.py
@@ -22,11 +22,7 @@
# Import system libs
import socket
import sys
-try:
- import netifaces
- netifaces_tag = True
-except ImportError:
- netifaces_tag = False
+
try:
from zeroconf import (
__version__ as __zeroconf_version,
@@ -42,13 +38,13 @@ except ImportError:
from glances.core.glances_globals import appname
from glances.core.glances_logging import logger
-# Zeroconf 0.16 or higher is needed
+# Zeroconf 0.17 or higher is needed
if zeroconf_tag:
- zeroconf_min_version = (0, 16, 0)
+ zeroconf_min_version = (0, 17, 0)
zeroconf_version = tuple([int(num) for num in __zeroconf_version.split('.')])
logger.debug("Zeroconf version {0} detected.".format(__zeroconf_version))
if zeroconf_version < zeroconf_min_version:
- logger.critical("Please install zeroconf 0.16 or higher.")
+ logger.critical("Please install zeroconf 0.17 or higher.")
sys.exit(1)
# Global var
@@ -57,7 +53,7 @@ zeroconf_type = "_%s._tcp." % appname
class AutoDiscovered(object):
- """Class to manage the auto discovered servers dict"""
+ """Class to manage the auto discovered servers dict."""
def __init__(self):
# server_dict is a list of dict (JSON compliant)
@@ -65,30 +61,30 @@ class AutoDiscovered(object):
self._server_list = []
def get_servers_list(self):
- """Return the current server list (list of dict)"""
+ """Return the current server list (list of dict)."""
return self._server_list
def set_server(self, server_pos, key, value):
- """Set the key to the value for the server_pos (position in the list)"""
+ """Set the key to the value for the server_pos (position in the list)."""
self._server_list[server_pos][key] = value
def add_server(self, name, ip, port):
- """Add a new server to the list"""
- new_server = {'key': name, # Zeroconf name with both hostname and port
- 'name': name.split(':')[0], # Short name
- 'ip': ip, # IP address seen by the client
- 'port': port, # TCP port
- 'username': 'glances', # Default username
- 'password': '', # Default password
- 'status': 'UNKNOWN', # Server status: 'UNKNOWN', 'OFFLINE', 'ONLINE', 'PROTECTED'
- 'type': 'DYNAMIC', # Server type: 'STATIC' or 'DYNAMIC'
- }
+ """Add a new server to the list."""
+ new_server = {
+ 'key': name, # Zeroconf name with both hostname and port
+ 'name': name.split(':')[0], # Short name
+ 'ip': ip, # IP address seen by the client
+ 'port': port, # TCP port
+ 'username': 'glances', # Default username
+ 'password': '', # Default password
+ 'status': 'UNKNOWN', # Server status: 'UNKNOWN', 'OFFLINE', 'ONLINE', 'PROTECTED'
+ 'type': 'DYNAMIC'} # Server type: 'STATIC' or 'DYNAMIC'
self._server_list.append(new_server)
logger.debug("Updated servers list (%s servers): %s" %
(len(self._server_list), self._server_list))
def remove_server(self, name):
- """Remove a server from the dict"""
+ """Remove a server from the dict."""
for i in self._server_list:
if i['key'] == name:
try:
@@ -103,22 +99,23 @@ class AutoDiscovered(object):
class GlancesAutoDiscoverListener(object):
- """Zeroconf listener for Glances server"""
+ """Zeroconf listener for Glances server."""
def __init__(self):
# Create an instance of the servers list
self.servers = AutoDiscovered()
def get_servers_list(self):
- """Return the current server list (list of dict)"""
+ """Return the current server list (list of dict)."""
return self.servers.get_servers_list()
def set_server(self, server_pos, key, value):
- """Set the key to the value for the server_pos (position in the list)"""
+ """Set the key to the value for the server_pos (position in the list)."""
self.servers.set_server(server_pos, key, value)
def add_service(self, zeroconf, srv_type, srv_name):
- """Method called when a new Zeroconf client is detected
+ """Method called when a new Zeroconf client is detected.
+
Return True if the zeroconf client is a Glances server
Note: the return code will never be used
"""
@@ -141,7 +138,7 @@ class GlancesAutoDiscoverListener(object):
return True
def remove_service(self, zeroconf, srv_type, srv_name):
- # Remove the server from the list
+ """Remove the server from the list."""
self.servers.remove_server(srv_name)
logger.info(
"Glances server %s removed from the autodetect list" % srv_name)
@@ -149,7 +146,7 @@ class GlancesAutoDiscoverListener(object):
class GlancesAutoDiscoverServer(object):
- """Implementation of the Zeroconf protocol (server side for the Glances client)"""
+ """Implementation of the Zeroconf protocol (server side for the Glances client)."""
def __init__(self, args=None):
if zeroconf_tag:
@@ -169,14 +166,14 @@ class GlancesAutoDiscoverServer(object):