Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Allow for multiple email addresses.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjlandau committed Oct 26, 2009
1 parent cb4275d commit 89fce90
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/site.rb
Expand Up @@ -13,7 +13,8 @@ def self.email
email_name_regex = '[A-Z0-9_\.%\+\-]+' email_name_regex = '[A-Z0-9_\.%\+\-]+'
domain_head_regex = '(?:[A-Z0-9\-]+\.)+' domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)' 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
end end


Expand Down
2 changes: 2 additions & 0 deletions app/templates/monit_check.mustache
Expand Up @@ -3,8 +3,10 @@ check host {{monit_check_name}} with address {{host_name}}
{{#match_text?}}and content == "{{match_text}}" {{/match_text?}} {{#match_text?}}and content == "{{match_text}}" {{/match_text?}}
for {{threshold}} cycles for {{threshold}} cycles
then alert then alert
{{#emails}}
alert {{email}} with mail-format { alert {{email}} with mail-format {
subject: [WATCH DOG] $EVENT for {{site_name}} subject: [WATCH DOG] $EVENT for {{site_name}}
message: As of $DATE {{site_name}} is $EVENT: message: As of $DATE {{site_name}} is $EVENT:
$DESCRIPTION $DESCRIPTION
} }
{{/emails}}
4 changes: 4 additions & 0 deletions app/views/monit_check.rb
Expand Up @@ -22,6 +22,10 @@ def url
@site.url @site.url
end end


def emails
@site.email.split(/\s*,\s*/).map {|e| {:email => e} }
end

def threshold def threshold
@site.threshold @site.threshold
end end
Expand Down

0 comments on commit 89fce90

Please sign in to comment.