Sha256: e3c86d5f762025c9e2d5e222372009b13728e94519ac2cefdde37e30c4bf8b14

Contents?: true

Size: 1.66 KB

Versions: 7

Compression:

Stored size: 1.66 KB

Contents

require 'redis'

namespace :events do

  # FIXME: add arguments, make more flexible
  desc "send events to trigger some notifications"
  task :test_notification 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'

    FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'development'
    config_file = File.join('etc', 'flapjack_config.yaml')
    @config, @redis_config = Flapjack::Configuration.new.load( config_file )

    if @config.nil? || @config.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

7 entries across 7 versions & 1 rubygems

Version Path
flapjack-0.6.46 tasks/events.rake
flapjack-0.6.45 tasks/events.rake
flapjack-0.6.44 tasks/events.rake
flapjack-0.6.43 tasks/events.rake
flapjack-0.6.42 tasks/events.rake
flapjack-0.6.41 tasks/events.rake
flapjack-0.6.40 tasks/events.rake