Merge branch 'develop'

This commit is contained in:
nicolargo 2016-03-16 17:42:09 +01:00
commit adb900d4b0
185 changed files with 49581 additions and 5087 deletions

View File

@ -3,12 +3,13 @@ python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "pypy"
install:
- pip install -r requirements.txt
- pip install coveralls
script:
script:
- python setup.py install
- coverage run --source=glances unitest.py
after_success:
- coveralls
- coveralls

View File

@ -8,7 +8,7 @@ https://twitter.com/nicolargo
https://github.com/nicolargo
nicolashennion@gmail.com
PGP Fingerprint: 835F C447 3BCD 60E9 9200 2778 ABA4 D1AB 9731 6A3C
PGP Public key: gpg --keyserver pgp.mit.edu --recv-keys 0xaba4d1ab97316a3c
PGP Public key: gpg --keyserver pgp.mit.edu --recv-keys 0xaba4d1ab97316a3c
Alessio Sergi (aka) Al3hex
https://twitter.com/al3hex
@ -37,8 +37,8 @@ https://github.com/notFloran
Packagers
=========
Rémi Verchère for the Debian package
https://github.com/rverchere/debian-glances
Daniel Echeverry and Sebastien Badia for the Debian package
https://mentors.debian.net/package/glances
Philip Lacroix for the Slackware (SlackBuild) package

View File

