Permalink
Browse files

Allow for multiple email addresses.

  • Loading branch information...
1 parent cb4275d commit 89fce9020115e2089efa122cd8528e50e0e6601e @brianjlandau brianjlandau committed Oct 26, 2009
Showing with 8 additions and 1 deletion.
  1. +2 −1 app/models/site.rb
  2. +2 −0 app/templates/monit_check.mustache
  3. +4 −0 app/views/monit_check.rb
View
@@ -13,7 +13,8 @@ def self.email
email_name_regex = '[A-Z0-9_\.%\+\-]+'
domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
- /\A#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}\z/i
+ full_email = "#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}"
+ /^#{full_email}(\s*,\s*#{full_email})*$/i
end
end
@@ -3,8 +3,10 @@ check host {{monit_check_name}} with address {{host_name}}
{{#match_text?}}and content == "{{match_text}}" {{/match_text?}}
for {{threshold}} cycles
then alert
+ {{#emails}}
alert {{email}} with mail-format {
subject: [WATCH DOG] $EVENT for {{site_name}}
message: As of $DATE {{site_name}} is $EVENT:
$DESCRIPTION
}
+ {{/emails}}
View
@@ -22,6 +22,10 @@ def url
@site.url
end
+ def emails
+ @site.email.split(/\s*,\s*/).map {|e| {:email => e} }
+ end
+
def threshold
@site.threshold
end

0 comments on commit 89fce90

Please sign in to comment.