From 6a0432709b33cc6b70731e45908e5baba223adf1 Mon Sep 17 00:00:00 2001 From: Greg Musick Date: Tue, 4 Feb 2014 13:32:46 -0800 Subject: [PATCH] Allow multiple emails to be alerted to --- attributes/default.rb | 3 ++- templates/default/monitrc.erb | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 8628a58..0a23f5e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,5 +1,6 @@ default[:monit][:send_alerts] = true -default[:monit][:notify_email] = "notify@example.com" +default[:monit][:notify_email] = nil +default[:monit][:notify_emails] = [] default[:monit][:poll_period] = 60 default[:monit][:poll_start_delay] = 120 diff --git a/templates/default/monitrc.erb b/templates/default/monitrc.erb index c31d958..1e78c1b 100755 --- a/templates/default/monitrc.erb +++ b/templates/default/monitrc.erb @@ -21,15 +21,19 @@ set logfile syslog facility log_daemon with <%= @node[:monit][:mailserver][:with] %> <% end %> - set mail-format { from: <%= @node[:monit][:mail_format][:from] %> subject: <%= @node[:monit][:mail_format][:subject] %> message: <%= @node[:monit][:mail_format][:message] %> } - set alert <%= @node[:monit][:notify_email] %> NOT ON { action, instance, pid, ppid } + <% if @node[:monit][:notify_email] %> + set alert <%= @node[:monit][:notify_email] %> NOT ON { action, instance, pid, ppid } + <% end %> + <% @node[:monit][:notify_emails].each do |email| %> + set alert <%= email %> NOT ON { action, instance, pid, ppid } + <% end %> <% end %> set eventqueue