@ -122,7 +122,9 @@ included in the project:
git checkout -b <topic-branch-name>
```
4. Commit your changes in logical chunks. Please adhere to these [git commit
4. It's coding time !
Please respect the following coding convention: [Elements of Python Style](https://github.com/amontalenti/elements-of-python-style)
Commit your changes in logical chunks. Please adhere to these [git commit
message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
or your code is unlikely be merged into the main project. Use Git's
[interactive rebase](https://help.github.com/articles/interactive-rebase)

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
#
# Glances Dockerfile
#
# https://github.com/nicolargo/glances
#
# Pull base image.
FROM ubuntu
# Install Glances (develop branch)
RUN apt-get -y install curl && \
curl -L https://raw.githubusercontent.com/nicolargo/glancesautoinstall/master/install-develop.sh | /bin/bash
# Define working directory.
WORKDIR /glances
# EXPOSE PORT (For XMLRPC)
EXPOSE 61209
# EXPOSE PORT (For Web UI)
EXPOSE 61208
# Define default command.
CMD python -m glances $GLANCES_OPT

View File

@ -3,17 +3,6 @@ include COPYING
include NEWS
include README.rst
include conf/glances.conf
include glances/outputs/static/html/*.html
include glances/outputs/static/html/plugins/*.html
include glances/outputs/static/*.ico
include glances/outputs/static/css/*.css
include glances/outputs/static/js/*.js
include glances/outputs/static/js/*.js.map
include glances/outputs/static/js/services/core/*.js
include glances/outputs/static/js/services/plugins/*.js
include glances/outputs/static/js/vendors/*.js
include glances/outputs/static/js/vendors/*.js.map
include glances/outputs/static/images/*.png
include man/glances.1
recursive-include docs images/*.png glances-doc.html
recursive-include docs *
recursive-include glances *.py
recursive-include glances/outputs/static *

55
NEWS
View File

@ -2,6 +2,61 @@
Glances Version 2
==============================================================================
Version 2.6
===========
Deprecations:
* Add deprecation warning for Python 2.6.
Python 2.6 support will be dropped in future releases.
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.
Enhancements and new features:
* Add a connector to ElasticSearch (welcome to Kibana dashboard) (issue #311)
* New folders' monitoring plugins (issue #721)
* Use wildcard (regexp) to the hide configuration option for network, diskio and fs sections (issue #799 )
* Command line arguments are now take into account in the WebUI (#789 by @notFloran)
* Change username for server and web server authentication (issue #693)
* Add an option to disable top menu (issue #766)
* Add IOps in the DiskIO plugin (issue #763)
* Add hide configuration key for FS Plugin (issue #736)
* Add process summary min/max stats (issue #703)
* Add timestamp to the CSV export module (issue #708)
* Add a shortcut 'E' to delete process filter (issue #699)
* By default, hide disk I/O ram1-** (issue #714)
* When Glances is starting the notifications should be delayed (issue #732)
* Add option (--disable-bg) to disable ANSI background colours (issue #738 by okdana)
* [WebUI] add "pointer" cursor for sortable columns (issue #704 by @notFloran)
* [WebUI] Make web page title configurable (issue #724)
* Do not show interface in down state (issue #765)
* InfluxDB > 0.9.3 needs float and not int for numerical value (issue#749 and issue#750 by nicolargo)
Bugs corrected:
* Can't read sensors on a Thinkpad (issue #711)
* InfluxDB/OpenTSDB: tag parsing broken (issue #713)
* Grafana Dashboard outdated for InfluxDB 0.9.x (issue #648)
* '--tree' breaks process filter on Debian 8 (issue #768)
* Fix highlighting of process when it contains whitespaces (issue #546 by Alessio Sergi)
* Fix RAID support in Python 3 (issue #793 by Alessio Sergi)
* Use dict view objects to avoid issue (issue #758 by Alessio Sergi)
* System exit if Cpu not supported by the Cpuinfo lib (issue #754 by nicolargo)
* KeyError: 'cpucore' when exporting data to InfluxDB (issue #729) by nicolargo)
Others:
* A new Glances docker container to monitor your Docker infrastructure is available here (issue #728): https://hub.docker.com/r/nicolargo/glances/
* Documentation is now generated automatically thanks to Sphinx and the Alessio Sergi patch (http://glances.readthedocs.org/en/latest/)
Contributors summary:
* Nicolas Hennion: 112 commits
* Alessio Sergi: 55 commits
* Floran Brutel: 19 commits
* Nicolas Hart: 8 commits
* @desbma: 4 commits
* @dana: 2 commits
* Damien Martin, Raju Kadam, @georgewhewell: 1 commit
Version 2.5.1
=============

View File

@ -3,6 +3,8 @@ Glances - An eye on your system
===============================
.. image:: https://img.shields.io/pypi/v/glances.svg
:target: https://pypi.python.org/pypi/Glances
.. image:: https://img.shields.io/pypi/dm/glances.svg
:target: https://pypi.python.org/pypi/glances#downloads
:alt: Downloads this month
@ -10,13 +12,13 @@ Glances - An eye on your system
:target: https://github.com/nicolargo/glances/
:alt: Github stars
.. image:: https://travis-ci.org/nicolargo/glances.svg?branch=master
:target: https://travis-ci.org/nicolargo/glances
.. image:: https://img.shields.io/pypi/v/glances.svg
:target: https://pypi.python.org/pypi/Glances
:target: https://travis-ci.org/nicolargo/glances
.. image:: https://circleci.com/gh/nicolargo/glances/tree/develop.svg?style=svg
:target: https://circleci.com/gh/nicolargo/glances/tree/develop
.. image:: https://img.shields.io/scrutinizer/g/nicolargo/glances.svg
:target: https://scrutinizer-ci.com/g/nicolargo/glances/
:target: https://scrutinizer-ci.com/g/nicolargo/glances/
.. image:: https://api.flattr.com/button/flattr-badge-large.png
:target: https://flattr.com/thing/484466/nicolargoglances-on-GitHub
:target: https://flattr.com/thing/484466/nicolargoglances-on-GitHub
Follow Glances on Twitter: `@nicolargo`_ or `@glances_system`_
@ -28,7 +30,7 @@ written in Python.
Requirements
============
- ``python >= 2.6`` or ``>= 3.3`` (tested with version 2.6, 2.7, 3.3, 3.4)
- ``python >= 2.6`` or ``>= 3.3`` (tested with version 2.6, 2.7, 3.3, 3.4, 3.5)
- ``psutil >= 2.0.0``
- ``setuptools``
@ -49,12 +51,15 @@ Optional dependencies:
- ``matplotlib`` (for graphical/chart support)
- ``pika`` (for the RabbitMQ/ActiveMQ export module)
- ``py-cpuinfo`` (for the Quicklook CPU info module)
- ``scandir`` (for the Folders plugin) [Only for Python < 3.5]
Installation
============
Glances Auto Install script
---------------------------
Several method to test/install Glances on your system. Choose your weapon !
Glances Auto Install script: the total way
------------------------------------------
To install both dependencies and latest Glances production ready version
(aka *master* branch), just enter the following command line:
@ -93,7 +98,7 @@ features (like the Web interface):
.. code-block:: console
pip install bottle batinfo https://bitbucket.org/gleb_zhulik/py3sensors/get/tip.tar.gz zeroconf netifaces pymdstat influxdb potsdb statsd pystache docker-py pysnmp pika py-cpuinfo
pip install bottle batinfo https://bitbucket.org/gleb_zhulik/py3sensors/get/tip.tar.gz zeroconf netifaces pymdstat influxdb potsdb statsd pystache docker-py pysnmp pika py-cpuinfo scandir
Install or upgrade Glances from the Git ``develop`` repository:
@ -115,6 +120,24 @@ If you need to install Glances in a specific user location, use:
export PYTHONUSERBASE=~/mylocalpath
pip install --user glances
Docker: the funny way
---------------------
A Glances container is available. It will include the latest development HEAD version. You can use it to monitor your server and all your others containers !
Get the Glances container:
.. code-block:: console
docker pull nicolargo/glances
Run the container in console mode:
.. code-block:: console
docker run -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host -it docker.io/nicolargo/glances
GNU/Linux
---------
@ -190,6 +213,11 @@ To install Glances from source:
*Note*: Python headers are required to install psutil. For example,
on Debian/Ubuntu you need to install first the *python-dev* package.
Chef
----
An awesome ``Chef`` cookbook is available to monitor your infrastructure: https://supermarket.chef.io/cookbooks/glances (thanks to Antoine Rouyer)
Puppet
------
@ -238,7 +266,7 @@ and RTFM, always.
Documentation
=============
For complete documentation see `glances-doc`_.
For complete documentation have a look at the readthedocs_ website.
If you have any question (after RTFM!), please post it on the official Q&A `forum`_.
@ -273,6 +301,6 @@ LGPL. See ``COPYING`` for more details.
.. _@nicolargo: https://twitter.com/nicolargo
.. _@glances_system: https://twitter.com/glances_system
.. _Python: https://www.python.org/getit/
.. _glances-doc: https://github.com/nicolargo/glances/blob/master/docs/glances-doc.rst
.. _readthedocs: https://glances.readthedocs.org/
.. _forum: https://groups.google.com/forum/?hl=en#!forum/glances-users
.. _wiki: https://github.com/nicolargo/glances/wiki/How-to-contribute-to-Glances-%3F

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
[quicklook]
# Define CPU, MEM and SWAP thresholds in %
cpu_careful=50
cpu_warning=70
cpu_critical=90
@ -10,12 +11,13 @@ swap_warning=70
swap_critical=90
[cpu]
# Define CPU thresholds in %
# Default values if not defined: 50/70/90
user_careful=50
user_warning=70
user_critical=90
#user_log=False
#user_critical_action=echo {{user}} {{value}} {{max}} > /tmp/cpu.alert
#user_critical_action=echo `date` - {{user}} > /tmp/cpu.alert
iowait_careful=50
iowait_warning=70
iowait_critical=90
@ -28,6 +30,7 @@ steal_critical=90
#steal_log=True
[percpu]
# Define CPU thresholds in %
# Default values if not defined: 50/70/90
user_careful=50
user_warning=70
@ -40,6 +43,7 @@ system_warning=70
system_critical=90
[load]
# Define LOAD thresholds
# Value * number of cores
# Default values if not defined: 0.7/1.0/5.0 per number of cores
# Source: http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages
@ -50,22 +54,22 @@ critical=5.0
#log=False
[mem]
# Default limits for free RAM memory in %
# Define RAM thresholds in %
# Default values if not defined: 50/70/90
careful=50
warning=70
critical=90
[memswap]
# Default limits for free swap memory in %
# Define SWAP thresholds in %
# Default values if not defined: 50/70/90
careful=50
warning=70
critical=90
#[network]
# Define the list of hidden network interfaces (comma separeted)
#hide=lo
# Define the list of hidden network interfaces (comma-separated regexp)
#hide=docker.*,lo
# WLAN 0 alias
#wlan0_alias=Wireless IF
# WLAN 0 Default limits (in bits per second aka bps) for interface bitrate
@ -79,34 +83,53 @@ critical=90
#wlan0_tx_log=True
#[diskio]
# Define the list of hidden disks (comma separeted)
#hide=sda2,sda5
# Define the list of hidden disks (comma-separated regexp)
#hide=sda2,sda5,loop.*
# Alias for sda1
#sda1_alias=IntDisk
[fs]
# Default limits for free filesytem space in %
# Define the list of hidden file system (comma-separated regexp)
#hide=/boot.*
# Define filesystem space thresholds in %
# Default values if not defined: 50/70/90
# It is also possible to define per mount point value
# Example: /_careful=40
careful=50
warning=70
critical=90
# Allow additionnals files types (comma-separated FS type)
# Allow additional file system types (comma-separated FS type)
#allow=zfs
#[folders]
# Define a folder list to monitor
# The list is composed of items (list_#nb <= 10)
# An item is defined by:
# * path: absolute path
# * careful: optional careful threshold (in MB)
# * warning: optional warning threshold (in MB)
# * critical: optional critical threshold (in MB)
#folder_1_path=/tmp
#folder_1_careful=2500
#folder_1_warning=3000
#folder_1_critical=3500
#folder_2_path=/home/nicolargo/Videos
#folder_2_warning=17000
#folder_2_critical=20000
#folder_3_path=/nonexisting
[sensors]
# Sensors core limits (in Celsius...)
# Sensors core thresholds (in Celsius...)
# Default values if not defined: 60/70/80
temperature_core_careful=60
temperature_core_warning=70
temperature_core_critical=80
# Temperatures in °C for hddtemp
# Temperatures threshold in °C for hddtemp
# Default values if not defined: 45/52/60
temperature_hdd_careful=45
temperature_hdd_warning=52
temperature_hdd_critical=60
# Battery % limits
# Battery threshold in %
battery_careful=80
battery_warning=90
battery_critical=95
@ -117,7 +140,7 @@ battery_critical=95
#core 1_alias=CPU Core 1
[processlist]
# Limit values for CPU/MEM per process in %
# Define CPU/MEM (per process) thresholds in %
# Default values if not defined: 50/70/90
cpu_careful=50
cpu_warning=70
@ -165,18 +188,18 @@ mem_critical=90
#server_4_name=pasbon
#server_4_port=61237
[passwords]
#[passwords]
# Define the passwords list
# Syntax: host=password
# Where: host is the hostname
# password is the clear password
# Additionnaly (and optionnaly) a default password could be defined
# Additionally (and optionally) a default password could be defined
#xps=abc
#default=defaultpassword
[influxdb]
# Configuration file for the --export-influxdb option
# https://influxdb.com/
# https://influxdb.com/
host=localhost
port=8086
user=root
@ -200,6 +223,14 @@ host=localhost
port=8125
#prefix=glances
[elasticsearch]
# Configuration file for the --export-elasticsearch option
# Data are available via the ES Restful API. ex: URL/<index>/cpu/system
# https://www.elastic.co
host=localhost
port=9200
index=glances
[rabbitmq]
host=localhost
port=5672

View File

@ -7,6 +7,11 @@ SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
@ -14,8 +19,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@ -25,53 +29,66 @@ help:
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"
.PHONY: clean
clean:
-rm -rf $(BUILDDIR)/*
rm -rf $(BUILDDIR)/*
.PHONY: html
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
.PHONY: dirhtml
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
.PHONY: pickle
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
.PHONY: json
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
.PHONY: htmlhelp
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
.PHONY: qthelp
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@ -81,6 +98,16 @@ qthelp:
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Glances.qhc"
.PHONY: applehelp
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."
.PHONY: devhelp
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@ -90,11 +117,13 @@ devhelp:
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Glances"
@echo "# devhelp"
.PHONY: epub
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
.PHONY: latex
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@ -102,22 +131,36 @@ latex:
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
.PHONY: latexpdf
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: latexpdfja
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: text
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
.PHONY: man
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
rm -f man/*
cp $(BUILDDIR)/man/* man/
@echo "The manual pages have been copied in ./man."
.PHONY: texinfo
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@ -125,29 +168,52 @@ texinfo:
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
.PHONY: info
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
.PHONY: gettext
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
.PHONY: changes
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
.PHONY: linkcheck
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
.PHONY: doctest
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
.PHONY: coverage
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."
.PHONY: xml
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
.PHONY: pseudoxml
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

22
docs/README.txt Normal file
View File

@ -0,0 +1,22 @@
Building the docs
=================
First install Sphinx:
pip install sphinx
or update it if already installed:
pip install --upgrade sphinx
Go to the docs folder:
cd docs
Then build the HTML documentation:
make html
and the man page:
LC_ALL=C make man

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

BIN
docs/_static/folders.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 287 KiB

After

Width:  |  Height:  |  Size: 287 KiB

BIN
docs/_static/grafana.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 222 KiB

After

Width:  |  Height:  |  Size: 222 KiB

View File

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
docs/_static/screenshot-web.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

BIN
docs/_static/screenshot-web2.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
docs/_static/screenshot-wide.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

View File

Before

Width:  |  Height:  |  Size: 496 KiB

After

Width:  |  Height:  |  Size: 496 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

7
docs/_templates/links.html vendored Normal file
View File

@ -0,0 +1,7 @@
<h3>Useful Links</h3>
<ul>
<li><a href="https://pypi.python.org/pypi/Glances">Glances @ PyPI</a></li>
<li><a href="https://github.com/nicolargo/glances">Glances @ GitHub</a></li>
<li><a href="https://github.com/nicolargo/glances/issues">Issue Tracker</a></li>
<li><a href="https://groups.google.com/forum/#!forum/glances-users">Forum</a></li>
</ul>

34
docs/aoa/actions.rst Normal file
View File

@ -0,0 +1,34 @@
.. _actions:
Actions
=======
Glances can trigger actions on events.
By ``action``, we mean all shell command line. For example, if you want
to execute the ``foo.py`` script if the last 5 minutes load are critical
then add the ``_action`` line to the Glances configuration file:
.. code-block:: ini
[load]
critical=5.0
critical_action=python /path/to/foo.py
All the stats are available in the command line through the use of the
`{{mustache}}`_ syntax. Another example would be to create a log file
containing used vs total disk space if a space trigger warning is
reached:
.. code-block:: ini
[fs]
warning=70
warning_action=echo {{mnt_point}} {{used}}/{{size}} > /tmp/fs.alert
.. note::
You can use all the stats for the current plugin. See
https://github.com/nicolargo/glances/wiki/The-Glances-2.x-API-How-to
for the stats list.
.. _{{mustache}}: https://mustache.github.io/

41
docs/aoa/cpu.rst Normal file
View File

@ -0,0 +1,41 @@
.. _cpu:
CPU
===
The CPU stats are shown as a percentage and for the configured refresh
time. The total CPU usage is displayed on the first line.
.. image:: ../_static/cpu.png
If enough horizontal space is available, extended CPU information are
displayed.
.. image:: ../_static/cpu-wide.png
To switch to per-CPU stats, just hit the ``1`` key:
.. image:: ../_static/per-cpu.png
By default, ``steal`` CPU time alerts aren't logged. If you want that,
just add to the configuration file:
.. code-block:: ini
[cpu]
steal_log=True
Legend:
================= ============
CPU (user/system) Status
================= ============
``<50%`` ``OK``
``>50%`` ``CAREFUL``
``>70%`` ``WARNING``
``>90%`` ``CRITICAL``
================= ============
.. note::
Limit values can be overwritten in the configuration file under
the ``[cpu]`` and/or ``[percpu]`` sections.

26
docs/aoa/disk.rst Normal file
View File

@ -0,0 +1,26 @@
.. _disk:
Disk I/O
========
.. image:: ../_static/diskio.png
Glances displays the disk I/O throughput. The unit is adapted
dynamically.
There is no alert on this information.
It's possible to define:
- a list of disks to hide
- aliases for disk name
under the ``[diskio]`` section in the configuration file.
For example, if you want to hide the loopback disks (loop0, loop1, ...)
and the specific ``sda5`` partition:
.. code-block:: ini
[diskio]
hide=sda5,loop.*

11
docs/aoa/docker.rst Normal file
View File

@ -0,0 +1,11 @@
.. _docker:
Docker
======
If you use ``Docker``, Glances can help you to monitor your containers.
Glances uses the Docker API through the `docker-py`_ library.
.. image:: ../_static/docker.png
.. _docker-py: https://github.com/docker/docker-py

34
docs/aoa/folders.rst Normal file
View File

@ -0,0 +1,34 @@
.. _folders:
Folders
=======
The folders plugin allows user, through the configuration file, to
monitor size of a predefined folders list.
.. image:: ../_static/folders.png
Each item is defined by:
- ``path``: absolute path to monitor (mandatory)
- ``careful``: optional careful threshold (in MB)
- ``warning``: optional warning threshold (in MB)
- ``critical``: optional critical threshold (in MB)
Up to ``10`` items can be defined.
For example, if you want to monitor the ``/tmp`` folder, the following
definition should do the job:
.. code-block:: ini
[folders]
folder_1_path=/tmp
folder_1_careful=2500
folder_1_warning=3000
folder_1_critical=3500
In client/server mode, the list is defined on the ``server`` side.
.. warning::
Do **NOT** define folders containing lot of files and subfolders.

55
docs/aoa/fs.rst Normal file
View File

@ -0,0 +1,55 @@
.. _fs:
File System
===========
.. image:: ../_static/fs.png
Glances displays the used and total file system disk space. The unit is
adapted dynamically.
Alerts are set for used disk space.
Legend:
=========== ============
Disk usage Status
=========== ============
``<50%`` ``OK``
``>50%`` ``CAREFUL``
``>70%`` ``WARNING``
``>90%`` ``CRITICAL``
=========== ============
.. note::
Limit values can be overwritten in the configuration file under
the ``[filesystem]`` section.
By default, the plugin only displays physical devices (hard disks, USB
keys). To allow other file system types, you have to enable them in the
configuration file. For example, if you want to allow the ``zfs`` file
system:
.. code-block:: ini
[fs]
allow=zfs
Also, you can hide mount points as well (in the following ``/boot``):
.. code-block:: ini
[fs]
hide=/boot.*
RAID
----
*Availability: Linux*
Thanks to the `pymdstat`_ library, if a ``RAID`` controller is detected
on you system, its status will be displayed as well:
.. image:: ../_static/raid.png
.. _pymdstat: https://github.com/nicolargo/pymdstat

20
docs/aoa/header.rst Normal file
View File

@ -0,0 +1,20 @@
.. _header:
Header
======
.. image:: ../_static/header.png
The header shows the hostname, OS name, release version, platform
architecture and system uptime (on the upper right corner).
Additionally, on GNU/Linux, it also shows the kernel version.
In client mode, the server connection status is also displayed.
**Connected**:
.. image:: ../_static/connected.png
**Disconnected**:
.. image:: ../_static/disconnected.png

37
docs/aoa/index.rst Normal file
View File

@ -0,0 +1,37 @@
.. _aoa:
Anatomy Of The Application
==========================
This document is meant to give an overview of the Glances interface.
Legend:
=========== ============
``GREEN`` ``OK``
``BLUE`` ``CAREFUL``
``MAGENTA`` ``WARNING``
``RED`` ``CRITICAL``
=========== ============
.. note::
Only stats with colored background will be shown in the alert view.
.. toctree::
:maxdepth: 2
header
quicklook
cpu
load
memory
network
disk
fs
folders
sensors
ps
monitor
logs
docker
actions

35
docs/aoa/load.rst Normal file
View File

@ -0,0 +1,35 @@
.. _load:
Load
====
*Availability: Unix*
.. image:: ../_static/load.png
On the *No Sheep* blog, Zachary Tirrell defines the `load average`_:
"In short it is the average sum of the number of processes
waiting in the run-queue plus the number currently executing
over 1, 5, and 15 minutes time periods."
Glances gets the number of CPU core to adapt the alerts.
Alerts on load average are only set on 15 minutes time period.
The first line also displays the number of CPU core.
Legend:
============= ============
Load avg Status
============= ============
``<0.7*core`` ``OK``
``>0.7*core`` ``CAREFUL``
``>1*core`` ``WARNING``
``>5*core`` ``CRITICAL``
============= ============
.. note::
Limit values can be overwritten in the configuration file under
the ``[load]`` section.
.. _load average: http://nosheep.net/story/defining-unix-load-average/

21
docs/aoa/logs.rst Normal file
View File

@ -0,0 +1,21 @@
.. _logs:
Logs
====
.. image:: ../_static/logs.png
A log messages list is displayed in the bottom of the screen if and only
if:
- at least one ``WARNING`` or ``CRITICAL`` alert was occurred
- space is available in the bottom of the console/terminal
Each alert message displays the following information:
1. start datetime
2. duration if alert is terminated or `ongoing` if the alert is still in
progress
3. alert name
4. {min,avg,max} values or number of running processes for monitored
processes list alerts

30
docs/aoa/memory.rst Normal file
View File

@ -0,0 +1,30 @@
.. _memory:
Memory
======
Glances uses two columns: one for the ``RAM`` and one for the ``SWAP``.
.. image:: ../_static/mem.png
If enough space is available, Glances displays extended information for
the ``RAM``:
.. image:: ../_static/mem-wide.png
Alerts are only set for used memory and used swap.
Legend:
======== ============
RAM/Swap Status
======== ============
``<50%`` ``OK``
``>50%`` ``CAREFUL``
``>70%`` ``WARNING``
``>90%`` ``CRITICAL``
======== ============
.. note::
Limit values can be overwritten in the configuration file under
the ``[memory]`` and/or ``[memswap]`` sections.

65
docs/aoa/monitor.rst Normal file
View File

@ -0,0 +1,65 @@
.. _monitor:
Monitored Processes List
========================
The monitored processes list allows user, through the configuration
file, to group processes and quickly show if the number of running
processes is not good.
.. image:: ../_static/monitored.png
Each item is defined by:
- ``description``: description of the processes (max 16 chars).
- ``regex``: regular expression of the processes to monitor.
- ``command``: (optional) full path to shell command/script for extended
- stat. Should return a single line string. Use with caution.
- ``countmin``: (optional) minimal number of processes. A warning will
- be displayed if number of processes < count.
- ``countmax``: (optional) maximum number of processes. A warning will
be displayed if number of processes > count.
Up to ``10`` items can be defined.
For example, if you want to monitor the Nginx processes on a web server,
the following definition should do the job:
.. code-block:: ini
[monitor]
list_1_description=Nginx server
list_1_regex=.*nginx.*
list_1_command=nginx -v
list_1_countmin=1
list_1_countmax=4
If you also want to monitor the PHP-FPM daemon processes, you should add
another item:
.. code-block:: ini
[monitor]
list_1_description=Nginx server
list_1_regex=.*nginx.*
list_1_command=nginx -v
list_1_countmin=1
list_1_countmax=4
list_2_description=PHP-FPM
list_2_regex=.*php-fpm.*
list_2_countmin=1
list_2_countmax=20
In client/server mode, the list is defined on the server side.
A new method, called `getAllMonitored`, is available in the APIs and
get the JSON representation of the monitored processes list.
Alerts are set as following:
================= ============
# of process Status
================= ============
``0`` ``CRITICAL``
``min < p < max`` ``OK``
``p > max`` ``WARNING``
================= ============

28
docs/aoa/network.rst Normal file
View File

@ -0,0 +1,28 @@
.. _network:
Network
=======
.. image:: ../_static/network.png
Glances displays the network interface bit rate. The unit is adapted
dynamically (bit/s, kbit/s, Mbit/s, etc).
Alerts are only set if the maximum speed per network interface is
available (see sample in the configuration file).
It's also possibile to define:
- a list of network interfaces to hide
- per-interface limit values
- aliases for interface name
in the ``[network]`` section of the configuration file.
For example, if you want to hide the loopback interface (lo) and all the
virtual docker interface (docker0, docker1, ...):
.. code-block:: ini
[network]
hide=lo,docker.*

107
docs/aoa/ps.rst Normal file
View File

@ -0,0 +1,107 @@
.. _ps:
Processes List
==============
Compact view:
.. image:: ../_static/processlist.png
Full view:
.. image:: ../_static/processlist-wide.png
Filtered view:
.. image:: ../_static/processlist-filter.png
The process view consists of 3 parts:
- Processes summary
- Monitored processes list (optional)
- Processes list
The processes summary line displays:
- Tasks number (total number of processes)
- Threads number
- Running tasks number
- Sleeping tasks number
- Other tasks number (not running or sleeping)
- Sort key
By default, or if you hit the ``a`` key, the processes list is
automatically sorted by:
- ``CPU``: if there is no alert (default behavior)
- ``CPU``: if a CPU or LOAD alert is detected
- ``MEM``: if a memory alert is detected
- ``DISK I/O``: if a CPU iowait alert is detected
The number of processes in the list is adapted to the screen size.
Columns display
---------------
========================= ==============================================
``CPU%`` % of CPU used by the process
If Irix/Solaris mode is off, the value is
divided by logical core number
``MEM%`` % of MEM used by the process
``VIRT`` Virtual Memory Size
The total amount of virtual memory used by the
process
``RES`` Resident Memory Size
The non-swapped physical memory a process is
using
``PID`` Process ID
``USER`` User ID
``NI`` Nice level of the process
``S`` Process status
The status of the process:
- ``R``: running
- ``S``: sleeping (may be interrupted)
- ``D``: disk sleep (may not be interrupted)
- ``T``: traced/stopped
- ``Z``: zombie
``TIME+`` Cumulative CPU time used by the process
``R/s`` Per process I/O read rate in B/s
``W/s`` Per process I/O write rate in B/s
``COMMAND`` Process command line or command name
User can switch to the process name by
pressing on the ``'/'`` key
========================= ==============================================
Extended info
-------------
.. image:: ../_static/processlist-top.png
In standalone mode, additional information are provided for the top
process:
========================= ==============================================
``CPU affinity`` Number of cores used by the process
``Memory info`` Extended memory information about the process
For example, on Linux: swap, shared, text,
lib, data and dirty
``Open`` The number of threads, files and network
sessions (TCP and UDP) used by the process
``IO nice`` The process I/O niceness (priority)
========================= ==============================================
The extended stats feature can be enabled using the
``--enable-process-extended`` option (command line) or the ``e`` key
(curses interface).
.. note::
Limit values can be overwritten in the configuration file under
the ``[process]`` section.

17
docs/aoa/quicklook.rst Normal file
View File

@ -0,0 +1,17 @@
.. _quicklook:
Quick Look
==========
The ``quicklook`` plugin is only displayed on wide screen and proposes a
bar view for CPU and memory (virtual and swap).
.. image:: ../_static/quicklook.png
If the per CPU mode is on (by clicking the ``1`` key):
.. image:: ../_static/quicklook-percpu.png
.. note::
Limit values can be overwritten in the configuration file under
the ``[quicklook]`` section.

24
docs/aoa/sensors.rst Normal file
View File

@ -0,0 +1,24 @@
.. _sensors:
Sensors
=======
*Availability: Linux*
.. image:: ../_static/sensors.png
Glances can displays the sensors information using ``lm-sensors``,
``hddtemp`` and `batinfo`_.
All of the above libraries are available only on Linux.
As of ``lm-sensors``, a filter is being applied in order to display
temperature and fan speed only.
There is no alert on this information.
.. note::
Limit values and sensors alias names can be defined in the
configuration file under the ``[sensors]`` section.
.. _batinfo: https://github.com/nicolargo/batinfo

15
docs/api.rst Normal file
View File

@ -0,0 +1,15 @@
.. _api:
API Documentation
=================
Glances provides an `XML-RPC server`_ and a `RESTful-JSON`_ API which
can be used by other clients.
API documentation is available at:
- XML-RPC: https://github.com/nicolargo/glances/wiki/The-Glances-2.x-API-How-to
- RESTful-JSON: https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API
.. _XML-RPC server: http://docs.python.org/2/library/simplexmlrpcserver.html
.. _RESTful-JSON: http://jsonapi.org/

413
docs/cmds.rst Normal file
View File

@ -0,0 +1,413 @@
.. _cmds:
Command Reference
=================
Command-Line Options
--------------------
.. option:: -h, --help
show this help message and exit
.. option:: -V, --version
show program's version number and exit
.. option:: -d, --debug
enable debug mode
.. option:: -C CONF_FILE, --config CONF_FILE
path to the configuration file
.. option:: -3, --disable-quicklook
disable quick look module
.. option:: -4, --full-quicklook
disable all but quick look and load
.. option:: --disable-cpu
disable CPU module
.. option:: --disable-mem
disable memory module
.. option:: --disable-swap
disable swap module
.. option:: --disable-load
disable load module
.. option:: --disable-network
disable network module
.. option:: --disable-ip
disable IP module
.. option:: --disable-diskio
disable disk I/O module
.. option:: --disable-fs
disable filesystem module
.. option:: --disable-folder
disable folder module
.. option:: --disable-sensors
disable sensors module
.. option:: --disable-hddtemp
disable HD temperature module
.. option:: --disable-raid
disable RAID module
.. option:: --disable-docker
disable Docker module
.. option:: -5, --disable-top
disable top menu (QuickLook, CPU, MEM, SWAP and LOAD)
.. option:: -2, --disable-left-sidebar
disable network, disk I/O, FS and sensors modules (py3sensors lib
needed)
.. option:: --disable-process
disable process module
.. option:: --disable-log
disable log module
.. option:: --disable-bold
disable bold mode in the terminal
.. option:: --disable-bg
disable background colors in the terminal
.. option:: --enable-process-extended
enable extended stats on top process
.. option:: --enable-history
enable the history mode (matplotlib lib needed)
.. option:: --path-history PATH_HISTORY
set the export path for graph history
.. option:: --export-csv EXPORT_CSV
export stats to a CSV file
.. option:: --export-influxdb
export stats to an InfluxDB server (influxdb lib needed)
.. option:: --export-opentsdb
export stats to an OpenTSDB server (potsdb lib needed)
.. option:: --export-statsd
export stats to a StatsD server (statsd lib needed)
.. option:: --export-rabbitmq
export stats to RabbitMQ broker (pika lib needed)
.. option:: --export-elasticsearch
export stats to an Elasticsearch server (elasticsearch lib needed)
.. option:: -c CLIENT, --client CLIENT
connect to a Glances server by IPv4/IPv6 address or hostname
.. option:: -s, --server
run Glances in server mode
.. option:: --browser
start the client browser (list of servers)
.. option:: --disable-autodiscover
disable autodiscover feature
.. option:: -p PORT, --port PORT
define the client/server TCP port [default: 61209]
.. option:: -B BIND_ADDRESS, --bind BIND_ADDRESS
bind server to the given IPv4/IPv6 address or hostname
.. option:: --username
define a client/server username
.. option:: --password
define a client/server password
.. option:: --snmp-community SNMP_COMMUNITY
SNMP community
.. option:: --snmp-port SNMP_PORT
SNMP port
.. option:: --snmp-version SNMP_VERSION
SNMP version (1, 2c or 3)
.. option:: --snmp-user SNMP_USER
SNMP username (only for SNMPv3)
.. option:: --snmp-auth SNMP_AUTH
SNMP authentication key (only for SNMPv3)
.. option:: --snmp-force
force SNMP mode
.. option:: -t TIME, --time TIME
set refresh time in seconds [default: 3 sec]
.. option:: -w, --webserver
run Glances in web server mode (bottle lib needed)
.. option:: -q, --quiet
do not display the curses interface
.. option:: -f PROCESS_FILTER, --process-filter PROCESS_FILTER
set the process filter pattern (regular expression)
.. option:: --process-short-name
force short name for processes name
.. option:: -0, --disable-irix
task's CPU usage will be divided by the total number of CPUs
.. option:: --hide-kernel-threads
hide kernel threads in process list
.. option:: --tree
display processes as a tree
.. option:: -b, --byte
display network rate in byte per second
.. option:: --diskio-show-ramfs
show RAM FS in the DiskIO plugin
.. option:: --diskio-iops
show I/O per second in the DiskIO plugin
.. option:: --fahrenheit
display temperature in Fahrenheit (default is Celsius)
.. option:: -1, --percpu
start Glances in per CPU mode
.. option:: --fs-free-space
display FS free space instead of used
.. option:: --theme-white
optimize display colors for white background
Interactive Commands
--------------------
The following commands (key pressed) are supported while in Glances:
``ENTER``
Set the process filter
**Note**: on OS X, please use ``CTRL-H`` to delete
filter.
Filter is a regular expression pattern:
- ``gnome``: matches all processes starting with the ``gnome``
string
- ``.*gnome.*``: matches all processes containing the ``gnome``
string
``a``
Sort process list automatically
- If CPU ``>70%``, sort processes by CPU usage
- If MEM ``>70%``, sort processes by MEM usage
- If CPU iowait ``>60%``, sort processes by I/O read and write
``b``
Switch between bit/s or Byte/s for network I/O
``B``
View disk I/O counters per second
``c``
Sort processes by CPU usage
``d``
Show/hide disk I/O stats
``D``
Enable/disable Docker stats
``e``
Enable/disable top extended stats
``E``
Erase current process filter
``f``
Show/hide file system and folder monitoring stats
``F``
Switch between file system used and free space
``g``
Generate graphs for current history
``h``
Show/hide the help screen
``i``
Sort processes by I/O rate
``I``
Show/hide IP module
``l``
Show/hide log messages
``m``
Sort processes by MEM usage
``M``
Reset processes summary min/max
``n``
Show/hide network stats
``p``
Sort processes by name
``q|ESC``
Quit the current Glances session
``r``
Reset history
``R``
Show/hide RAID plugin
``s``
Show/hide sensors stats
``t``
Sort process by CPU times (TIME+)
``T``
View network I/O as combination
``u``
Sort processes by USER
``U``
View cumulative network I/O
``w``
Delete finished warning log messages
``x``
Delete finished warning and critical log messages
``z``
Show/hide processes stats
``0``
Enable/disable Irix/Solaris mode
Task's CPU usage will be divided by the total number of CPUs
``1``
Switch between global CPU and per-CPU stats
``2``
Enable/disable left sidebar
``3``
Enable/disable the quick look module
``4``
Enable/disable all but quick look and load module
``5``
Enable/disable top menu (QuickLook, CPU, MEM, SWAP and LOAD)
``/``
Switch between process command line or command name
In the Glances client browser (accessible through the ``--browser``
command line argument):
``ENTER``
Run the selected server
``UP``
Up in the servers list
``DOWN``
Down in the servers list
``q|ESC``
Quit Glances

View File

@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
#
# Glances documentation build configuration file, created by
# sphinx-quickstart on Tue Mar 25 19:57:21 2014.
# sphinx-quickstart on Tue Mar 1 10:53:59 2016.
#
# This file is execfile()d with the current directory set to its containing dir.
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
@ -11,45 +12,36 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import datetime
import sys
import os
from datetime import datetime
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
cwd = os.path.realpath(os.path.dirname(__file__))
project_path = os.path.realpath(os.path.join(cwd, '..', 'glances'))
def get_version():
init_file = os.path.realpath(os.path.join(project_path, '__init__.py'))
f = open(init_file, 'r')
try:
for line in f:
if line.startswith('__version__'):
return line.strip().split(' = ')[1]
else:
raise ValueError("Version string not found")
finally:
f.close()
# Insert Glances' path into the system.
sys.path.insert(0, os.path.abspath('..'))
_version = get_version()
_year = datetime.datetime.now().year
_copyright = u'{0}, Nicolas Hennion'.format(_year)
from glances import __version__
# -- General configuration -----------------------------------------------------
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
@ -59,20 +51,25 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'Glances'
copyright = _copyright
project = 'Glances'
author = 'Nicolas Hennion'
year = datetime.now().year
copyright = '%d, %s' % (year, author)
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = _version
version = __version__
# The full version, including alpha/beta/rc tags.
release = version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
#language = None
# There are two options for replacing |today|: either, you set today to some
@ -85,7 +82,8 @@ release = version
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
@ -105,17 +103,27 @@ pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ---------------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
html_theme_options = {
'github_user': 'nicolargo',
'github_repo': 'glances',
'show_powered_by': False
}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
@ -131,15 +139,20 @@ html_theme = 'default'
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
@ -150,7 +163,14 @@ html_theme = 'default'
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'links.html',
'searchbox.html'
]
}
# Additional templates that should be rendered to pages, maps page names to
# template names.
@ -166,7 +186,7 @@ html_theme = 'default'
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
html_show_sourcelink = False
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
@ -182,11 +202,24 @@ html_theme = 'default'
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
#html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'Glancesdoc'
# -- Options for LaTeX output --------------------------------------------------
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
@ -197,13 +230,17 @@ latex_elements = {
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'Glances.tex', u'Glances Documentation',
u'Nicolas Hennion', 'manual'),
(master_doc, 'Glances.tex', 'Glances Documentation',
'Nicolas Hennion', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@ -227,28 +264,28 @@ latex_documents = [
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'glances', u'Glances Documentation',
[u'Nicolas Hennion'], 1)
('glances', 'glances', 'An eye on your system',
'', 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Glances', u'Glances Documentation',
u'Nicolas Hennion', 'Glances', 'One line description of project.',
'Miscellaneous'),
(master_doc, 'Glances', 'Glances Documentation',
author, 'Glances', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
@ -259,3 +296,6 @@ texinfo_documents = [
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

77
docs/config.rst Normal file
View File

@ -0,0 +1,77 @@
.. _config:
Configuration
=============
No configuration file is mandatory to use Glances.
Furthermore a configuration file is needed to access more settings.
Location
--------
You can put the ``glances.conf`` file in the following locations:
=========== ============================================================
``Linux`` ~/.config/glances, /etc/glances
``*BSD`` ~/.config/glances, /usr/local/etc/glances
``OS X`` ~/Library/Application Support/glances, /usr/local/etc/glances
``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
User-specific options override system-wide options and options given on
the command line override either.
Syntax
------
Glances reads configuration files in the *ini* syntax.
Each plugin and export module can have a section. Below an example for
the CPU plugin:
.. code-block:: ini
[cpu]
user_careful=50
user_warning=70
user_critical=90
iowait_careful=50
iowait_warning=70
iowait_critical=90
system_careful=50
system_warning=70
system_critical=90
steal_careful=50
steal_warning=70
steal_critical=90
Logging
-------
Glances logs all of its internal messages to a log file.
``DEBUG`` messages can been logged using the ``-d`` option on the command
line.
By default, the ``glances.log`` file is under the temporary directory:
===================== ==================================================
``Linux, *BSD, OS X`` /tmp
``Windows`` %APPDATA%\\Local\\temp
===================== ==================================================
If ``glances.log`` is not writable, a new file will be created and
returned to the user console.

File diff suppressed because it is too large Load Diff

View File

@ -1,964 +0,0 @@
=======
Glances
=======
This manual describes *Glances* version 2.5.1.
Copyright © 2011-2015 Nicolas Hennion <nicolas@nicolargo.com>
October, 2015
.. contents:: Table of Contents
Introduction
============
Glances is a cross-platform curses-based system monitoring tool which
aims to present a maximum of information in a minimum of space, ideally
to fit in a classical 80x24 terminal or higher to have additional
information. It can adapt dynamically the displayed information depending
on the terminal size.
Glances can also work in client/server mode. Remote monitoring could be
done via terminal or web interface.
Glances is written in Python and uses the `psutil`_ library to get
information from your system.
Console (80x24)
.. image:: images/screenshot.png
Full view (>80x24)
.. image:: images/screenshot-wide.png
Web interface (Firefox)
.. image:: images/screenshot-web.png
Usage
=====
Standalone Mode
---------------
Simply run:
.. code-block:: console
$ glances
Client/Server Mode
------------------
If you want to remotely monitor a machine, called ``server``, from
another one, called ``client``, just run on the server:
.. code-block:: console
server$ glances -s
and on the client:
.. code-block:: console
client$ glances -c @server
where ``@server`` is the IP address or hostname of the server.
Glances can centralize available Glances servers using the ``--browser``
option. The server list can be statically defined in the Glances
configuration file (section ``[serverlist]``).
Glances can also detect and display all Glances servers available on your
network (auto-discover mode is based on the the ``zeroconf`` protocol,
which is only available on GNU/Linux and OS X):
.. code-block:: console
client$ glances --browser
It is possible to disable the auto discover mode ``--disable-autodiscover``.
In server mode, you can set the bind address ``-B ADDRESS`` and listening
TCP port ``-p PORT``.
In client mode, you can set the TCP port of the server ``-p PORT``.
You can set a password to access to the server ``--password``.
Default binding address is ``0.0.0.0`` (Glances will listen on all the
available network interfaces) and TCP port is ``61209``.
In client/server mode, limits are set by the server side.
Glances is ``IPv6`` compatible. Just use the ``-B ::`` option to bind to
all IPv6 addresses.
As an experimental feature, if Glances server is not detected by the
client, the latter will try to grab stats using the ``SNMP`` protocol:
.. code-block:: console
client$ glances -c @snmpserver
*Note*: stats grabbed by SNMP request are limited (OS dependent).
Web Server Mode
---------------
If you want to remotely monitor a machine, called ``server``, from any
device with a web browser, just run the server with the ``-w`` option:
.. code-block:: console
server$ glances -w
and on the client enter the following URL in your favorite web browser:
::
http://@server:61208
where ``@server`` is the IP address or hostname of the server.
To change the refresh rate of the page, just add the period in seconds
at the end of the URL. For example, to refresh the page every 10s:
::
http://@server:61208/10
The Glances web interface follows responsive web design principles.
Screenshot from Chrome on Android
.. image:: images/screenshot-web2.png
Command Reference
=================
Command-Line Options
--------------------
-h, --help show this help message and exit
-V, --version show program's version number and exit
-d, --debug enable debug mode
-C CONF_FILE, --config CONF_FILE
path to the configuration file
-3, --disable-quicklook
disable quick look module
-4, --full-quicklook
enable all but quick look and load
--disable-cpu disable CPU module
--disable-mem disable MEM module
--disable-swap disable SWAP module
--disable-load disable LOAD module
--disable-network disable network module
--disable-ip disable IP module
--disable-diskio disable disk I/O module
--disable-fs disable file system module
--disable-sensors disable sensors module
--disable-hddtemp disable hddtemp module
--disable-raid disable RAID module
--disable-docker disable Docker module
-2, --disable-left-sidebar
disable network, disk I/O, file system and
sensors modules (py3sensors needed)
--disable-process disable process module
--disable-log disable log module
--disable-bold disable bold mode in the terminal
--enable-process-extended
enable extended stats on top process
--enable-history enable the history mode (matplotlib needed)
--path-history PATH_HISTORY
set the export path for graph history
--export-csv EXPORT_CSV
export stats to a CSV file
--export-influxdb export stats to an InfluxDB server (influxdb needed)
--export-opentsdb export stats to an OpenTSDB server (potsdb needed)
--export-statsd export stats to a StatsD server (statsd needed)
--export-rabbitmq export stats to a RabbitMQ server (pika needed)
-c CLIENT, --client CLIENT
connect to a Glances server by IPv4/IPv6 address or
hostname
-s, --server run Glances in server mode
--browser start the client browser (list of Glances servers)
--disable-autodiscover
disable autodiscover feature
-p PORT, --port PORT define the client/server TCP port [default: 61209]
-B BIND_ADDRESS, --bind BIND_ADDRESS
bind server to the given IPv4/IPv6 address or hostname
--password define a client/server password
--snmp-community SNMP_COMMUNITY
SNMP community
--snmp-port SNMP_PORT
SNMP port
--snmp-version SNMP_VERSION
SNMP version (1, 2c or 3)
--snmp-user SNMP_USER
SNMP username (only for SNMPv3)
--snmp-auth SNMP_AUTH
SNMP authentication key (only for SNMPv3)
--snmp-force force SNMP mode
-t TIME, --time TIME set refresh time in seconds [default: 3 sec]
-w, --webserver run Glances in web server mode (bottle needed)
-q, --quiet do not display the curses interface
-f PROCESS_FILTER, --process-filter PROCESS_FILTER
set the process filter pattern (regular expression)
--process-short-name force short name for processes name
--disable-irix Task's cpu usage will be divided by the total number of CPUs
--hide-kernel-threads
hide kernel threads in process list
--tree display processes as a tree
-b, --byte display network rate in byte per second
--fahrenheit display temperature in Fahrenheit (default is Celsius)
-1, --percpu start Glances in per CPU mode
--fs-free-space display file system free space instead of used
--theme-white optimize display colors for white background
Interactive Commands
--------------------
The following commands (key pressed) are supported while in Glances:
``ENTER``
Set the process filter
Note: On Mac OS, please use CTRL-H to delete filter
Filter is a regular expression pattern:
- gnome: all processes starting with the gnome string
- .*gnome.*: all processes containing the gnome string
``a``
Sort process list automatically
- If CPU iowait ``>60%``, sort processes by I/O read and write
- If CPU ``>70%``, sort processes by CPU usage
- If MEM ``>70%``, sort processes by memory usage
``b``
Switch between bit/s or Byte/s for network I/O
``c``
Sort processes by CPU usage
``d``
Show/hide disk I/O stats
``e``
Enable/disable top extended stats
``f``
Show/hide file system stats
``F``
Switch between file system used and free space
``g``
Generate graphs for current history
``h``
Show/hide the help screen
``i``
Sort processes by I/O rate
``l``
Show/hide log messages
``m``
Sort processes by MEM usage
``n``
Show/hide network stats
``p``
Sort processes by name
``q`` or ``ESC``
Quit the current Glances session
``r``
Reset history
``s``
Show/hide sensors stats
``t``
Sort process by CPU times (TIME+)
``T``
View network I/O as combination
``u``
Sort processes by USER
``U``
View cumulative network I/O
``w``
Delete finished warning log messages
``x``
Delete finished warning and critical log messages
``z``
Show/hide processes stats
``0``
Task's cpu usage will be divided by the total number of CPUs
``1``
Switch between global CPU and per-CPU stats
``2``
Enable/disable left sidebar
``3``
Enable/disable the quick look module
``4``
Enable/disable all but quick look and load module
``/``
Switch between short name / command line (processes name)
In the Glances client browser (accessible through the ``--browser``
command line argument):
``ENTER``
Run Glances client to the selected server
``UP``
Up in the servers list
``DOWN``
Down in the servers list
``q`` or ``ESC``
Quit Glances
Configuration
=============
No configuration file is mandatory to use Glances.
Furthermore a configuration file is needed to modify limit alerts, to
set up monitored processes list, to hide disks or network interfaces or
to define alias.
Location
--------
You can put the configuration file ``glances.conf`` in the following
locations:
:Linux: ``~/.config/glances, /etc/glances``
:\*BSD: ``~/.config/glances, /usr/local/etc/glances``
:OS X: ``~/Library/Application Support/glances, /usr/local/etc/glances``
: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
User-specific options override system-wide options and options given on
the command line override either.
Syntax
------
Each plugin and export module can have a section.
Example for the CPU plugin:
.. code-block::
[cpu]
user_careful=50
user_warning=70
user_critical=90
iowait_careful=50
iowait_warning=70
iowait_critical=90
system_careful=50
system_warning=70
system_critical=90
steal_careful=50
steal_warning=70
steal_critical=90
By default the ``steal`` CPU time alerts aren't logged. If you want to
enable log/alert, just add:
.. code-block::
steal_log=True
Logs and debug mode
===================
Glances logs all its internal messages to a log file. By default, only
INFO & WARNING & ERROR &CRITICAL levels are logged, but DEBUG messages
can ben logged using the -d option on the command line.
By default, the log file is under:
:Linux, \*BSD, OS X: ``/tmp/glances.log``
:Windows: ``%APPDATA%\Local\temp\glances.log``
If ``glances.log`` is not writable, a new file will be created and
returned to the user console.
Anatomy Of The Application
==========================
Legend
------
| ``GREEN`` stat counter is ``"OK"``
| ``BLUE`` stat counter is ``"CAREFUL"``
| ``MAGENTA`` stat counter is ``"WARNING"``
| ``RED`` stat counter is ``"CRITICAL"``
*Note*: only stats with colored background will be logged in the alert
view.
Header
------
.. image:: images/header.png
The header shows the hostname, OS name, release version, platform
architecture and system uptime (on the upper right corner).
Additionally, on GNU/Linux, it also shows the kernel version.
In client mode, the server connection status is displayed.
Connected:
.. image:: images/connected.png
Disconnected:
.. image:: images/disconnected.png
QuickLook
---------
The ``quicklook`` plugin is only displayed on wide screen and propose a
bar view for CPU and memory (virtual and swap).
.. image:: images/quicklook.png
If the per CPU mode is on (click '1'):
.. image:: images/quicklook-percpu.png
*Note*: limit values can be overwritten in the configuration file under
the ``[quicklook]`` section.
CPU
---
Short view:
.. image:: images/cpu.png
If enough horizontal space is available, extended CPU information are
displayed.
Extended view:
.. image:: images/cpu-wide.png
To switch to per-CPU stats, just hit the ``1`` key:
.. image:: images/per-cpu.png
The CPU stats are shown as a percentage and for the configured refresh
time. The total CPU usage is displayed on the first line.
| If user|system CPU is ``<50%``, then status is set to ``"OK"``
| If user|system CPU is ``>50%``, then status is set to ``"CAREFUL"``
| If user|system CPU is ``>70%``, then status is set to ``"WARNING"``
| If user|system CPU is ``>90%``, then status is set to ``"CRITICAL"``
*Note*: limit values can be overwritten in the configuration file under
the ``[cpu]`` and/or ``[percpu]`` sections.
Load
----
.. image:: images/load.png
On the *No Sheep* blog, *Zachary Tirrell* defines the load average [1]_:
"In short it is the average sum of the number of processes
waiting in the run-queue plus the number currently executing
over 1, 5, and 15 minutes time periods."
Glances gets the number of CPU core to adapt the alerts.
Alerts on load average are only set on 15 minutes time period.
The first line also displays the number of CPU core.
| If load average is ``<0.7*core``, then status is set to ``"OK"``
| If load average is ``>0.7*core``, then status is set to ``"CAREFUL"``
| If load average is ``>1*core``, then status is set to ``"WARNING"``
| If load average is ``>5*core``, then status is set to ``"CRITICAL"``
*Note*: limit values can be overwritten in the configuration file under
the ``[load]`` section.
Memory
------
Glances uses two columns: one for the ``RAM`` and one for the ``SWAP``.
.. image:: images/mem.png
If enough space is available, Glances displays extended information for
the ``RAM``:
.. image:: images/mem-wide.png
Alerts are only set for used memory and used swap.
| If used memory|swap is ``<50%``, then status is set to ``"OK"``
| If used memory|swap is ``>50%``, then status is set to ``"CAREFUL"``
| If used memory|swap is ``>70%``, then status is set to ``"WARNING"``
| If used memory|swap is ``>90%``, then status is set to ``"CRITICAL"``
*Note*: limit values can be overwritten in the configuration file under
the ``[memory]`` and/or ``[memswap]`` sections.
Network
-------
.. image:: images/network.png
Glances displays the network interface bit rate. The unit is adapted
dynamically (bits per second, kbits per second, Mbits per second, etc).
Alerts are only set if the maximum speed per network interface is available
(see sample in the configuration file).
*Note*: it is possibile to define a list of network interfaces to hide
and per-interface limit values in the ``[network]`` section of the
configuration file and aliases for interface name.
Disk I/O
--------
.. image:: images/diskio.png
Glances displays the disk I/O throughput. The unit is adapted dynamically.
There is no alert on this information.
*Note*: it is possible to define a list of disks to hide under the
``[diskio]`` section in the configuration file and aliases for disk name.
File System
-----------
.. image:: images/fs.png
Glances displays the used and total file system disk space. The unit is
adapted dynamically.
Alerts are set for used disk space.
| If used disk is ``<50%``, then status is set to ``"OK"``
| If used disk is ``>50%``, then status is set to ``"CAREFUL"``
| If used disk is ``>70%``, then status is set to ``"WARNING"``
| If used disk is ``>90%``, then status is set to ``"CRITICAL"``
*Note*: limit values can be overwritten in the configuration file under
the ``[filesystem]`` section.
If a RAID controller is detected on you system, its status will be displayed:
.. image:: images/raid.png
By default, the plugin only displays physical devices (hard disks, USB
keys) and ignore all others. To allow others FS type, you have to use the
following section in the configuration file:
::
[fs]
allow=zfs,misc
Sensors
-------
Glances can displays the sensors information using `lm-sensors`,
`hddtemp` and `batinfo` [2]_.
All of the above libraries are available only on Linux.
As of lm-sensors, a filter is being applied in order to display
temperature only.
.. image:: images/sensors.png
There is no alert on this information.
*Note*: limit values and sensors alias names can be defined in the
configuration file under the ``[sensors]`` section.
Processes List
--------------
Compact view:
.. image:: images/processlist.png
Full view:
.. image:: images/processlist-wide.png
Filtered view:
.. image:: images/processlist-filter.png
Three views are available for processes:
* Processes summary
* Optional monitored processes list (see below)
* Processes list
The processes summary line display:
* Tasks number (total number of processes)
* Threads number
* Running tasks number
* Sleeping tasks number
* Other tasks number (not running or sleeping)
* Sort key
By default, or if you hit the ``a`` key, the processes list is
automatically sorted by:
* ``CPU`` if there is no alert (default behavior)
* ``CPU`` if a CPU or LOAD alert is detected
* ``MEM`` if a memory alert is detected
* ``Disk I/O`` if a CPU iowait alert is detected
The number of processes in the list is adapted to the screen size.
``CPU%``
% of CPU used by the process
If IRIX mode is off (aka Solaris mode), the value is divided by logical core number
``MEM%``
% of MEM used by the process
``VIRT``
Total program size - Virtual Memory Size (VMS)
``RES``
Resident Set Size (RSS)
``PID``
Process ID
``USER``
User ID
``NI``
Nice level of the process (niceness other than 0 is highlighted)
``S``
Process status (running process is highlighted)
``TIME+``
Cumulative CPU time used
``IOR/s``
Per process I/O read rate (in Byte/s)
``IOW/s``
Per process I/O write rate (in Byte/s)
``COMMAND``
Process command line
User cans switch to the process name by pressing on the ``/`` key
Process status legend:
``R``
Running
``S``
Sleeping (may be interrupted)
``D``
Disk sleep (may not be interrupted)
``T``
Traced / Stopped
``Z``
Zombie
In standalone mode, additional informations are provided for the top
process:
.. image:: images/processlist-top.png
* CPU affinity (number of cores used by the process)
* Extended memory information (swap, shared, text, lib, data and dirty on Linux)
* Open threads, files and network sessions (TCP and UDP)
* IO nice level
The extended stats feature could be enabled using the ``--enable-process-extended``
option (command line) or the ``e`` key (curses interface).
*Note*: limit values can be overwritten in the configuration file under
the ``[process]`` section.
Monitored Processes List
------------------------
The monitored processes list allows user, through the configuration file,
to group processes and quickly show if the number of running processes is
not good.
.. image:: images/monitored.png
Each item is defined by:
* ``description``: description of the processes (max 16 chars).
* ``regex``: regular expression of the processes to monitor.
* ``command`` (optional): full path to shell command/script for extended
stat. Should return a single line string. Use with caution.
* ``countmin`` (optional): minimal number of processes. A warning will
be displayed if number of processes < count.
* ``countmax`` (optional): maximum number of processes. A warning will
be displayed if number of processes > count.
Up to 10 items can be defined.
For example, if you want to monitor the Nginx processes on a Web server,
the following definition should do the job:
::
[monitor]
list_1_description=Nginx server
list_1_regex=.*nginx.*
list_1_command=nginx -v
list_1_countmin=1
list_1_countmax=4
If you also want to monitor the PHP-FPM daemon processes, you should add
another item:
::
[monitor]
list_1_description=Nginx server
list_1_regex=.*nginx.*
list_1_command=nginx -v
list_1_countmin=1
list_1_countmax=4
list_2_description=PHP-FPM
list_2_regex=.*php-fpm.*
list_2_countmin=1
list_2_countmax=20
In client/server mode, the list is defined on the server side.
A new method, called `getAllMonitored`, is available in the APIs and
get the JSON representation of the monitored processes list.
Alerts are set as following:
| If number of processes is 0, then status is set to ``"CRITICAL"``
| If number of processes is min < current < max, then status is set to ``"OK"``
| Else status is set to ``"WARNING"``
Logs
----
.. image:: images/logs.png
A log messages list is displayed in the bottom of the screen if (and
only if):
- at least one ``WARNING`` or ``CRITICAL`` alert was occurred
- space is available in the bottom of the console/terminal
Each alert message displays the following information:
1. start datetime
2. duration if alert is terminated or `ongoing` if the alert is still in
progress
3. alert name
4. {min,avg,max} values or number of running processes for monitored
processes list alerts
Docker
------
If you use ``Docker``, Glances can help you to monitor your container.
Glances uses the Docker API through the ``docker-py`` library.
.. image:: images/docker.png
Actions
-------
Glances can trigger actions on events.
By ``action``, we mean all shell command line. For example, if you want
to execute the ``foo.py`` script if the last 5 minutes load are critical
then add the action line to the Glances configuration file:
.. code-block::
[load]
critical=5.0
critical_action=python /path/to/foo.py
All the stats are available in the command line through the use of the
``{{mustache}}`` syntax. Another example would be to create a log file
containing used vs total disk space if a space trigger warning is reached:
.. code-block::
[fs]
warning=70
warning_action=echo {{mnt_point}} {{used}}/{{size}} > /tmp/fs.alert
*Note*: you can use all the stats for the current plugin (see
https://github.com/nicolargo/glances/wiki/The-Glances-2.x-API-How-to for
the stats list)
Gateway to others services
==========================
CSV
---
It is possible to export statistics to CSV file.
.. code-block:: console
$ glances --export-csv /tmp/glances.csv
CSV file description:
- Stats description (first line)
- Stats (others lines)
InfluxDB
--------
You can export statistics to an ``InfluxDB`` server (time series server).
The connection should be defined in the Glances configuration file as
following:
.. code-block::
[influxdb]
host=localhost
port=8086
user=root
password=root
db=glances
and run Glances with:
.. code-block:: console
$ glances --export-influxdb
InfluxDB 0.9.x or higher also supports an optional tags
configuration parameter specified as comma separated, key:value pairs.
For example:
.. code-block::
[influxdb]
host=localhost
port=8086
user=root
password=root
db=glances
tags=foo:bar,spam:eggs
For Grafana users, Glances provides a dedicated `dashboard`_. Just import
the file in your ``Grafana`` web interface.
.. image:: images/grafana.png
OpenTSDB
--------
You can export statistics to an ``OpenTSDB`` server (time series server).
The connection should be defined in the Glances configuration file as
following:
.. code-block::
[opentsdb]
host=localhost
port=4242
prefix=glances
tags=foo:bar,spam:eggs
and run Glances with:
.. code-block:: console
$ glances --export-opentsdb
Statsd
------
You can export statistics to a ``Statsd`` server (welcome to Graphite!).
The connection should be defined in the Glances configuration file as
following:
.. code-block::
[statsd]
host=localhost
port=8125
prefix=glances
*Note*: the prefix option is optional ('glances by default')
and run Glances with:
.. code-block:: console
$ glances --export-statsd
Glances will generate stats as:
.. code-block::
'glances.cpu.user': 12.5,
'glances.cpu.total': 14.9,
'glances.load.cpucore': 4,
'glances.load.min1': 0.19,
...
RabbitMQ
--------
You can export statistics to an ``RabbitMQ`` server (AMQP Broker).
The connection should be defined in the Glances configuration file as
following:
.. code-block::
[rabbitmq]
host=localhost
port=5672
user=glances
password=glances
queue=glances_queue
and run Glances with:
.. code-block:: console
$ glances --export-rabbitmq
APIs documentation
==================
Glances includes a `XML-RPC server`_ and a `RESTFUL-JSON`_ API which can
be used by another client software.
APIs documentation is available at:
- XML-RPC: https://github.com/nicolargo/glances/wiki/The-Glances-2.x-API-How-to
- RESTFUL-JSON: https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API
Support
=======
To post a question about Glances use cases, please post it to the
official Q&A `forum`_.
To report a bug or a feature request use the bug tracking system at
https://github.com/nicolargo/glances/issues.
Feel free to contribute !
.. [1] http://nosheep.net/story/defining-unix-load-average/
.. [2] https://github.com/nicolargo/batinfo
.. _psutil: https://code.google.com/p/psutil/
.. _XML-RPC server: http://docs.python.org/2/library/simplexmlrpcserver.html
.. _RESTFUL-JSON: http://jsonapi.org/
.. _forum: https://groups.google.com/forum/?hl=en#!forum/glances-users
.. _dashboard: https://github.com/nicolargo/glances/blob/master/conf/glances-grafana.json

68
docs/glances.rst Normal file
View File

@ -0,0 +1,68 @@
:orphan:
glances
=======
SYNOPSIS
--------
**glances** [OPTIONS]
DESCRIPTION
-----------
**glances** is a cross-platform curses-based monitoring tool which aims
to present a maximum of information in a minimum of space, ideally to
fit in a classical 80x24 terminal or higher to have additional
information. It can adapt dynamically the displayed information
depending on the terminal size. It can also work in client/server mode.
Remote monitoring could be done via terminal or web interface.
**glances** is written in Python and uses the *psutil* library to get
information from your system.
OPTIONS
-------
.. include:: cmds.rst
EXAMPLES
--------
Monitor local machine (standalone mode):
$ glances
Monitor local machine with the web interface (Web UI):
$ glances -w
Monitor local machine and export stats to a CSV file:
$ glances --export-csv
Monitor local machine and export stats to a InfluxDB server with 5s
refresh time:
$ 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 to a Glances server and export stats to a StatsD server:
$ glances -c <ip_server> --export-statsd
Start the client browser (browser mode):
$ glances --browser
AUTHOR
------
Nicolas Hennion aka Nicolargo <contact@nicolargo.com>

15
docs/gw/csv.rst Normal file
View File

@ -0,0 +1,15 @@
.. _csv:
CSV
===
It's possible to export stats to a CSV file.
.. code-block:: console
$ glances --export-csv /tmp/glances.csv
CSV file description:
- Stats description (first line)
- Stats (other lines)

38
docs/gw/elastic.rst Normal file
View File

@ -0,0 +1,38 @@
.. _elastic:
Elasticsearch
=============
You can export statistics to an ``elasticsearch`` server. The connection
should be defined in the Glances configuration file as following:
.. code-block:: ini
[elasticsearch]
host=localhost
port=9200
index=glances
and run Glances with:
.. code-block:: console
$ glances --export-elasticsearch
The stats are available through the elasticsearch API. For example, to
get the CPU system stats:
.. code-block:: console
$ curl http://172.17.0.2:9200/glances/cpu/system
{
"_index": "glances",
"_type": "cpu",
"_id": "system",
"_version": 28,
"found": true,"
_source": {
"timestamp": "2016-02-04T14:11:02.362232",
"value": "2.2"
}
}

17
docs/gw/index.rst Normal file
View File

@ -0,0 +1,17 @@
.. _gw:
Gateway To Other Services
=========================
Glances can exports stats to a CSV file. Also, it can act as a gateway
to providing stats to multiple services.
.. toctree::
:maxdepth: 2
csv
influxdb
opentsdb
statsd
rabbitmq
elastic

46
docs/gw/influxdb.rst Normal file
View File

@ -0,0 +1,46 @@
.. _influxdb:
InfluxDB
========
You can export statistics to an ``InfluxDB`` server (time series server).
The connection should be defined in the Glances configuration file as
following:
.. code-block:: ini
[influxdb]
host=localhost
port=8086
user=root
password=root
db=glances
and run Glances with:
.. code-block:: console
$ glances --export-influxdb
InfluxDB 0.9 or higher also supports an optional ``tags`` configuration
parameter specified as comma separated ``key:value`` pairs. For example:
.. code-block:: ini
[influxdb]
host=localhost
port=8086
user=root
password=root
db=glances
tags=foo:bar,spam:eggs
Grafana
-------
For Grafana users, Glances provides a dedicated `dashboard`_. To use it,
just import the file in your ``Grafana`` web interface.
.. image:: ../_static/grafana.png
.. _dashboard: https://github.com/nicolargo/glances/blob/master/conf/glances-grafana.json

22
docs/gw/opentsdb.rst Normal file
View File

@ -0,0 +1,22 @@
.. _opentsdb:
OpenTSDB
========
You can export statistics to an ``OpenTSDB`` server (time series server).
The connection should be defined in the Glances configuration file as
following:
.. code-block:: ini
[opentsdb]
host=localhost
port=4242
prefix=glances
tags=foo:bar,spam:eggs
and run Glances with:
.. code-block:: console
$ glances --export-opentsdb

23
docs/gw/rabbitmq.rst Normal file
View File

@ -0,0 +1,23 @@
.. _rabbitmq:
RabbitMQ
========
You can export statistics to an ``RabbitMQ`` server (AMQP Broker). The
connection should be defined in the Glances configuration file as
following:
.. code-block:: ini
[rabbitmq]
host=localhost
port=5672
user=glances
password=glances
queue=glances_queue
and run Glances with:
.. code-block:: console
$ glances --export-rabbitmq

33
docs/gw/statsd.rst Normal file
View File

@ -0,0 +1,33 @@
.. _statsd:
StatsD
======
You can export statistics to a ``StatsD`` server (welcome to Graphite!).
The connection should be defined in the Glances configuration file as
following:
.. code-block:: ini
[statsd]
host=localhost
port=8125
prefix=glances
.. note:: The ``prefix`` is optional (``glances`` by default)
and run Glances with:
.. code-block:: console
$ glances --export-statsd
Glances will generate stats as:
::
'glances.cpu.user': 12.5,
'glances.cpu.total': 14.9,
'glances.load.cpucore': 4,
'glances.load.min1': 0.19,
...

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 622 KiB

View File

@ -1,28 +1,30 @@
Welcome to Glances documentation!
=================================
Glances
=======
**Glances** is a cross-platform curses-based monitoring tool written in Python.
.. image:: _static/screenshot-wide.png
It uses the psutil library and some internal code to get information from your system.
Glances is a cross-platform curses-based monitoring tool which aims to
present a maximum of information in a minimum of space, ideally to fit
in a classical 80x24 terminal or higher to have additional information.
It can adapt dynamically the displayed information depending on the
terminal size. It can also work in client/server mode. Remote monitoring
could be done via terminal or web interface.
.. image:: images/screenshot-wide.png
Glances is written in Python and uses the `psutil`_ library to get
information from your system.
Get the code
------------
.. _psutil: https://github.com/giampaolo/psutil
The `source <http://github.com/nicolargo/glances>`_ is available on GitHub.
Contents
--------
Table of Contents
=================
.. toctree::
:maxdepth: 2
glances-doc
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
quickstart
cmds
config
aoa/index
gw/index
api
support

