Sha256: 0d6c403dbfd6d61882e6cbbed7b55e17a39a02a53cc8d31c79fd20094fc7f53d

Contents?: true

Size: 673 Bytes

Versions: 2

Compression:

Stored size: 673 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}").password("#{pass}").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

2 entries across 2 versions & 1 rubygems

Version Path
sensu-plugins-imkayac-0.0.2 bin/imkayac.rb
sensu-plugins-imkayac-0.0.1 bin/imkayac.rb