Sha256: 1939547e68a760363bf53b5c95194d6099106d10f1a1d9c60c54ea34a3ed76e0

Contents?: true

Size: 1.76 KB

Versions: 61

Compression:

Stored size: 1.76 KB

Contents

require 'redis'

namespace :events do

  # add lib to the default include path
  unless $:.include?(File.dirname(__FILE__) + '/../lib/')
    $: << File.dirname(__FILE__) + '/../lib'
  end

  require 'flapjack/configuration'
  require 'flapjack/data/event'
  require 'flapjack/data/entity_check'

  # FIXME: add arguments, make more flexible
  desc "send events to trigger some notifications"
  task :test_notification do

    FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'development'
    config_file = File.join('etc', 'flapjack_config.yaml')

    config = Flapjack::Configuration.new
    config.load( config_file )

    @config_env = config.all
    @redis_config = config.for_redis

    if @config_env.nil? || @config_env.empty?
      puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{config_file}'"
      exit(false)
    end

    redis = Redis.new(@redis_config)

    Flapjack::Data::Event.add({'entity'  => 'clientx-app-01',
                               'check'   => 'ping',
                               'type'    => 'service',
                               'state'   => 'ok',
                               'summary' => 'testing'}, :redis => redis)

    sleep(8)

    Flapjack::Data::Event.add({'entity'  => 'clientx-app-01',
                               'check'   => 'ping',
                               'type'    => 'service',
                               'state'   => 'critical',
                               'summary' => 'testing'}, :redis => redis)

    sleep(8)

    Flapjack::Data::Event.add({'entity'  => 'clientx-app-01',
                               'check'   => 'ping',
                               'type'    => 'service',
                               'state'   => 'ok',
                               'summary' => 'testing'}, :redis => redis)

  end


end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
flapjack-0.8.7 tasks/events.rake
flapjack-0.8.6 tasks/events.rake
flapjack-0.8.5 tasks/events.rake
flapjack-0.8.4 tasks/events.rake
flapjack-0.8.3 tasks/events.rake
flapjack-0.8.2 tasks/events.rake
flapjack-0.8.1 tasks/events.rake
flapjack-0.8.0 tasks/events.rake
flapjack-0.7.35 tasks/events.rake
flapjack-0.7.34 tasks/events.rake
flapjack-0.7.33 tasks/events.rake
flapjack-0.7.32 tasks/events.rake
flapjack-0.7.31 tasks/events.rake
flapjack-0.7.30 tasks/events.rake
flapjack-0.7.29 tasks/events.rake
flapjack-0.7.28 tasks/events.rake
flapjack-0.7.27 tasks/events.rake
flapjack-0.7.26 tasks/events.rake
flapjack-0.7.25 tasks/events.rake
flapjack-0.7.22 tasks/events.rake