View File

@ -1,131 +0,0 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: glances
# Required-Start: $remote_fs $local_fs $network
# Required-Stop: $remote_fs $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts and daemonize Glances server
# Description: Starts and daemonize Glances server
### END INIT INFO
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Glances server"
NAME=glances
USER=$NAME
DAEMON="/usr/bin/$NAME"
PIDFILE="/run/$NAME/$NAME.pid"
CONF="/etc/glances/glances.conf"
DAEMON_ARGS="-C $CONF -s"
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
# Ensure /run/glances is there, cf. Debian policy 9.4.1
# http://www.debian.org/doc/debian-policy/ch-opersys.html#s-fhs-run
if [ ! -d "$(dirname $PIDFILE)" ]; then
mkdir "$(dirname $PIDFILE)"
chown $USER:$USER "$(dirname $PIDFILE)"
chmod 755 "$(dirname $PIDFILE)"
fi
#
# Function that starts the daemon/service
#
do_start()
{
log_daemon_msg "Starting $DESC" "$NAME "
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
[ -e $PIDFILE ] && PID=$(cat "$PIDFILE")
if ( [ -e $PIDFILE ] && ps -p $PID 1>&2 > /dev/null )
then
log_action_end_msg 1 "already running, PID's $PID"
exit 0
elif ( [ -w $PIDFILE ] )
then
log_warning_msg "PID file found while ${NAME} is not running, removing file."
rm $PIDFILE
fi
if [ "$RUN" != "true" ]; then
log_action_msg "Not starting glances: disabled by /etc/default/$NAME".
exit 0
fi
start-stop-daemon --start --chuid $USER --pidfile=$PIDFILE --quiet -m -b --exec $DAEMON -- $DAEMON_ARGS || return 2
[ -e "$PIDFILE" ] && chown $USER $PIDFILE
return 0
}
#
# Function that stops the daemon/service
#
do_stop()
{
log_daemon_msg "Stopping $DESC" "$NAME "
if [ ! -w $PIDFILE ]
then
log_warning_msg "PID file not found"
return 4
fi
start-stop-daemon --stop --oknodo --chuid $USER --pidfile=$PID --user=$USER --pidfile="$PIDFILE" --retry=30 || return 1
/bin/rm -f $PIDFILE
return 0
}
case "$1" in
start)
do_start
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
stop)
do_stop
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;;
esac
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME"
;;
restart|force-reload)
do_stop
case "$?" in
0)
log_end_msg 0
do_start
case "$?" in
0) log_end_msg 0 ;;
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: invoke-rc.d $NAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac

