Sha256: edb960adcc084ed99855de69be3237bd077fa8bc3186fcf311fa17fe7155a38f

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

require 'json'
require 'open-uri'
require "active_support/time"

require 'snowman-io/notifiers/slack'

module SnowmanIO
  class Check
    include Checks::HostedGraphite

    DEFAULT_INTERVAL = 1.minute
    class << self
      def interval(value = nil)
        if value
          @interval = value
        else
          @interval || DEFAULT_INTERVAL
        end
      end

      def human(value = nil)
        if value
          @human = value
        else
          self.name + ": #{@human}"
        end
      end

      def notifiers
        @notifiers ||= [Notifiers::Slack].select { |notifier| notifier.configured? }
      end
    end

    def perform
      if ok?
        status = "success"
        message = self.class.human + " - OK"
      else
        status = "failed"
        message = self.class.human + " - FAIL"
      end
      CheckResult.new(self.class, status, message)
    end

    def ok?
      raise "Implement ok? in check class"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snowman-io-0.0.4 lib/snowman-io/check.rb