wakame-dolphin 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +4 -0
  4. data/.travis.yml +25 -0
  5. data/Gemfile +18 -0
  6. data/Makefile +56 -0
  7. data/README.md +77 -0
  8. data/Rakefile +67 -0
  9. data/bin/dolphin_server +98 -0
  10. data/config/db/cassandra_clear.txt +1 -0
  11. data/config/db/cassandra_schema.txt +14 -0
  12. data/config/db/sequel/migrations/0001_add_notification.rb +15 -0
  13. data/config/db/sequel/migrations/0002_add_event.rb +15 -0
  14. data/config/dolphin-mysql.conf.travis +26 -0
  15. data/config/dolphin.conf.example +26 -0
  16. data/lib/dolphin.rb +148 -0
  17. data/lib/dolphin/data_store.rb +55 -0
  18. data/lib/dolphin/data_stores/base_rdb.rb +57 -0
  19. data/lib/dolphin/data_stores/cassandra.rb +98 -0
  20. data/lib/dolphin/data_stores/mysql.rb +31 -0
  21. data/lib/dolphin/helpers/message/zabbix_helper.rb +16 -0
  22. data/lib/dolphin/helpers/request_helper.rb +72 -0
  23. data/lib/dolphin/mailer.rb +83 -0
  24. data/lib/dolphin/manager.rb +35 -0
  25. data/lib/dolphin/message_builder.rb +98 -0
  26. data/lib/dolphin/models/base.rb +8 -0
  27. data/lib/dolphin/models/cassandra/base.rb +11 -0
  28. data/lib/dolphin/models/cassandra/event.rb +42 -0
  29. data/lib/dolphin/models/cassandra/notification.rb +28 -0
  30. data/lib/dolphin/models/rdb/base.rb +12 -0
  31. data/lib/dolphin/models/rdb/event.rb +47 -0
  32. data/lib/dolphin/models/rdb/notification.rb +27 -0
  33. data/lib/dolphin/models/rdb/orm/base.rb +10 -0
  34. data/lib/dolphin/models/rdb/orm/event.rb +8 -0
  35. data/lib/dolphin/models/rdb/orm/notification.rb +8 -0
  36. data/lib/dolphin/query_processor.rb +50 -0
  37. data/lib/dolphin/request_handler.rb +150 -0
  38. data/lib/dolphin/sender.rb +47 -0
  39. data/lib/dolphin/util.rb +18 -0
  40. data/lib/dolphin/version.rb +3 -0
  41. data/lib/dolphin/worker.rb +149 -0
  42. data/script/console +13 -0
  43. data/spec/files/cassandra_models_spec.rb +127 -0
  44. data/spec/files/dolphin_spec.rb +110 -0
  45. data/spec/files/endpoint/event_spec.rb +123 -0
  46. data/spec/files/endpoint/notification_spec.rb +54 -0
  47. data/spec/files/message_builder_spec.rb +15 -0
  48. data/spec/helpers/test_helper.rb +21 -0
  49. data/spec/helpers/web_request_helper.rb +40 -0
  50. data/spec/spec_helper.rb +18 -0
  51. data/templates/email/alert_port.erb +24 -0
  52. data/templates/email/default.erb +3 -0
  53. data/tests/test_dolphin +10 -0
  54. data/tests/test_get_event +31 -0
  55. data/tests/test_get_notification +27 -0
  56. data/tests/test_post_event +37 -0
  57. data/tests/test_post_notification +43 -0
  58. data/wakame-dolphin.gemspec +40 -0
  59. metadata +311 -0
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'json'
7
+
8
+ host = ENV['DOLPHIN_HOST'] || '127.0.0.1'
9
+ port = ENV['DOLPHIN_PORT'] || 9004
10
+
11
+ path = "http://#{host}:#{port}/notifications"
12
+
13
+ uri = URI.parse(path)
14
+
15
+ headers = {
16
+ 'Content-Type' =>'application/json',
17
+ 'X-Notification-Id' => 'system',
18
+ }
19
+
20
+ request = Net::HTTP::Get.new(uri.request_uri, headers)
21
+ http = Net::HTTP.new(uri.host, uri.port)
22
+ http.set_debug_output $stderr
23
+ http.start do |h|
24
+ response = h.request(request)
25
+ res = JSON.parse(response.body)
26
+ p res
27
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'json'
7
+
8
+ host = ENV['DOLPHIN_HOST'] || '127.0.0.1'
9
+ port = ENV['DOLPHIN_PORT'] || 9004
10
+
11
+ path = "http://#{host}:#{port}/events"
12
+ uri = URI.parse(path)
13
+
14
+ headers = {
15
+ 'Content-Type' =>'application/json',
16
+ 'X-Notification-Id' => 'system',
17
+ 'X-Message-Type' => 'alert_port'
18
+ }
19
+
20
+ messages = {
21
+ 'instance_id' => 'i-abcdefgh',
22
+ 'instance_name' => 'test',
23
+ 'instance_ip' => '127.0.0.1',
24
+ 'account_id' => 'a-abcdefgh',
25
+ 'event_datetime' => Time.now,
26
+ 'message' => 'Alert!!!!'
27
+ }
28
+ request = Net::HTTP::Post.new(uri.request_uri, headers)
29
+
30
+ request.body = messages.to_json
31
+
32
+ http = Net::HTTP.new(uri.host, uri.port)
33
+ http.set_debug_output $stderr
34
+ http.start do |h|
35
+ response = h.request(request)
36
+ puts JSON.parse(response.body)
37
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'json'
7
+
8
+ host = ENV['DOLPHIN_HOST'] || '127.0.0.1'
9
+ port = ENV['DOLPHIN_PORT'] || 9004
10
+ mail_to = ENV['MAIL_TO']
11
+ mail_cc = ENV['MAIL_CC']
12
+ mail_bcc = ENV['MAIL_BCC']
13
+
14
+ mail_to ||= 'foo@example.com,bar@example.com'
15
+ mail_cc ||= 'foo@example.com,bar@example.com'
16
+ mail_bcc ||= 'foofoo@example.com,barbar@example.com'
17
+
18
+ path = "http://#{host}:#{port}/notifications"
19
+ uri = URI.parse(path)
20
+
21
+ headers = {
22
+ 'Content-Type' =>'application/json',
23
+ 'X-Notification-Id' => 'system',
24
+ }
25
+
26
+ methods = {
27
+ 'email' => {
28
+ 'to' => mail_to,
29
+ }
30
+ }
31
+
32
+ methods['email']['cc'] = mail_cc unless mail_cc.empty?
33
+ methods['email']['bcc'] = mail_bcc unless mail_bcc.empty?
34
+
35
+ request = Net::HTTP::Post.new(uri.request_uri, headers)
36
+ request.body = methods.to_json
37
+
38
+ http = Net::HTTP.new(uri.host, uri.port)
39
+ http.set_debug_output $stderr
40
+ http.start do |h|
41
+ response = h.request(request)
42
+ puts JSON.parse(response.body)
43
+ end
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'wakame-dolphin'
6
+ spec.version = '0.0.2'
7
+ spec.platform = Gem::Platform::RUBY
8
+ spec.summary = 'notification service'
9
+ spec.description = 'notification service'
10
+ spec.licenses = ['LGPL 3.0']
11
+
12
+ spec.authors = ['axsh Ltd.']
13
+ spec.email = ['dev@axsh.net']
14
+ spec.homepage = 'https://github.com/axsh/wakame-dolphin'
15
+
16
+ spec.required_ruby_version = '>= 1.9.3'
17
+ spec.required_rubygems_version = '>= 1.3.6'
18
+
19
+ spec.files = `git ls-files`.split($/)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(tests|spec)/})
22
+ spec.require_path = ['lib']
23
+
24
+ spec.add_runtime_dependency 'reel', '= 0.3.0'
25
+ spec.add_runtime_dependency 'actionmailer', '= 3.2.12'
26
+ spec.add_runtime_dependency 'ltsv', '= 0.1.0'
27
+ spec.add_runtime_dependency 'extlib', '~> 0.9.16'
28
+ spec.add_runtime_dependency 'multi_json', '1.6.1'
29
+ spec.add_runtime_dependency 'rake', '= 10.0.3'
30
+ spec.add_runtime_dependency 'octarine', '= 0.0.3'
31
+ spec.add_runtime_dependency 'parseconfig', '= 1.0.2'
32
+ spec.add_runtime_dependency 'erubis', '= 2.7.0'
33
+ spec.add_runtime_dependency 'mail-iso-2022-jp', '= 2.0.1'
34
+ spec.add_runtime_dependency 'simple_uuid', '= 0.2.0'
35
+
36
+ # Fixed version for reel
37
+ spec.add_runtime_dependency 'celluloid', '= 0.12.4'
38
+ spec.add_runtime_dependency 'celluloid-io', '= 0.12.1'
39
+ spec.add_runtime_dependency 'nio4r', '= 0.4.3'
40
+ end
metadata ADDED
@@ -0,0 +1,311 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wakame-dolphin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - axsh Ltd.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: reel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionmailer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.12
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.12
41
+ - !ruby/object:Gem::Dependency
42
+ name: ltsv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: extlib
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.16
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.16
69
+ - !ruby/object:Gem::Dependency
70
+ name: multi_json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.6.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.6.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 10.0.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 10.0.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: octarine
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.0.3
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.0.3
111
+ - !ruby/object:Gem::Dependency
112
+ name: parseconfig
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.0.2
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.0.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: erubis
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 2.7.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 2.7.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: mail-iso-2022-jp
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 2.0.1
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 2.0.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: simple_uuid
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 0.2.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 0.2.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: celluloid
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.12.4
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 0.12.4
181
+ - !ruby/object:Gem::Dependency
182
+ name: celluloid-io
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 0.12.1
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 0.12.1
195
+ - !ruby/object:Gem::Dependency
196
+ name: nio4r
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '='
200
+ - !ruby/object:Gem::Version
201
+ version: 0.4.3
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '='
207
+ - !ruby/object:Gem::Version
208
+ version: 0.4.3
209
+ description: notification service
210
+ email:
211
+ - dev@axsh.net
212
+ executables:
213
+ - dolphin_server
214
+ extensions: []
215
+ extra_rdoc_files: []
216
+ files:
217
+ - .gitignore
218
+ - .rspec
219
+ - .travis.yml
220
+ - Gemfile
221
+ - Makefile
222
+ - README.md
223
+ - Rakefile
224
+ - bin/dolphin_server
225
+ - config/db/cassandra_clear.txt
226
+ - config/db/cassandra_schema.txt
227
+ - config/db/sequel/migrations/0001_add_notification.rb
228
+ - config/db/sequel/migrations/0002_add_event.rb
229
+ - config/dolphin-mysql.conf.travis
230
+ - config/dolphin.conf.example
231
+ - lib/dolphin.rb
232
+ - lib/dolphin/data_store.rb
233
+ - lib/dolphin/data_stores/base_rdb.rb
234
+ - lib/dolphin/data_stores/cassandra.rb
235
+ - lib/dolphin/data_stores/mysql.rb
236
+ - lib/dolphin/helpers/message/zabbix_helper.rb
237
+ - lib/dolphin/helpers/request_helper.rb
238
+ - lib/dolphin/mailer.rb
239
+ - lib/dolphin/manager.rb
240
+ - lib/dolphin/message_builder.rb
241
+ - lib/dolphin/models/base.rb
242
+ - lib/dolphin/models/cassandra/base.rb
243
+ - lib/dolphin/models/cassandra/event.rb
244
+ - lib/dolphin/models/cassandra/notification.rb
245
+ - lib/dolphin/models/rdb/base.rb
246
+ - lib/dolphin/models/rdb/event.rb
247
+ - lib/dolphin/models/rdb/notification.rb
248
+ - lib/dolphin/models/rdb/orm/base.rb
249
+ - lib/dolphin/models/rdb/orm/event.rb
250
+ - lib/dolphin/models/rdb/orm/notification.rb
251
+ - lib/dolphin/query_processor.rb
252
+ - lib/dolphin/request_handler.rb
253
+ - lib/dolphin/sender.rb
254
+ - lib/dolphin/util.rb
255
+ - lib/dolphin/version.rb
256
+ - lib/dolphin/worker.rb
257
+ - script/console
258
+ - spec/files/cassandra_models_spec.rb
259
+ - spec/files/dolphin_spec.rb
260
+ - spec/files/endpoint/event_spec.rb
261
+ - spec/files/endpoint/notification_spec.rb
262
+ - spec/files/message_builder_spec.rb
263
+ - spec/helpers/test_helper.rb
264
+ - spec/helpers/web_request_helper.rb
265
+ - spec/spec_helper.rb
266
+ - templates/email/alert_port.erb
267
+ - templates/email/default.erb
268
+ - tests/test_dolphin
269
+ - tests/test_get_event
270
+ - tests/test_get_notification
271
+ - tests/test_post_event
272
+ - tests/test_post_notification
273
+ - wakame-dolphin.gemspec
274
+ homepage: https://github.com/axsh/wakame-dolphin
275
+ licenses:
276
+ - LGPL 3.0
277
+ metadata: {}
278
+ post_install_message:
279
+ rdoc_options: []
280
+ require_paths:
281
+ - - lib
282
+ required_ruby_version: !ruby/object:Gem::Requirement
283
+ requirements:
284
+ - - '>='
285
+ - !ruby/object:Gem::Version
286
+ version: 1.9.3
287
+ required_rubygems_version: !ruby/object:Gem::Requirement
288
+ requirements:
289
+ - - '>='
290
+ - !ruby/object:Gem::Version
291
+ version: 1.3.6
292
+ requirements: []
293
+ rubyforge_project:
294
+ rubygems_version: 2.0.3
295
+ signing_key:
296
+ specification_version: 4
297
+ summary: notification service
298
+ test_files:
299
+ - spec/files/cassandra_models_spec.rb
300
+ - spec/files/dolphin_spec.rb
301
+ - spec/files/endpoint/event_spec.rb
302
+ - spec/files/endpoint/notification_spec.rb
303
+ - spec/files/message_builder_spec.rb
304
+ - spec/helpers/test_helper.rb
305
+ - spec/helpers/web_request_helper.rb
306
+ - spec/spec_helper.rb
307
+ - tests/test_dolphin
308
+ - tests/test_get_event
309
+ - tests/test_get_notification
310
+ - tests/test_post_event
311
+ - tests/test_post_notification