-
Notifications
You must be signed in to change notification settings - Fork 117
Description
The following is really a request to get feedback on an idea I have, before I begin any work implementing it. This all depends on #55 being accepted, i.e allowing handlers to accept command-line options.
I've been thinking about how to allow handlers to have multiple configuration sections defined in the config json. This would be useful for handlers like mailer or xmpp, where you might want to have different handlers alerting different users, but not want to have to modify the handler code each time.
I'd like to propose a command-line option, set in sensu-plugin, which is then inherited by handlers - lets call this 'jsonconfig' for now (name isn't important). It's default value would be the name of the handler. It can then be overridden to point to a differently named section when the handler is used, e.g:
/etc/sensu/handlers/notification/mailer.rb --jsonconfig mailer-devteam
'mailer-devteam' in the json config would contain email configuration options for the development team, while 'mailer' (the default) would email the production team.
It would be easy to change handlers on a case-by-case basis, switching them from having hard-coded config paths to using this variable.
For example, mailer.rb currently has:
mail_to = settings['mailer']['mail_to']
This would change to something like:
mail_to = settings[config[:jsonconfig]]['mail_to']
I'm happy to write the code for this, and also to update any documentation. I'd also be making changes to at least some of the community handlers to support this for my own use, mailer and xmpp, but perhaps others if the changes are minimal.
Thoughts, comments, input etc appreciated!