From a2c0357898c24518867efd37adfc1e7bbed83b81 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sun, 25 Apr 2021 09:42:23 +0200 Subject: Manage multiple commands (&&) in the secure popen --- docs/aoa/actions.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'docs/aoa/actions.rst') diff --git a/docs/aoa/actions.rst b/docs/aoa/actions.rst index a594d34d..3ee6779e 100644 --- a/docs/aoa/actions.rst +++ b/docs/aoa/actions.rst @@ -28,16 +28,21 @@ reached: warning=70 warning_action=echo {{mnt_point}} {{used}}/{{size}} > /tmp/fs.alert -A last example would be to create a log file -containing the total user disk space usage for a device and notify by email each time a space trigger critical is -reached: +A last example would be to create a log file containing the total user disk +space usage for a device and notify by email each time a space trigger +critical is reached: .. code-block:: ini [fs] critical=90 critical_action_repeat=echo {{device_name}} {{percent}} > /tmp/fs.alert && python /etc/glances/actions.d/fs-critical.py - + + +.. note:: + Use && as seprator for multiple commands + + Within ``/etc/glances/actions.d/fs-critical.py``: .. code-block:: python @@ -55,9 +60,6 @@ Within ``/etc/glances/actions.d/fs-critical.py``: ps = subprocess.Popen(('echo', '-e', body), stdout=subprocess.PIPE) subprocess.call(['mail', '-s', 'CRITICAL: disk usage above 90%', '-r', 'postmaster@example.com', 'glances@example.com'], stdin=ps.stdout) - - - .. note:: You can use all the stats for the current plugin. See https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API -- cgit v1.2.3