forked from flapjack/flapjack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.rake
59 lines (42 loc) · 1.67 KB
/
events.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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'
require 'flapjack/configuration'
require 'flapjack/data/event'
# 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.toml')
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 found in '#{config_file}'"
exit(false)
end
Flapjack.redis = Redis.new(@redis_config)
Flapjack::Data::Event.add({'entity' => 'clientx-app-01',
'check' => 'ping',
'type' => 'service',
'state' => 'ok',
'summary' => 'testing'})
sleep(8)
Flapjack::Data::Event.add({'entity' => 'clientx-app-01',
'check' => 'ping',
'type' => 'service',
'state' => 'critical',
'summary' => 'testing'})
sleep(8)
Flapjack::Data::Event.add({'entity' => 'clientx-app-01',
'check' => 'ping',
'type' => 'service',
'state' => 'ok',
'summary' => 'testing'})
end
end