summaryrefslogtreecommitdiffstats
path: root/docs/aoa/actions.rst
blob: b83f17372c2daa074c39bbf74af24ead0a9e2cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
.. _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.

It is also possible to repeat action until the end of the alert.
Keep in mind that the command line is executed every refresh time so
use with caution:

.. code-block:: ini

    [load]
    critical=5.0
    critical_action_repeat=/home/myhome/bin/bipper.sh

.. _{{mustache}}: https://mustache.github.io/