Skip to content

Instantly share code, notes, and snippets.

@bryanthompson
Created April 18, 2012 02:36
Show Gist options
  • Save bryanthompson/2410717 to your computer and use it in GitHub Desktop.
Save bryanthompson/2410717 to your computer and use it in GitHub Desktop.
Nagios Mailer using Amazon/SES and REE 1.8.7
[root@puppet nagios]# cat /bin/mailer
#!/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby
require "rubygems"
require "choice"
require "amazon-ses-mailer"
PROGRAM_VERSION = 1
Choice.options do
option :subject do
short '-s'
long '--subject="Email notification subject"'
desc 'The subject to use in this message'
default 'Server Alert'
end
option :body do
short '-b'
long '--body=BODY'
desc 'Notification message'
end
option :recipients do
short '-r'
long '--recipients=recipient@email.com,recipient2@email.com'
desc 'Comma-separated list of recipients'
default 'support@madebymarket.com'
end
option :help do
long '--help'
desc 'Show this message'
end
option :version do
short '-v'
long '--version'
desc 'Show version'
action do
puts "nagios-ses-mailer v#{PROGRAM_VERSION}"
exit
end
end
end
mailer = AmazonSes::Mailer.new(:secret_key => "AWS_SECRET",
:access_key => "AWS_ACCESS")
delivery = mailer.deliver(:to => Choice[:recipients],
:from => "Server Alert <notice@madebymarket.com>",
:subject => Choice[:subject],
:content_type => "text/plain",
:body => CGI.parse(Choice[:body]) )
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment