Sha256: 9b4733d1ce62727213a9977afb50dc17bcabd1e4448d244136b15e5d2e8fac25

Contents?: true

Size: 927 Bytes

Versions: 50

Compression:

Stored size: 927 Bytes

Contents

# Configure your watches like this:
#
#   God.contact(:webhook) do |c|
#     c.name      = 'Tester'
#     c.hook_url  = 'http://hook/url'
#   end

require 'net/http'
require 'uri'

module God
  module Contacts

    class Webhook < Contact

      attr_accessor :hook_url

      def valid?
        valid = true
      end

      def notify(message, time, priority, category, host)
        begin
          data = {
            :message => message,
            :time => time,
            :priority => priority,
            :category => category,
            :host => host
          }

          uri = URI.parse(self.hook_url)
          Net::HTTP.post_form(uri, data)

          self.info = "sent webhook to #{self.hook_url}"
        rescue => e
          puts e.message
          puts e.backtrace.join("\n")

          self.info = "failed to send webhook to #{self.hook_url}: #{e.message}"
        end
      end

    end

  end
end

Version data entries

50 entries across 50 versions & 15 rubygems

Version Path
dguettler-god-0.7.13.2 lib/god/contacts/webhook.rb
dguettler-god-0.7.13.3 lib/god/contacts/webhook.rb
dunedain289-god-0.7.12.1 lib/god/contacts/webhook.rb
eric-god-0.7.10 lib/god/contacts/webhook.rb
eric-god-0.7.11 lib/god/contacts/webhook.rb
eric-god-0.7.12 lib/god/contacts/webhook.rb
eric-god-0.7.14 lib/god/contacts/webhook.rb
fotonauts-god-0.7.10 lib/god/contacts/webhook.rb
fotonauts-god-0.7.12 lib/god/contacts/webhook.rb
gordoncww-god-0.7.11.1 lib/god/contacts/webhook.rb
jreynolds-god-0.7.13 lib/god/contacts/webhook.rb
mathieuravaux-god-0.7.11 lib/god/contacts/webhook.rb
mojombo-god-0.7.10 lib/god/contacts/webhook.rb
mojombo-god-0.7.11 lib/god/contacts/webhook.rb
mojombo-god-0.7.12 lib/god/contacts/webhook.rb
mojombo-god-0.7.13 lib/god/contacts/webhook.rb
mojombo-god-0.7.14 lib/god/contacts/webhook.rb
mojombo-god-0.7.15 lib/god/contacts/webhook.rb
mojombo-god-0.7.16 lib/god/contacts/webhook.rb
mojombo-god-0.7.20 lib/god/contacts/webhook.rb