mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-27 19:04:50 +03:00
Add auto generation refresh time function
This commit is contained in:
parent
476d441c0e
commit
da75b97047
@ -320,6 +320,10 @@ all=False
|
||||
# Set the path where the graph (.svg files) will be created
|
||||
# Can be overwrite by the --graph-path command line option
|
||||
path=/tmp
|
||||
# It is possible to generate the graphs automatically by setting the
|
||||
# generate_every to a non zero value corresponding to the seconds between
|
||||
# two generation. Set it to 0 to disable graph auto generation.
|
||||
generate_every=60
|
||||
# See followings configuration keys definitions in the Pygal lib documentation
|
||||
# http://pygal.org/en/stable/documentation/index.html
|
||||
width=800
|
||||
|
4
docs/_static/graph-load.svg
vendored
Normal file
4
docs/_static/graph-load.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 183 KiB |
@ -21,7 +21,7 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-cassandra
|
||||
$ glances --export cassandra
|
||||
|
||||
The data model is the following:
|
||||
|
||||
|
@ -20,7 +20,7 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-couchdb
|
||||
$ glances --export couchdb
|
||||
|
||||
Documents are stored in native ``JSON`` format. Glances adds ``"type"``
|
||||
and ``"time"`` entries:
|
||||
|
@ -7,7 +7,7 @@ It's possible to export stats to a CSV file.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-csv /tmp/glances.csv
|
||||
$ glances --export csv --export-csv-file /tmp/glances.csv
|
||||
|
||||
CSV file description:
|
||||
|
||||
|
@ -17,7 +17,7 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-elasticsearch
|
||||
$ glances --export elasticsearch
|
||||
|
||||
The stats are available through the elasticsearch API. For example, to
|
||||
get the CPU system stats:
|
||||
|
34
docs/gw/graph.rst
Normal file
34
docs/gw/graph.rst
Normal file
@ -0,0 +1,34 @@
|
||||
.. _graph:
|
||||
|
||||
Graph
|
||||
======
|
||||
|
||||
You can generate dynamic graphs (SVG format) in a target folder. The generation
|
||||
starts every time the 'g' key is pressed in the CLI interface.
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[graph]
|
||||
# Configuration for the --export graph option
|
||||
# Set the path where the graph (.svg files) will be created
|
||||
# Can be overwrite by the --graph-path command line option
|
||||
path=/tmp
|
||||
# It is possible to generate the graphs automatically by setting the
|
||||
# generate_every to a non zero value corresponding to the seconds between
|
||||
# two generation. Set it to 0 to disable graph auto generation.
|
||||
generate_every=60
|
||||
# See followings configuration keys definitions in the Pygal lib documentation
|
||||
# http://pygal.org/en/stable/documentation/index.html
|
||||
width=800
|
||||
height=600
|
||||
style=DarkStyle
|
||||
|
||||
and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export graph --export-graph-path /tmp
|
||||
|
||||
Example of output (load graph)
|
||||
|
||||
.. image:: ../_static/graph-load.svg
|
@ -14,6 +14,7 @@ to providing stats to multiple services (see list below).
|
||||
cassandra
|
||||
couchdb
|
||||
elastic
|
||||
graph
|
||||
influxdb
|
||||
json
|
||||
kafka
|
||||
|
@ -21,7 +21,7 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-influxdb
|
||||
$ glances --export influxdb
|
||||
|
||||
Glances generates a lot of columns, e.g., if you have many running
|
||||
Docker containers, so you should use the ``tsm1`` engine in the InfluxDB
|
||||
|
@ -7,4 +7,4 @@ It's possible to export stats to a JSON file.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-json /tmp/glances.json
|
||||
$ glances --export json --export-json-file json /tmp/glances.json
|
||||
|
@ -21,7 +21,7 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-kafka
|
||||
$ glances --export kafka
|
||||
|
||||
Stats are sent in native ``JSON`` format to the topic:
|
||||
|
||||
|
@ -19,4 +19,4 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-opentsdb
|
||||
$ glances --export opentsdb
|
||||
|
@ -18,7 +18,7 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-prometheus
|
||||
$ glances --export prometheus
|
||||
|
||||
You can check that Glances exports the stats using this URL: http://localhost:9091
|
||||
|
||||
|
@ -20,4 +20,4 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-rabbitmq
|
||||
$ glances --export rabbitmq
|
||||
|
@ -34,7 +34,7 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-restful
|
||||
$ glances --export restful
|
||||
|
||||
Glances will generate stats as a big JSON dictionary (see example `here`_).
|
||||
|
||||
|
@ -17,4 +17,4 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-riemann
|
||||
$ glances --export riemann
|
||||
|
@ -20,7 +20,7 @@ and run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-statsd
|
||||
$ glances --export statsd
|
||||
|
||||
Glances will generate stats as:
|
||||
|
||||
|
@ -26,7 +26,7 @@ Run Glances with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ glances --export-zeromq -C <path>/glances.conf
|
||||
$ glances --export zeromq
|
||||
|
||||
Following is a simple Python client to subscribe to the Glances stats:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
.\" Man page generated from reStructuredText.
|
||||
.
|
||||
.TH "GLANCES" "1" "Feb 11, 2018" "3.0.dev0" "Glances"
|
||||
.TH "GLANCES" "1" "Apr 02, 2018" "3.0.rc1" "Glances"
|
||||
.SH NAME
|
||||
glances \- An eye on your system
|
||||
.
|
||||
|
@ -27,6 +27,7 @@ import tempfile
|
||||
import errno
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.timer import Timer
|
||||
from glances.compat import iteritems, time_serie_subsample
|
||||
from glances.exports.glances_export import GlancesExport
|
||||
|
||||
@ -42,12 +43,14 @@ class Export(GlancesExport):
|
||||
# Load the Graph configuration file section (is exists)
|
||||
self.export_enable = self.load_conf('graph',
|
||||
options=['path',
|
||||
'generate_every',
|
||||
'width',
|
||||
'height',
|
||||
'style'])
|
||||
|
||||
# Manage options (command line arguments overwrite configuration file)
|
||||
self.path = args.export_graph_path or self.path
|
||||
self.generate_every = int(getattr(self, 'generate_every', 0))
|
||||
self.width = int(getattr(self, 'width', 800))
|
||||
self.height = int(getattr(self, 'height', 600))
|
||||
self.style = getattr(pygal.style,
|
||||
@ -69,8 +72,14 @@ class Export(GlancesExport):
|
||||
logger.critical("Graph output folder {} is not writeable".format(self.path))
|
||||
sys.exit(2)
|
||||
|
||||
logger.info("Graphs will be created in the folder {}".format(self.path))
|
||||
logger.info("Graphs are created when 'g' key is pressed")
|
||||
logger.info("Graphs will be created in the {} folder".format(self.path))
|
||||
logger.info("Graphs will be created when 'g' key is pressed (in the CLI interface)")
|
||||
if self.generate_every != 0:
|
||||
logger.info("Graphs will be created automatically every {} seconds".format(self.generate_every))
|
||||
# Start the timer
|
||||
self._timer = Timer(self.generate_every)
|
||||
else:
|
||||
self._timer = None
|
||||
|
||||
def exit(self):
|
||||
"""Close the files."""
|
||||
@ -78,6 +87,11 @@ class Export(GlancesExport):
|
||||
|
||||
def update(self, stats):
|
||||
"""Generate Graph file in the output folder."""
|
||||
|
||||
if self.generate_every != 0 and self._timer.finished():
|
||||
self.args.generate_graph = True
|
||||
self._timer.reset()
|
||||
|
||||
if not self.args.generate_graph:
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user