263
docs/make.bat Normal file
View File

@ -0,0 +1,263 @@
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=_build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
set I18NSPHINXOPTS=%SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. xml to make Docutils-native XML files
echo. pseudoxml to make pseudoxml-XML files for display purposes
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
echo. coverage to run coverage check of the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
REM Check if sphinx-build is available and fallback to Python version if any
%SPHINXBUILD% 1>NUL 2>NUL
if errorlevel 9009 goto sphinx_python
goto sphinx_ok
:sphinx_python
set SPHINXBUILD=python -m sphinx.__init__
%SPHINXBUILD% 2> nul
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
:sphinx_ok
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Glances.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Glances.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdf" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdfja" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf-ja
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
if "%1" == "coverage" (
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
if errorlevel 1 exit /b 1
echo.
echo.Testing of coverage in the sources finished, look at the ^
results in %BUILDDIR%/coverage/python.txt.
goto end
)
if "%1" == "xml" (
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The XML files are in %BUILDDIR%/xml.
goto end
)
if "%1" == "pseudoxml" (
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
goto end
)
:end

588
docs/man/glances.1 Normal file
View File

@ -0,0 +1,588 @@
.\" Man page generated from reStructuredText.
.
.TH "GLANCES" "1" "March 16, 2016" "2.6" "Glances"
.SH NAME
glances \- An eye on your system
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.SH SYNOPSIS
.sp
\fBglances\fP [OPTIONS]
.SH DESCRIPTION
.sp
\fBglances\fP is a cross\-platform curses\-based monitoring tool which aims
to present a maximum of information in a minimum of space, ideally to
fit in a classical 80x24 terminal or higher to have additional
information. It can adapt dynamically the displayed information
depending on the terminal size. It can also work in client/server mode.
Remote monitoring could be done via terminal or web interface.
.sp
\fBglances\fP is written in Python and uses the \fIpsutil\fP library to get
information from your system.
.SH OPTIONS
.SH COMMAND-LINE OPTIONS
.INDENT 0.0
.TP
.B \-h, \-\-help
show this help message and exit
.UNINDENT
.INDENT 0.0
.TP
.B \-V, \-\-version
show program\(aqs version number and exit
.UNINDENT
.INDENT 0.0
.TP
.B \-d, \-\-debug
enable debug mode
.UNINDENT
.INDENT 0.0
.TP
.B \-C CONF_FILE, \-\-config CONF_FILE
path to the configuration file
.UNINDENT
.INDENT 0.0
.TP
.B \-3, \-\-disable\-quicklook
disable quick look module
.UNINDENT
.INDENT 0.0
.TP
.B \-4, \-\-full\-quicklook
disable all but quick look and load
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-cpu
disable CPU module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-mem
disable memory module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-swap
disable swap module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-load
disable load module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-network
disable network module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-ip
disable IP module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-diskio
disable disk I/O module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-fs
disable filesystem module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-folder
disable folder module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-sensors
disable sensors module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-hddtemp
disable HD temperature module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-raid
disable RAID module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-docker
disable Docker module
.UNINDENT
.INDENT 0.0
.TP
.B \-5, \-\-disable\-top
disable top menu (QuickLook, CPU, MEM, SWAP and LOAD)
.UNINDENT
.INDENT 0.0
.TP
.B \-2, \-\-disable\-left\-sidebar
disable network, disk I/O, FS and sensors modules (py3sensors lib
needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-process
disable process module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-log
disable log module
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-bold
disable bold mode in the terminal
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-bg
disable background colors in the terminal
.UNINDENT
.INDENT 0.0
.TP
.B \-\-enable\-process\-extended
enable extended stats on top process
.UNINDENT
.INDENT 0.0
.TP
.B \-\-enable\-history
enable the history mode (matplotlib lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-path\-history PATH_HISTORY
set the export path for graph history
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-csv EXPORT_CSV
export stats to a CSV file
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-influxdb
export stats to an InfluxDB server (influxdb lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-opentsdb
export stats to an OpenTSDB server (potsdb lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-statsd
export stats to a StatsD server (statsd lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-rabbitmq
export stats to RabbitMQ broker (pika lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export\-elasticsearch
export stats to an Elasticsearch server (elasticsearch lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-c CLIENT, \-\-client CLIENT
connect to a Glances server by IPv4/IPv6 address or hostname
.UNINDENT
.INDENT 0.0
.TP
.B \-s, \-\-server
run Glances in server mode
.UNINDENT
.INDENT 0.0
.TP
.B \-\-browser
start the client browser (list of servers)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-disable\-autodiscover
disable autodiscover feature
.UNINDENT
.INDENT 0.0
.TP
.B \-p PORT, \-\-port PORT
define the client/server TCP port [default: 61209]
.UNINDENT
.INDENT 0.0
.TP
.B \-B BIND_ADDRESS, \-\-bind BIND_ADDRESS
bind server to the given IPv4/IPv6 address or hostname
.UNINDENT
.INDENT 0.0
.TP
.B \-\-username
define a client/server username
.UNINDENT
.INDENT 0.0
.TP
.B \-\-password
define a client/server password
.UNINDENT
.INDENT 0.0
.TP
.B \-\-snmp\-community SNMP_COMMUNITY
SNMP community
.UNINDENT
.INDENT 0.0
.TP
.B \-\-snmp\-port SNMP_PORT
SNMP port
.UNINDENT
.INDENT 0.0
.TP
.B \-\-snmp\-version SNMP_VERSION
SNMP version (1, 2c or 3)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-snmp\-user SNMP_USER
SNMP username (only for SNMPv3)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-snmp\-auth SNMP_AUTH
SNMP authentication key (only for SNMPv3)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-snmp\-force
force SNMP mode
.UNINDENT
.INDENT 0.0
.TP
.B \-t TIME, \-\-time TIME
set refresh time in seconds [default: 3 sec]
.UNINDENT
.INDENT 0.0
.TP
.B \-w, \-\-webserver
run Glances in web server mode (bottle lib needed)
.UNINDENT
.INDENT 0.0
.TP
.B \-q, \-\-quiet
do not display the curses interface
.UNINDENT
.INDENT 0.0
.TP
.B \-f PROCESS_FILTER, \-\-process\-filter PROCESS_FILTER
set the process filter pattern (regular expression)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-process\-short\-name
force short name for processes name
.UNINDENT
.INDENT 0.0
.TP
.B \-0, \-\-disable\-irix
task\(aqs CPU usage will be divided by the total number of CPUs
.UNINDENT
.INDENT 0.0
.TP
.B \-\-hide\-kernel\-threads
hide kernel threads in process list
.UNINDENT
.INDENT 0.0
.TP
.B \-\-tree
display processes as a tree
.UNINDENT
.INDENT 0.0
.TP
.B \-b, \-\-byte
display network rate in byte per second
.UNINDENT
.INDENT 0.0
.TP
.B \-\-diskio\-show\-ramfs
show RAM FS in the DiskIO plugin
.UNINDENT
.INDENT 0.0
.TP
.B \-\-diskio\-iops
show I/O per second in the DiskIO plugin
.UNINDENT
.INDENT 0.0
.TP
.B \-\-fahrenheit
display temperature in Fahrenheit (default is Celsius)
.UNINDENT
.INDENT 0.0
.TP
.B \-1, \-\-percpu
start Glances in per CPU mode
.UNINDENT
.INDENT 0.0
.TP
.B \-\-fs\-free\-space
display FS free space instead of used
.UNINDENT
.INDENT 0.0
.TP
.B \-\-theme\-white
optimize display colors for white background
.UNINDENT
.SH INTERACTIVE COMMANDS
.sp
The following commands (key pressed) are supported while in Glances:
.INDENT 0.0
.TP
.B \fBENTER\fP
Set the process filter
.sp
\fBNote\fP: on OS X, please use \fBCTRL\-H\fP to delete
filter.
.sp
Filter is a regular expression pattern:
.INDENT 7.0
.IP \(bu 2
\fBgnome\fP: matches all processes starting with the \fBgnome\fP
string
.IP \(bu 2
\fB\&.*gnome.*\fP: matches all processes containing the \fBgnome\fP
string
.UNINDENT
.TP
.B \fBa\fP
Sort process list automatically
.INDENT 7.0
.IP \(bu 2
If CPU \fB>70%\fP, sort processes by CPU usage
.IP \(bu 2
If MEM \fB>70%\fP, sort processes by MEM usage
.IP \(bu 2
If CPU iowait \fB>60%\fP, sort processes by I/O read and write
.UNINDENT
.TP
.B \fBb\fP
Switch between bit/s or Byte/s for network I/O
.TP
.B \fBB\fP
View disk I/O counters per second
.TP
.B \fBc\fP
Sort processes by CPU usage
.TP
.B \fBd\fP
Show/hide disk I/O stats
.TP
.B \fBD\fP
Enable/disable Docker stats
.TP
.B \fBe\fP
Enable/disable top extended stats
.TP
.B \fBE\fP
Erase current process filter
.TP
.B \fBf\fP
Show/hide file system and folder monitoring stats
.TP
.B \fBF\fP
Switch between file system used and free space
.TP
.B \fBg\fP
Generate graphs for current history
.TP
.B \fBh\fP
Show/hide the help screen
.TP
.B \fBi\fP
Sort processes by I/O rate
.TP
.B \fBI\fP
Show/hide IP module
.TP
.B \fBl\fP
Show/hide log messages
.TP
.B \fBm\fP
Sort processes by MEM usage
.TP
.B \fBM\fP
Reset processes summary min/max
.TP
.B \fBn\fP
Show/hide network stats
.TP
.B \fBp\fP
Sort processes by name
.TP
.B \fBq|ESC\fP
Quit the current Glances session
.TP
.B \fBr\fP
Reset history
.TP
.B \fBR\fP
Show/hide RAID plugin
.TP
.B \fBs\fP
Show/hide sensors stats
.TP
.B \fBt\fP
Sort process by CPU times (TIME+)
.TP
.B \fBT\fP
View network I/O as combination
.TP
.B \fBu\fP
Sort processes by USER
.TP
.B \fBU\fP
View cumulative network I/O
.TP
.B \fBw\fP
Delete finished warning log messages
.TP
.B \fBx\fP
Delete finished warning and critical log messages
.TP
.B \fBz\fP
Show/hide processes stats
.TP
.B \fB0\fP
Enable/disable Irix/Solaris mode
.sp
Task\(aqs CPU usage will be divided by the total number of CPUs
.TP
.B \fB1\fP
Switch between global CPU and per\-CPU stats
.TP
.B \fB2\fP
Enable/disable left sidebar
.TP
.B \fB3\fP
Enable/disable the quick look module
.TP
.B \fB4\fP
Enable/disable all but quick look and load module
.TP
.B \fB5\fP
Enable/disable top menu (QuickLook, CPU, MEM, SWAP and LOAD)
.TP
.B \fB/\fP
Switch between process command line or command name
.UNINDENT
.sp
In the Glances client browser (accessible through the \fB\-\-browser\fP
command line argument):
.INDENT 0.0
.TP
.B \fBENTER\fP
Run the selected server
.TP
.B \fBUP\fP
Up in the servers list
.TP
.B \fBDOWN\fP
Down in the servers list
.TP
.B \fBq|ESC\fP
Quit Glances
.UNINDENT
.SH EXAMPLES
.sp
Monitor local machine (standalone mode):
.INDENT 0.0
.INDENT 3.5
$ glances
.UNINDENT
.UNINDENT
.sp
Monitor local machine with the web interface (Web UI):
.INDENT 0.0
.INDENT 3.5
$ glances \-w
.UNINDENT
.UNINDENT
.sp
Monitor local machine and export stats to a CSV file:
.INDENT 0.0
.INDENT 3.5
$ glances \-\-export\-csv
.UNINDENT
.UNINDENT
.sp
Monitor local machine and export stats to a InfluxDB server with 5s
refresh time:
.INDENT 0.0
.INDENT 3.5
$ glances \-t 5 \-\-export\-influxdb
.UNINDENT
.UNINDENT
.sp
Start a Glances server (server mode):
.INDENT 0.0
.INDENT 3.5
$ glances \-s
.UNINDENT
.UNINDENT
.sp
Connect Glances to a Glances server (client mode):
.INDENT 0.0
.INDENT 3.5
$ glances \-c <ip_server>
.UNINDENT
.UNINDENT
.sp
Connect to a Glances server and export stats to a StatsD server:
.INDENT 0.0
.INDENT 3.5
$ glances \-c <ip_server> \-\-export\-statsd
.UNINDENT
.UNINDENT
.sp
Start the client browser (browser mode):
.INDENT 0.0
.INDENT 3.5
$ glances \-\-browser
.UNINDENT
.UNINDENT
.SH AUTHOR
.sp
Nicolas Hennion aka Nicolargo <\fI\%contact@nicolargo.com\fP>
.SH COPYRIGHT
2016, Nicolas Hennion
.\" Generated by docutils manpage writer.
.

120
docs/quickstart.rst Normal file
View File

@ -0,0 +1,120 @@
.. _quickstart:
Quickstart
==========
This page gives a good introduction in how to get started with Glances.
Glances offers 3 modes:
- Standalone
- Client/Server
- Web server
Standalone Mode
---------------
Simply run:
.. code-block:: console
$ glances
Client/Server Mode
------------------
If you want to remotely monitor a machine, called ``server``, from
another one, called ``client``, just run on the server:
.. code-block:: console
server$ glances -s
and on the client:
.. code-block:: console
client$ glances -c @server
where ``@server`` is the IP address or hostname of the server.
Glances can centralize available Glances servers using the ``--browser``
option. The server list can be statically defined via the configuration
file (section ``[serverlist]``).
In server mode, you can set the bind address with ``-B ADDRESS`` and
the listening TCP port with ``-p PORT``.
In client mode, you can set the TCP port of the server with ``-p PORT``.
Default binding address is ``0.0.0.0`` (Glances will listen on all the
available network interfaces) and TCP port is ``61209``.
In client/server mode, limits are set by the server side.
You can set a password to access to the server ``--password``. By
default, the username is ``glances`` but you can change it with
``--username``.
If you ask it, the SHA password will be stored in ``username.pwd`` file.
Glances is ``IPv6`` compatible. Just use the ``-B ::`` option to bind to
all IPv6 addresses.
Autodiscover
^^^^^^^^^^^^
Glances can also detect and display all Glances servers available on
your network via the ``zeroconf`` protocol (not available on Windows):
.. code-block:: console
client$ glances --browser
Use ``--disable-autodiscover`` to disable it.
SNMP
^^^^
As an experimental feature, if Glances server is not detected by the
client, the latter will try to grab stats using the ``SNMP`` protocol:
.. code-block:: console
client$ glances -c @snmpserver
.. note::
Stats grabbed by SNMP request are limited and OS dependent.
Web Server Mode
---------------
.. image:: _static/screenshot-web.png
If you want to remotely monitor a machine, called ``server``, from any
device with a web browser, just run the server with the ``-w`` option:
.. code-block:: console
server$ glances -w
then on the client enter the following URL in your favorite web browser:
::
http://@server:61208
where ``@server`` is the IP address or hostname of the server.
To change the refresh rate of the page, just add the period in seconds
at the end of the URL. For example, to refresh the page every ``10``
seconds:
::
http://@server:61208/10
The Glances web interface follows responsive web design principles.
Here's a screenshot from Chrome on Android:
.. image:: _static/screenshot-web2.png

View File

@ -1,109 +0,0 @@
/*
:Author: Alessio Sergi
:Contact: al3hex at gmail dot com
Stylesheet for use with Docutils.
This file is the CSS for the Glances documentation.
*/
body {
margin-top: 1em;
margin-left: 1em;
max-width: 80em;
font-family: serif;
font-size: 16px;
}
h1 {
font-size: 20px;
}
h1.title {
font-size: 22px;
}
h2, h3, p.topic-title {
font-size: 18px;
}
.first {
/* override p.topic-title margin styles */
margin-top: 0 ! important;
}
a {
color: #0055df;
text-decoration: none;
}
a:hover {
color: #339999;
text-decoration: underline;
}
a:visited {
color: #800080;
}
a.toc-backref {
text-decoration: none;
color: black;
}
blockquote {
padding-left: 1ex;
border-left: 1px solid #008000;
max-width: 30em;
}
p.topic-title {
font-weight: bold;
}
pre {
margin-left: 2em;
margin-right: 2em;
}
.console, .literal-block {
background-color: #eeeeee;
border: 1px solid #cccccc;
max-width: 60em;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px 3px 3px 3px;
}
span.option, tt.docutils {
white-space: nowrap;
border: 1px dotted #008000;
padding: 1px;
background-color: #eeeeee;
}
.literal, .literal-block, .option, .var {
font-family: monospace;
font-size: 10pt;
}
dl.docutils {
margin-left: 2em;
}
dl.docutils dd {
margin-bottom: 0.5em;
}
ol.simple {
margin-left: 0.5em;
}
table.docutils {
margin-left: 2em;
}
td.option-group {
padding-right: 1em;
}

13
docs/support.rst Normal file
View File

@ -0,0 +1,13 @@
.. _support:
Support
=======
To post a question about Glances use cases, please post it to the
official Q&A `forum
<https://groups.google.com/forum/?hl=en#!forum/glances-users>`_.
To report a bug or a feature request use the GitHub `issue
<https://github.com/nicolargo/glances/issues>`_ tracker.
Feel free to contribute!

View File

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

View File

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

View File

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

View File

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

View File

@ -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):
except socket.error as e:
logger.error("Cannot start zeroconf: {0}".format(e))
# XXX FreeBSD: Segmentation fault (core dumped)
# XXX *BSDs: Segmentation fault (core dumped)
# -- https://bitbucket.org/al45tair/netifaces/issues/15
if not is_freebsd:
if not BSD:
try:
# -B @ overwrite the dynamic IPv4 choice
if zeroconf_bind_address == '0.0.0.0':

View File

@ -19,20 +19,14 @@
"""Manage the Glances client."""
# Import system libs
import json
import socket
import sys
try:
from xmlrpc.client import Transport, ServerProxy, ProtocolError, Fault
except ImportError:
# Python 2
from xmlrpclib import Transport, ServerProxy, ProtocolError, Fault
# Import Glances libs
from glances.core.glances_globals import version
from glances.core.glances_logging import logger
from glances.core.glances_stats import GlancesStatsClient
from glances.compat import Fault, ProtocolError, ServerProxy, Transport
from glances.globals import version
from glances.logger import logger
from glances.stats import GlancesStatsClient
from glances.outputs.glances_curses import GlancesCursesClient
@ -110,18 +104,19 @@ class GlancesClient(object):
except socket.error as err:
# Fallback to SNMP
self.client_mode = 'snmp'
logger.error("Connection to Glances server failed: {0}".format(err))
logger.error("Connection to Glances server failed ({0} {1})".format(err.errno, err.strerror))
fallbackmsg = 'No Glances server found. Trying fallback to SNMP...'
if not self.return_to_browser:
print(fallbackmsg)
else:
logger.info(fallbackmsg)
except ProtocolError as err:
# Others errors
if str(err).find(" 401 ") > 0:
msg = "Connection to server failed (bad password)"
# Other errors
msg = "Connection to server failed"
if err.errcode == 401:
msg += " (Bad username/password)"
else:
msg = "Connection to server failed ({0})".format(err)
msg += " ({0} {1})".format(err.errcode, err.errmsg)
self.log_and_exit(msg)
return False
@ -144,7 +139,7 @@ class GlancesClient(object):
if self.client_mode == 'snmp':
logger.info("Trying to grab stats by SNMP...")
from glances.core.glances_stats import GlancesStatsClientSNMP
from glances.stats import GlancesStatsClientSNMP
# Init stats
self.stats = GlancesStatsClientSNMP(config=self.config, args=self.args)

View File

@ -19,21 +19,15 @@
"""Manage the Glances client browser (list of Glances server)."""
# Import system libs
import json
import socket
try:
from xmlrpc.client import ServerProxy, Fault, ProtocolError
except ImportError:
# Python 2
from xmlrpclib import ServerProxy, Fault, ProtocolError
# Import Glances libs
from glances.core.glances_autodiscover import GlancesAutoDiscoverServer
from glances.core.glances_client import GlancesClient, GlancesClientTransport
from glances.core.glances_logging import logger
from glances.core.glances_passwordlist import GlancesPasswordList as GlancesPassword
from glances.core.glances_staticlist import GlancesStaticServer
from glances.compat import Fault, ProtocolError, ServerProxy
from glances.autodiscover import GlancesAutoDiscoverServer
from glances.client import GlancesClient, GlancesClientTransport
from glances.logger import logger
from glances.password_list import GlancesPasswordList as GlancesPassword
from glances.static_list import GlancesStaticServer
from glances.outputs.glances_curses import GlancesCursesBrowser
@ -100,8 +94,8 @@ class GlancesClientBrowser(object):
"""Main client loop."""
while True:
# No need to update the server list
# It's done by the GlancesAutoDiscoverListener class (glances_autodiscover.py)
# Or define staticaly in the configuration file (module glances_staticlist.py)
# It's done by the GlancesAutoDiscoverListener class (autodiscover.py)
# Or define staticaly in the configuration file (module static_list.py)
# For each server in the list, grab elementary stats (CPU, LOAD, MEM, OS...)
# logger.debug(self.get_servers_list())
try:
@ -140,15 +134,14 @@ class GlancesClientBrowser(object):
"Error while grabbing stats form {0}: {1}".format(uri, e))
v['status'] = 'OFFLINE'
except ProtocolError as e:
if str(e).find(" 401 ") > 0:
if e.errcode == 401:
# Error 401 (Authentication failed)
# Password is not the good one...
v['password'] = None
v['status'] = 'PROTECTED'
else:
v['status'] = 'OFFLINE'
logger.debug(
"Cannot grab stats from {0}: {1}".format(uri, e))
logger.debug("Cannot grab stats from {0} ({1} {2})".format(uri, e.errcode, e.errmsg))
else:
# Status
v['status'] = 'ONLINE'
@ -167,7 +160,7 @@ class GlancesClientBrowser(object):
"Server list dictionnary change inside the loop (wait next update)")
# Update the screen (list or Glances client)
if self.screen.active_server is None:
if not self.screen.active_server:
# Display the Glances browser
self.screen.update(self.get_servers_list())
else:

127
glances/compat.py Normal file
View File

@ -0,0 +1,127 @@
# -*- coding: utf-8 -*-
#
# This file is part of Glances.
#
# Copyright (C) 2015 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Glances is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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/>.
# flake8: noqa
# pylint: skip-file
"""Python 2/3 compatibility shims."""
import operator
import sys
PY3 = sys.version_info[0] == 3
if PY3:
import queue
from configparser import ConfigParser, NoOptionError, NoSectionError
from xmlrpc.client import Fault, ProtocolError, ServerProxy, Transport
from xmlrpc.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
input = input
range = range
map = map
text_type = str
binary_type = bytes
viewkeys = operator.methodcaller('keys')
viewvalues = operator.methodcaller('values')
viewitems = operator.methodcaller('items')
def listitems(d):
return list(d.items())
def listkeys(d):
return list(d.keys())
def listvalues(d):
return list(d.values())
def iteritems(d):
return iter(d.items())
def iterkeys(d):
return iter(d.keys())
def itervalues(d):
return iter(d.values())
def u(s):
return s
def b(s):
if isinstance(s, binary_type):
return s
return s.encode('latin-1')
def nativestr(s):
if isinstance(s, text_type):
return s
return s.decode('utf-8', 'replace')
else:
import Queue as queue
from itertools import imap as map
from ConfigParser import SafeConfigParser as ConfigParser, NoOptionError, NoSectionError
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
from xmlrpclib import Fault, ProtocolError, ServerProxy, Transport
input = raw_input
range = xrange
ConfigParser.read_file = ConfigParser.readfp
text_type = unicode
binary_type = str
viewkeys = operator.methodcaller('viewkeys')
viewvalues = operator.methodcaller('viewvalues')
viewitems = operator.methodcaller('viewitems')
def listitems(d):
return d.items()
def listkeys(d):
return d.keys()
def listvalues(d):
return d.values()
def iteritems(d):
return d.iteritems()
def iterkeys(d):
return d.iterkeys()
def itervalues(d):
return d.itervalues()
def u(s):
return s.decode('utf-8')
def b(s):
return s
def nativestr(s):
if isinstance(s, binary_type):
return s
return s.encode('utf-8', 'replace')
try:
# Python 2.6
from logutils.dictconfig import dictConfig
except ImportError:
from logging.config import dictConfig

View File

@ -19,27 +19,13 @@
"""Manage the configuration file."""
# Import system libs
import os
import sys
try:
from configparser import ConfigParser
from configparser import NoOptionError
except ImportError: # Python 2
from ConfigParser import SafeConfigParser as ConfigParser
from ConfigParser import NoOptionError
from io import open
# Import Glances lib
from glances.core.glances_globals import (
appname,
is_bsd,
is_linux,
is_mac,
is_py3,
is_windows,
sys_prefix
)
from glances.core.glances_logging import logger
from glances.compat import ConfigParser, NoOptionError
from glances.globals import appname, BSD, LINUX, OSX, WINDOWS, sys_prefix
from glances.logger import logger
class Config(object):
@ -79,24 +65,24 @@ class Config(object):
if self.config_dir:
paths.append(self.config_dir)
if is_linux or is_bsd:
if LINUX or BSD:
paths.append(
os.path.join(os.environ.get('XDG_CONFIG_HOME') or
os.path.expanduser('~/.config'),
appname, self.config_filename))
if is_bsd:
if BSD:
paths.append(
os.path.join(sys.prefix, 'etc', appname, self.config_filename))
else:
paths.append(
os.path.join('/etc', appname, self.config_filename))
elif is_mac:
elif OSX:
paths.append(
os.path.join(os.path.expanduser('~/Library/Application Support/'),
appname, self.config_filename))
paths.append(
os.path.join(sys_prefix, 'etc', appname, self.config_filename))
elif is_windows:
elif WINDOWS:
paths.append(
os.path.join(os.environ.get('APPDATA'), appname, self.config_filename))
@ -107,10 +93,9 @@ class Config(object):
for config_file in self.config_file_paths():
if os.path.exists(config_file):
try:
if is_py3:
self.parser.read(config_file, encoding='utf-8')
else:
self.parser.read(config_file)
with open(config_file, encoding='utf-8') as f:
self.parser.read_file(f)
self.parser.read(f)
logger.info("Read configuration file '{0}'".format(config_file))
except UnicodeDecodeError as err:
logger.error("Cannot decode configuration file '{0}': {1}".format(config_file, err))

View File

@ -19,7 +19,7 @@
"""CPU percent stats shared between CPU and Quicklook plugins."""
from glances.core.glances_timer import Timer
from glances.timer import Timer
import psutil

View File

@ -19,13 +19,12 @@
"""CSV interface class."""
# Import sys libs
import csv
import sys
import time
# Import Glances lib
from glances.core.glances_globals import is_py3
from glances.core.glances_logging import logger
from glances.compat import PY3, iterkeys, itervalues
from glances.logger import logger
from glances.exports.glances_export import GlancesExport
@ -35,14 +34,14 @@ class Export(GlancesExport):
def __init__(self, config=None, args=None):
"""Init the CSV export IF."""
GlancesExport.__init__(self, config=config, args=args)
super(Export, self).__init__(config=config, args=args)
# CSV file name
self.csv_filename = args.export_csv
# Set the CSV output file
try:
if is_py3:
if PY3:
self.csv_file = open(self.csv_filename, 'w', newline='')
else:
self.csv_file = open(self.csv_filename, 'wb')
@ -64,13 +63,14 @@ class Export(GlancesExport):
def update(self, stats):
"""Update stats in the CSV output file."""
csv_header = []
csv_data = []
# Get the stats
all_stats = stats.getAllExports()
plugins = stats.getAllPlugins()
# Init data with timestamp (issue#708)
csv_header = ['timestamp']
csv_data = [time.strftime('%Y-%m-%d %H:%M:%S')]
# Loop over available plugin
for i, plugin in enumerate(plugins):
if plugin in self.plugins_to_export():
@ -81,17 +81,15 @@ class Export(GlancesExport):
csv_header += ('{0}_{1}_{2}'.format(
plugin, self.get_item_key(stat), item) for item in stat)
# Others lines: stats
fieldvalues = stat.values()
csv_data += fieldvalues
csv_data += itervalues(stat)
elif isinstance(all_stats[i], dict):
# First line: header
if self.first_line:
fieldnames = all_stats[i].keys()
fieldnames = iterkeys(all_stats[i])
csv_header += ('{0}_{1}'.format(plugin, fieldname)
for fieldname in fieldnames)
# Others lines: stats
fieldvalues = all_stats[i].values()
csv_data += fieldvalues
csv_data += itervalues(all_stats[i])
# Export to CSV
if self.first_line:

View File

@ -0,0 +1,117 @@
# -*- coding: utf-8 -*-
#
# This file is part of Glances.
#
# Copyright (C) 2015 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Glances is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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/>.
"""ElasticSearch interface class."""
import sys
from datetime import datetime
from glances.compat import NoOptionError, NoSectionError
from glances.logger import logger
from glances.exports.glances_export import GlancesExport
from elasticsearch import Elasticsearch, helpers
class Export(GlancesExport):
"""This class manages the ElasticSearch (ES) export module."""
def __init__(self, config=None, args=None):
"""Init the ES export IF."""
super(Export, self).__init__(config=config, args=args)
# Load the ES configuration file
self.host = None
self.port = None
self.index = None
self.export_enable = self.load_conf()
if not self.export_enable:
sys.exit(2)
# Init the ES client
self.client = self.init()
def load_conf(self, section="elasticsearch"):
"""Load the ES configuration in the Glances configuration file."""
if self.config is None:
return False
try:
self.host = self.config.get_value(section, 'host')
self.port = self.config.get_value(section, 'port')
self.index = self.config.get_value(section, 'index')
except NoSectionError:
logger.critical("No ElasticSearch configuration found")
return False
except NoOptionError as e:
logger.critical("Error in the ElasticSearch configuration (%s)" % e)
return False
else:
logger.debug("Load ElasticSearch from the Glances configuration file")
return True
def init(self):
"""Init the connection to the ES server."""
if not self.export_enable:
return None
try:
es = Elasticsearch(hosts=['{0}:{1}'.format(self.host, self.port)])
except Exception as e:
logger.critical("Cannot connect to ElasticSearch server %s:%s (%s)" % (self.host, self.port, e))
sys.exit(2)
else:
logger.info("Connected to the ElasticSearch server %s:%s" % (self.host, self.port))
try:
index_count = es.count(index=self.index)['count']
except Exception as e:
# Index did not exist, it will be created at the first write
# Create it...
es.indices.create(self.index)
else:
logger.info("There is already %s entries in the ElasticSearch %s index" % (index_count, self.index))
return es
def export(self, name, columns, points):
"""Write the points to the ES server."""
logger.debug("Export {0} stats to ElasticSearch".format(name))
# Create DB input
# http://elasticsearch-py.readthedocs.org/en/master/helpers.html
actions = []
for c, p in zip(columns, points):
action = {
"_index": self.index,
"_type": name,
"_id": c,
"_source": {
"value": str(p),
"timestamp": datetime.now()
}
}
actions.append(action)
# Write input to the ES index
try:
helpers.bulk(self.client, actions)
except Exception as e:
logger.error("Cannot export {0} stats to ElasticSearch ({1})".format(name, e))

View File

@ -23,11 +23,8 @@ I am your father...
...for all Glances exports IF.
"""
# Import system libs
# None...
# Import Glances lib
from glances.core.glances_logging import logger
from glances.compat import iteritems, iterkeys
from glances.logger import logger
class GlancesExport(object):
@ -80,17 +77,24 @@ class GlancesExport(object):
else:
return ret
def parse_tags(self):
""" Parses some tags into a dict"""
if self.tags:
def parse_tags(self, tags):
"""Parse tags into a dict.
tags: a comma separated list of 'key:value' pairs.
Example: foo:bar,spam:eggs
dtags: a dict of tags.
Example: {'foo': 'bar', 'spam': 'eggs'}
"""
dtags = {}
if tags:
try:
self.tags = dict([x.split(':') for x in self.tags.split(',')])
dtags = dict([x.split(':') for x in tags.split(',')])
except ValueError:
# one of the keyvalue pairs was missing
logger.info('invalid tags passed: %s', self.tags)
self.tags = {}
else:
self.tags = {}
# one of the 'key:value' pairs was missing
logger.info('Invalid tags passed: %s', tags)
dtags = {}
return dtags
def update(self, stats):
"""Update stats to a server.
@ -131,16 +135,12 @@ class GlancesExport(object):
if isinstance(stats, dict):
# Stats is a dict
# Is there a key ?
if 'key' in list(stats.keys()):
if 'key' in iterkeys(stats):
pre_key = '{0}.'.format(stats[stats['key']])
else:
pre_key = ''
# Walk through the dict
try:
iteritems = stats.iteritems()
except AttributeError:
iteritems = stats.items()
for key, value in iteritems:
for key, value in iteritems(stats):
if isinstance(value, list):
try:
value = value[0]

View File

@ -19,13 +19,11 @@
"""History class."""
# Import system lib
import os
# Import Glances lib
from glances.core.glances_logging import logger
from glances.compat import iterkeys
from glances.logger import logger
# Import specific lib
try:
from matplotlib import __version__ as matplotlib_version
import matplotlib.pyplot as plt
@ -108,7 +106,7 @@ class GlancesHistory(object):
handles = []
labels = []
for i in stats.get_plugin(p).get_items_history_list():
if i['name'] in h.keys():
if i['name'] in iterkeys(h):
# The key exist
# Add the curves in the current chart
logger.debug("Generate graph: %s %s" % (p, i['name']))
@ -132,8 +130,7 @@ class GlancesHistory(object):
# Find if anothers key ends with the key
# Ex: key='tx' => 'ethernet_tx'
# Add one curve per chart
stats_history_filtered = [key for key in h.keys() if key.endswith('_' + i['name'])]
stats_history_filtered.sort()
stats_history_filtered = sorted([key for key in iterkeys(h) if key.endswith('_' + i['name'])])
logger.debug("Generate graphs: %s %s" %
(p, stats_history_filtered))
if len(stats_history_filtered) > 0:

View File

@ -19,15 +19,10 @@
"""InfluxDB interface class."""
# Import sys libs
import sys
try:
from configparser import NoOptionError, NoSectionError
except ImportError: # Python 2
from ConfigParser import NoOptionError, NoSectionError
# Import Glances lib
from glances.core.glances_logging import logger
from glances.compat import NoOptionError, NoSectionError
from glances.logger import logger
from glances.exports.glances_export import GlancesExport
from influxdb import InfluxDBClient
@ -35,9 +30,10 @@ from influxdb.client import InfluxDBClientError
from influxdb.influxdb08 import InfluxDBClient as InfluxDBClient08
from influxdb.influxdb08.client import InfluxDBClientError as InfluxDBClientError08
# Constants for tracking behavior
INFLUXDB_09 = '0.9'
# Constants for tracking specific behavior
INFLUXDB_08 = '0.8'
INFLUXDB_09PLUS = '0.9+'
class Export(GlancesExport):
@ -45,7 +41,7 @@ class Export(GlancesExport):
def __init__(self, config=None, args=None):
"""Init the InfluxDB export IF."""
GlancesExport.__init__(self, config=config, args=args)
super(Export, self).__init__(config=config, args=args)
# Load the InfluxDB configuration file
self.host = None
@ -54,6 +50,7 @@ class Export(GlancesExport):
self.password = None
self.db = None
self.prefix = None
self.tags = None
self.export_enable = self.load_conf()
if not self.export_enable:
sys.exit(2)
@ -90,7 +87,7 @@ class Export(GlancesExport):
try:
self.tags = self.config.get_value(section, 'tags')
except NoOptionError:
self.tags = ''
pass
return True
@ -106,7 +103,7 @@ class Export(GlancesExport):
password=self.password,
database=self.db)
get_all_db = [i['name'] for i in db.get_list_database()]
self.version = INFLUXDB_09
self.version = INFLUXDB_09PLUS
except InfluxDBClientError:
# https://github.com/influxdb/influxdb-python/issues/138
logger.info("Trying fallback to InfluxDB v0.8")
@ -128,9 +125,6 @@ class Export(GlancesExport):
logger.critical("InfluxDB database '%s' did not exist. Please create it" % self.db)
sys.exit(2)
# Read tags
self.parse_tags()
return db
def export(self, name, columns, points):
@ -139,14 +133,21 @@ class Export(GlancesExport):
# Manage prefix
if self.prefix is not None:
name = self.prefix + '.' + name
# logger.info(self.prefix)
# Create DB input
if self.version == INFLUXDB_09:
data = [{'measurement': name,
'tags': self.tags,
'fields': dict(zip(columns, points))}]
else:
if self.version == INFLUXDB_08:
data = [{'name': name, 'columns': columns, 'points': [points]}]
else:
# Convert all int to float (mandatory for InfluxDB>0.9.2)
# Correct issue#750 and issue#749
for i, _ in enumerate(points):
try:
points[i] = float(points[i])
except (TypeError, ValueError) as e:
logger.debug("InfluxDB error diring stat convertion %s=%s (%s)" % (columns[i], points[i], e))
data = [{'measurement': name,
'tags': self.parse_tags(self.tags),
'fields': dict(zip(columns, points))}]
# Write input to the InfluxDB database
try:
self.client.write_points(data)

View File

@ -19,32 +19,29 @@
"""OpenTSDB interface class."""
# Import sys libs
import sys
from numbers import Number
try:
from configparser import NoOptionError, NoSectionError
except ImportError: # Python 2
from ConfigParser import NoOptionError, NoSectionError
# Import Glances lib
from glances.core.glances_logging import logger
from glances.compat import NoOptionError, NoSectionError, range
from glances.logger import logger
from glances.exports.glances_export import GlancesExport
import potsdb
class Export(GlancesExport):
"""This class manages the OpenTSDB export module."""
def __init__(self, config=None, args=None):
"""Init the OpenTSDB export IF."""
GlancesExport.__init__(self, config=config, args=args)
super(Export, self).__init__(config=config, args=args)
# Load the InfluxDB configuration file
self.host = None
self.port = None
self.prefix = None
self.tags = None
self.export_enable = self.load_conf()
if not self.export_enable:
sys.exit(2)
@ -82,7 +79,7 @@ class Export(GlancesExport):
try:
self.tags = self.config.get_value(section, 'tags')
except NoOptionError:
self.tags = ''
pass
return True
@ -99,20 +96,18 @@ class Export(GlancesExport):
logger.critical("Cannot connect to OpenTSDB server %s:%s (%s)" % (self.host, self.port, e))
sys.exit(2)
# Read tags
self.parse_tags()
return db
def export(self, name, columns, points):
"""Export the stats to the Statsd server."""
for i in range(0, len(columns)):
for i in range(len(columns)):
if not isinstance(points[i], Number):
continue
stat_name = '{0}.{1}.{2}'.format(self.prefix, name, columns[i])
stat_value = points[i]
tags = self.parse_tags(self.tags)
try:
self.client.send(stat_name, stat_value, **self.tags)
self.client.send(stat_name, stat_value, **tags)
except Exception as e:
logger.error("Can not export stats %s to OpenTSDB (%s)" % (name, e))
logger.debug("Export {0} stats to OpenTSDB".format(name))
@ -122,4 +117,4 @@ class Export(GlancesExport):
# Waits for all outstanding metrics to be sent and background thread closes
self.client.wait()
# Call the father method
GlancesExport.exit(self)
super(Export, self).exit()

Some files were not shown because too many files have changed in this diff Show More