Created
April 18, 2012 02:36
-
-
Save bryanthompson/2410717 to your computer and use it in GitHub Desktop.
Nagios Mailer using Amazon/SES and REE 1.8.7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 '[email protected],[email protected]' | |
desc 'Comma-separated list of recipients' | |
default '[email protected]' | |
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 <[email protected]>", | |
: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