Sha256: 0d63d9a7f49e791bdb9bdc3b70b47b1a7a505183ed3db30df0c50b6950dc0c7d
Contents?: true
Size: 1.92 KB
Versions: 4
Compression:
Stored size: 1.92 KB
Contents
#!/usr/bin/env ruby # # Sensu Handler: campfire # # Copyright 2012, AJ Christensen <aj@junglist.gen.nz> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'sensu-handler' require 'tinder' # # Campfire # class Campfire < Sensu::Handler def incident_key @event['client']['name'] + '/' + @event['check']['name'] end def campfire Tinder::Campfire.new(settings['campfire']['account'], ssl: true, token: settings['campfire']['token']) end def room # #YELLOW unless settings['campfire']['room_id'].nil? # rubocop:disable UnlessElse return campfire.find_room_by_id(settings['campfire']['room_id']) else return campfire.find_room_by_name(settings['campfire']['room']) end end def handle # rubocop:disable all description = @event['notification'] || [ @event['client']['name'], @event['check']['name'], @event['check']['output'], @event['client']['address'], @event['client']['subscriptions'].join(',') ].join(' : ') begin timeout(3) do if room.speak("#{incident_key}: #{description}") puts 'campfire -- ' + @event['action'].capitalize + 'd incident -- ' + incident_key else puts 'campfire -- failed to ' + @event['action'] + ' incident -- ' + incident_key end end rescue Timeout::Error puts 'campfire -- timed out while attempting to ' + @event['action'] + ' a incident -- ' + incident_key end end end
Version data entries
4 entries across 4 versions & 1 rubygems