-
Notifications
You must be signed in to change notification settings - Fork 332
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
event-handler: T3083: Add simple event-handler #1340
Conversation
Can it be extended by adding logging of received messages and running scripts? Most likely you need to exclude logs produced by the program itself to avoid endless loops. Maybe you want to use required instead Also, you should switch to compiled regular expression objects. This reduces CPU usage a lot in systems with intensive logs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idea is sensible: reading the system log from journald is the only thing that doesn't open a huge can of worms with dying processes, disappearing log files and other unfortunate situations.
However, I think we should make it possible to watch for multiple patterns. I also left a few more ideas and suggestions there in the review.
e71e7c8
to
547f531
Compare
Event-handler allows executing a custom script when in logs it detects configured "pattern" A simple implemenation set system event-handler first pattern '.*ssh2.*' set system event-handler first script '/config/scripts/hello.sh'
* Removed dynamic generating for systemd unit * Optimized configuration file deleting process * Added exceptions handlers to event-handler script to protect service from most obvious potential troubles * Improved logging * Moved pattern compilation outside a messages loop to avoid extra operations * Added signal handlers for proper systemd integration
Move 'system event-handler' to 'service event-handler'
* Added the ability to filter by a syslog identifier * Added the ability to pass arguments to a script * Added the ability to pass preconfigured environment variables to a script * A message that triggered a script is now passed in the `message` variable and can be used in a script * Replaced `call()` to `run()`, since stdout are not need to be printed
Before: set service event-handler Foo After: set service event-handler event Foo
Lets merge it, play it, and improve it :) |
Change Summary
Event-handler allows executing a custom script when in logs it
detects configured "pattern"
A simple implementation
Types of changes
Related Task(s)
Component(s) name
Proposed changes
How to test
cat hello.sh:
Expect
vyos-event-handle.service
Connect via ssh and check journalctl
check cat /tmp/hello.txt
Checklist: