提交 ea8a50b3 编写于 作者: N nicolargo

Merge branch 'develop' of https://github.com/nicolargo/glances into develop

......@@ -15,25 +15,33 @@ displayed.
CPU stats description:
* user: percent time spent in user space
> User CPU time is time spent on the processor running your program's code (or code in libraries)
* system: percent time spent in kernel space
> System CPU time is the time spent running code in the operating system kernel
* idle: percent of CPU used by any program
> Every program or task that runs on a computer system occupies a certain amount of processing time on the CPU. If the CPU has completed all tasks it is idle.
* nice: percent time occupied by user level processes with a positive nice value
> The time the CPU has spent running users' processes that have been "niced"
* irq: percent time spent servicing/handling hardware/software interrupts
> Time servicing interrupts (hardware + software)
* iowait: percent time spent in wait (on disk)
> Time spent by the CPU waiting for a IO operations to complete
* steal: percent time in involuntary wait by virtual CPU
> Steal time is the percentage of time a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor
* ctx_sw: number of context switches (voluntary + involuntary) per second
> A context switch is a procedure that a computer's CPU (central processing unit) follows to change from one task (or process) to another while ensuring that the tasks do not conflict
* inter: number of interrupts per second
* sw_inter: number of software interrupts per second. Always set to 0 on Windows and SunOS.
* syscal: number of system calls per second. Do not displayed on Linux (always 0).
- **user**: percent time spent in user space. User CPU time is the time
spent on the processor running your program's code (or code in
libraries).
- **system**: percent time spent in kernel space. System CPU time is the
time spent running code in the Operating System kernel.
- **idle**: percent of CPU used by any program. Every program or task
that runs on a computer system occupies a certain amount of processing
time on the CPU. If the CPU has completed all tasks it is idle.
- **nice** *(\*nix)*: percent time occupied by user level processes with
a positive nice value. The time the CPU has spent running users'
processes that have been *niced*.
- **irq** *(Linux, \*BSD)*: percent time spent servicing/handling
hardware/software interrupts. Time servicing interrupts (hardware +
software).
- **iowait** *(Linux)*: percent time spent by the CPU waiting for I/O
operations to complete.
- **steal** *(Linux)*: percentage of time a virtual CPU waits for a real
CPU while the hypervisor is servicing another virtual processor.
- **ctx_sw**: number of context switches (voluntary + involuntary) per
second. A context switch is a procedure that a computer's CPU (central
processing unit) follows to change from one task (or process) to
another while ensuring that the tasks do not conflict.
- **inter**: number of interrupts per second.
- **sw_inter**: number of software interrupts per second. Always set to
0 on Windows and SunOS.
- **syscal**: number of system calls per second. Do not displayed on
Linux (always 0).
To switch to per-CPU stats, just hit the ``1`` key:
......
......@@ -23,17 +23,8 @@ You can put your own ``glances.conf`` file in the following locations:
``Windows`` %APPDATA%\\glances
==================== =============================================================
On Windows XP, the ``%APPDATA%`` path is:
::
C:\Documents and Settings\<User>\Application Data
Since Windows Vista and newer versions:
::
C:\Users\<User>\AppData\Roaming
* On Windows XP, ``%APPDATA%`` is: ``C:\Documents and Settings\<USERNAME>\Application Data``.
* On Windows Vista and later: ``C:\Users\<USERNAME>\AppData\Roaming``.
User-specific options override system-wide options and options given on
the command line override either.
......@@ -107,10 +98,13 @@ line.
By default, the ``glances-USERNAME.log`` file is under the temporary directory:
=========== ======================
=========== ======
``*nix`` /tmp
``Windows`` %APPDATA%\\Local\\temp
=========== ======================
``Windows`` %TEMP%
=========== ======
* On Windows XP, ``%TEMP%`` is: ``C:\Documents and Settings\<USERNAME>\Local Settings\Temp``.
* On Windows Vista and later: ``C:\Users\<USERNAME>\AppData\Local\Temp``.
If you want to use another system path or change the log message, you
can use your own logger configuration. First of all, you have to create
......
......@@ -26,6 +26,11 @@ OPTIONS
.. include:: cmds.rst
CONFIGURATION
-------------
.. include:: config.rst
EXAMPLES
--------
......
......@@ -124,8 +124,8 @@ class GlancesClient(object):
self.stats.set_plugins(json.loads(self.client.getAllPlugins()))
logger.debug("Client version: {} / Server version: {}".format(__version__, client_version))
else:
self.log_and_exit("Client and server not compatible: \
Client version: {} / Server version: {}".format(__version__, client_version))
self.log_and_exit(('Client and server not compatible: '
'Client version: {} / Server version: {}'.format(__version__, client_version)))
return False
return True
......
......@@ -42,6 +42,7 @@ def user_config_dir():
path = os.path.expanduser('~/Library/Application Support')
else:
path = os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser('~/.config')
path = os.path.join(path, 'glances')
return path
......@@ -51,10 +52,11 @@ def user_cache_dir():
- Linux, *BSD, SunOS: ~/.cache/glances
- macOS: ~/Library/Caches/glances
- Windows: %LOCALAPPDATA%\glances\cache
- Windows: {%LOCALAPPDATA%,%APPDATA%}\glances\cache
"""
if WINDOWS and os.environ.get('LOCALAPPDATA') is not None:
path = os.path.join(os.environ.get('LOCALAPPDATA'), 'glances', 'cache')
if WINDOWS:
path = os.path.join(os.environ.get('LOCALAPPDATA') or os.environ.get('APPDATA'),
'glances', 'cache')
elif MACOS:
path = os.path.expanduser('~/Library/Caches/glances')
else:
......@@ -77,6 +79,7 @@ def system_config_dir():
path = '/usr/local/etc'
else:
path = os.environ.get('APPDATA')
path = os.path.join(path, 'glances')
return path
......@@ -118,10 +121,8 @@ class Config(object):
if self.config_dir:
paths.append(self.config_dir)
if user_config_dir() is not None:
paths.append(os.path.join(user_config_dir(), self.config_filename))
if system_config_dir() is not None:
paths.append(os.path.join(system_config_dir(), self.config_filename))
paths.append(os.path.join(user_config_dir(), self.config_filename))
paths.append(os.path.join(system_config_dir(), self.config_filename))
return paths
......
......@@ -49,35 +49,34 @@ class GlancesMain(object):
username = "glances"
password = ""
# Exemple of use
example_of_use = "\
Examples of use:\n\
\n\
Monitor local machine (standalone mode):\n\
$ glances\n\
\n\
Monitor local machine with the Web interface (Web UI):\n\
$ glances -w\n\
Glances web server started on http://0.0.0.0:61208/\n\
\n\
Monitor local machine and export stats to a CSV file (standalone mode):\n\
$ glances --export-csv /tmp/glances.csv\n\
\n\
Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):\n\
$ glances -t 5 --export-influxdb\n\
\n\
Start a Glances server (server mode):\n\
$ glances -s\n\
\n\
Connect Glances to a Glances server (client mode):\n\
$ glances -c <ip_server>\n\
\n\
Connect Glances to a Glances server and export stats to a StatsD server (client mode):\n\
$ glances -c <ip_server> --export-statsd\n\
\n\
Start the client browser (browser mode):\n\
$ glances --browser\n\
"
# Examples of use
example_of_use = """
Examples of use:
Monitor local machine (standalone mode):
$ glances
Monitor local machine with the Web interface (Web UI):
$ glances -w
Glances web server started on http://0.0.0.0:61208/
Monitor local machine and export stats to a CSV file (standalone mode):
$ glances --export-csv /tmp/glances.csv
Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):
$ glances -t 5 --export-influxdb
Start a Glances server (server mode):
$ glances -s
Connect Glances to a Glances server (client mode):
$ glances -c <ip_server>
Connect Glances to a Glances server and export stats to a StatsD server (client mode):
$ glances -c <ip_server> --export-statsd
Start the client browser (browser mode):
$ glances --browser
"""
def __init__(self):
"""Manage the command line arguments."""
......@@ -363,30 +362,28 @@ Start the client browser (browser mode):\n\
self.args = args
# Export is only available in standalone or client mode (issue #614)
export_tag = args.export_csv or \
args.export_elasticsearch or \
args.export_statsd or \
args.export_influxdb or \
args.export_cassandra or \
args.export_opentsdb or \
args.export_rabbitmq or \
export_tag = (
args.export_csv or
args.export_elasticsearch or
args.export_statsd or
args.export_influxdb or
args.export_cassandra or
args.export_opentsdb or
args.export_rabbitmq or
args.export_couchdb
)
if WINDOWS and export_tag:
# On Windows, export is possible but only in quiet mode
# See issue #1038
logger.info(
"On Windows OS, export disable the Web Interface")
logger.info("On Windows OS, export disable the Web interface")
self.args.quiet = True
self.args.webserver = False
elif not (self.is_standalone() or self.is_client()) \
and export_tag:
logger.critical(
"Export is only available in standalone or client mode")
elif not (self.is_standalone() or self.is_client()) and export_tag:
logger.critical("Export is only available in standalone or client mode")
sys.exit(2)
# Filter is only available in standalone mode
if args.process_filter is not None \
and not self.is_standalone():
if args.process_filter is not None and not self.is_standalone():
logger.critical(
"Process filter is only available in standalone mode")
sys.exit(2)
......@@ -394,8 +391,7 @@ Start the client browser (browser mode):\n\
# Check graph output path
if args.export_graph and args.path_graph is not None:
if not os.access(args.path_graph, os.W_OK):
logger.critical(
"Graphs output path {} doesn't exist or is not writable".format(args.path_graph))
logger.critical("Graphs output path {} doesn't exist or is not writable".format(args.path_graph))
sys.exit(2)
logger.debug(
"Graphs output path is set to {}".format(args.path_graph))
......@@ -429,30 +425,26 @@ Start the client browser (browser mode):\n\
def is_standalone(self):
"""Return True if Glances is running in standalone mode."""
return not self.args.client \
and not self.args.browser \
and not self.args.server \
and not self.args.webserver
return (not self.args.client and
not self.args.browser and
not self.args.server and
not self.args.webserver)
def is_client(self):
"""Return True if Glances is running in client mode."""
return (self.args.client or self.args.browser) \
and not self.args.server
return (self.args.client or self.args.browser) and not self.args.server
def is_client_browser(self):
"""Return True if Glances is running in client browser mode."""
return self.args.browser \
and not self.args.server
return self.args.browser and not self.args.server
def is_server(self):
"""Return True if Glances is running in server mode."""
return not self.args.client \
and self.args.server
return not self.args.client and self.args.server
def is_webserver(self):
"""Return True if Glances is running in Web server mode."""
return not self.args.client \
and self.args.webserver
return not self.args.client and self.args.webserver
def get_config(self):
"""Return configuration file object."""
......
......@@ -135,8 +135,8 @@ class Outdated(object):
logger.debug("Cannot read the version cache file: {}".format(e))
else:
logger.debug("Read the version cache file")
if cached_data['installed_version'] != self.installed_version() or \
datetime.now() - cached_data['refresh_date'] > self.max_refresh_date:
if (cached_data['installed_version'] != self.installed_version() or
datetime.now() - cached_data['refresh_date'] > self.max_refresh_date):
# Reset the cache if:
# - the installed version is different
# - the refresh_date is > max_refresh_date
......
......@@ -515,9 +515,11 @@ class _GlancesCurses(object):
__stat_display = self.__get_stat_display(stats, plugin_max_width)
# Adapt number of processes to the available space
max_processes_displayed = self.screen.getmaxyx()[0] - 11 - \
self.get_stats_display_height(__stat_display["alert"]) - \
max_processes_displayed = (
self.screen.getmaxyx()[0] - 11 -
self.get_stats_display_height(__stat_display["alert"]) -
self.get_stats_display_height(__stat_display["docker"])
)
try:
if self.args.enable_process_extended and not self.args.process_tree:
max_processes_displayed -= 4
......@@ -618,10 +620,10 @@ class _GlancesCurses(object):
# Space between column
self.space_between_column = 0
self.new_line()
l_uptime = self.get_stats_display_width(stat_display["system"]) \
+ self.space_between_column \
+ self.get_stats_display_width(stat_display["ip"]) + 3 \
+ self.get_stats_display_width(stat_display["uptime"])
l_uptime = (self.get_stats_display_width(stat_display["system"]) +
self.space_between_column +
self.get_stats_display_width(stat_display["ip"]) + 3 +
self.get_stats_display_width(stat_display["uptime"]))
self.display_plugin(
stat_display["system"],
display_optional=(self.screen.getmaxyx()[1] >= l_uptime))
......@@ -722,8 +724,8 @@ class _GlancesCurses(object):
if not self.args.disable_left_sidebar:
for s in ['network', 'wifi', 'ports', 'diskio', 'fs', 'irq',
'folders', 'raid', 'sensors', 'now']:
if (hasattr(self.args, 'enable_' + s) or
hasattr(self.args, 'disable_' + s)) and s in stat_display:
if ((hasattr(self.args, 'enable_' + s) or
hasattr(self.args, 'disable_' + s)) and s in stat_display):
self.new_line()
self.display_plugin(stat_display[s])
......
......@@ -100,9 +100,7 @@ class Plugin(GlancesPlugin):
# Init the return message
ret = []
if not self.stats \
or self.stats == {} \
or self.is_disable():
if not self.stats or self.stats == {} or self.is_disable():
return ret
# Generate the output
......
......@@ -524,9 +524,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist (and non null) and display plugin enable...
if not self.stats \
or len(self.stats['containers']) == 0 \
or self.is_disable():
if not self.stats or len(self.stats['containers']) == 0 or self.is_disable():
return ret
# Build the string message
......
......@@ -229,8 +229,7 @@ class Plugin(GlancesPlugin):
mnt_point = i['mnt_point'][-fsname_max_width + 1:]
elif len(i['mnt_point']) + len(i['device_name'].split('/')[-1]) <= fsname_max_width - 3:
# If possible concatenate mode info... Glances touch inside :)
mnt_point = i['mnt_point'] + \
' (' + i['device_name'].split('/')[-1] + ')'
mnt_point = i['mnt_point'] + ' (' + i['device_name'].split('/')[-1] + ')'
elif len(i['mnt_point']) > fsname_max_width:
# Cut mount point name if it is too long
mnt_point = '_' + i['mnt_point'][-fsname_max_width + 1:]
......
......@@ -100,9 +100,9 @@ class Plugin(GlancesPlugin):
return 'CAREFUL'
elif port['status'] == 0:
return 'CRITICAL'
elif isinstance(port['status'], (float, int)) and \
port['rtt_warning'] is not None and \
port['status'] > port['rtt_warning']:
elif (isinstance(port['status'], (float, int)) and
port['rtt_warning'] is not None and
port['status'] > port['rtt_warning']):
return 'WARNING'
return 'OK'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册