Glances can trigger actions on events.

By action, we mean all shell command line. For example, if you want to execute the script if the last 5 minutes load are critical then add the _action line to the Glances configuration file:

critical_action=python /path/to/

All the stats are available in the command line through the use of the Mustache syntax. Chevron is required to render the mustache’s template syntax.

Another example would be to create a log file containing used vs total disk space if a space trigger warning is reached:

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:

critical_action_repeat=echo {{device_name}} {{percent}} > /tmp/fs.alert && python /etc/glances/actions.d/


Use && as separator for multiple commands

Within /etc/glances/actions.d/

import subprocess
from requests import get

fs_alert = open('/tmp/fs.alert', 'r').readline().strip().split(' ')
device = fs_alert[0]
percent = fs_alert[1]
system = subprocess.check_output(['uname', '-rn']).decode('utf-8').strip()
ip = get('').text

body = 'Used user disk space for ' + device + ' is at ' + percent + '%.\nPlease cleanup the filesystem to clear the alert.\nServer: ' + str(system)+ '.\nIP address: ' + ip
ps = subprocess.Popen(('echo', '-e', body), stdout=subprocess.PIPE)['mail', '-s', 'CRITICAL: disk usage above 90%', '-r', '', ''], stdin=ps.stdout)


You can use all the stats for the current plugin. See 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: