Sha256: aea9d38c6f473856e32e61e8010e0de5e82e78ed7e3412b881abed13ddafbf04

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

#!/usr/bin/env ruby

require 'sensu-handler'
require 'timeout'
require 'im-kayac'

class ImkayacNotif < Sensu::Handler
  def event_name
    @event['client']['name'] + '/' + @event['check']['name']
  end

  def event_action
    @event['action']
  end

  def handle
    user = settings['imkayac']['user']
    pass = settings['imkayac']['pass']
    message = @event['check']['notification'] || @event['check']['output']
    begin
      timeout(3) do
        p ImKayac.to(user.to_s).password(pass.to_s).post("#{event_action} - #{event_name} - #{message}")
      end
    rescue Timeout::Error
      puts 'im.kayac -- timed out while attempting to message'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sensu-plugins-imkayac-1.0.0 bin/handler-imkayac.rb