Created
May 3, 2010 05:38
-
-
Save elubow/387799 to your computer and use it in GitHub Desktop.
This file contains 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
require 'rubygems' | |
require 'optparse' | |
require 'tinder' | |
NotificationConfig = { | |
:campfire => { | |
:subdomain => 'subdomain', | |
:email => '135abc0cd5e0124cdc2993c79ff83h897baae260f', | |
:pass => 'secret', | |
:room => 'Room', | |
:ssl => true | |
} | |
} | |
options = {} | |
optparse = OptionParser.new do |o| | |
o.banner = "Usage: printf \"%b\" \"<message>\" #{File.basename($0)} -s \"<subject>\"" | |
o.on('-s', '--subject <subject>', 'Subject to be pasted into Campfire') do |subject| | |
options[:subject] = subject | |
end | |
o.separator "" | |
o.on_tail('-h', '--help', 'Display this help screen') do | |
puts o | |
exit 1 | |
end | |
end | |
optparse.parse! | |
config = NotificationConfig[:campfire] | |
campfire = Tinder::Campfire.new(config[:subdomain], :ssl => config[:ssl]) | |
campfire.login config[:email], config[:pass] | |
room = campfire.find_room_by_name config[:room] | |
room.speak "Nagios Alert: #{options[:subject]}" | |
room.paste ARGF.read |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment