New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add action script on alert #132
Comments
Better than the antique mail technology why don't you make it more general, more abstract. Launching a python script for isntance. Then it allows users to send xmpp|mail messages, write a log, play sound, send sms etc… : ) cheers |
Like your idea... |
@mxjeff : yes, I agree. It would be more convenient. Maybe we could add a Hubot (http://hubot.github.com/) plugin. |
How would the python script be configured? For example, what if the user wants t choose to play a sound and send an sms, but no email? |
config file ? |
It could be as simple as string to give to subprocess.Popen(). Then one can write a script in plain shell, perl or python to perform whatever action is required. Glances could set some env. var. to pass some info to the external process being call. subprocess.Popen([script_defined_in_conf, some, pos, arg]) I say, keep it simple and powerful enough for users to do whatever they want. |
How about something like this? import subprocess
commands = ["python custom_sendmail.py -addr test@example.com",
"python make_an_alarm_noise.py",]
print "Something is wrong, run alarm commands"
for cmd in commands:
formatted_cmd = cmd.split()
print "Running: '%s'" % formatted_cmd
subprocess.Popen(formatted_cmd) |
config file's path would be set at the programing init ? |
As a bonus, you can also use stats values as {{mustache}} tag in the command line:
|
Feature available on the develop branch (commit: 283af00). Should be beta-tested with a maximum of case. Feature documentation: 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:
All the stats are usable in the command line by the use of the {{mustache}} syntax. Another example to create a log file containing used vs total disk space if a warning space trigger is reached:
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) How to install the develop branch: https://github.com/nicolargo/glances/wiki/Install-and-test-Glances-DEVELOP-version |
Hi By the way if glances starts automatically with cron does it mean that it never stops ? |
Is it available in master already? |
Upon trigger (for exemple critical alert on free diskspace) a mail will be sent to a administrator.
The text was updated successfully, but these errors were encountered: