sensu-plugins / sensu-plugins-mailer

This plugin is an email handler for Sensu.
http://sensu-plugins.io
MIT License
17 stars 37 forks source link

Add ability to mail based on the client #38

Closed Evesy closed 7 years ago

Evesy commented 8 years ago

General

We check a number of aggregates by running a check-aggregate ruby script on our Sensu server against the Sensu API. All these checks use a roundrobin 'control' subscription that the Sensu server is subscribed to; and these checks make use of the proxy client feature to provide a meaningful client name for the check rather than displaying the Sensu server address.

There is a need to be able to alert specifically to different people for different aggregates (and thus different clients). The current scope of this script does not cover our use case (Alerting off the subscription is too broad & with a proxy client it does not have any subscriptions itself). The proposed change will allow an extra hash in the json config which will be used to build mailing lists off the client name returned in the check data.

Sample config

{
  "mailer": {
    "mail_from": "sensu@example.com",
    "mail_to": "monitor@example.com",
    "smtp_address": "smtp.example.org",
    "smtp_port": "25",
    "smtp_domain": "example.org",
    "template": "/optional/path/to/template.erb",
    "subscriptions": {
      "subscription_name": {
        "mail_to": "teamemail@example.com"
      }
    },
    "clients": {
      "client_name": {
        "mail_to": "teamemail2@example.com"
      }
    }
  }
}

Known Compatablity Issues

This will not cause any existing compatibility issues, the new block of code will only be executed should a user update their mailer json to include the new key.

Note: This code works but could probably be more elegant so feel free to suggest any improvements.

Cheers.

Evesy commented 7 years ago

Closing this as it no longer seems like the right approach to take.