dafiti-rabbit-hutch 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +56 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +68 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +2 -0
  7. data/bin/rabbithutch +1 -0
  8. data/bin/rabbithutchweb +6 -0
  9. data/config.yaml +14 -0
  10. data/configs/.config.yml.swp +0 -0
  11. data/configs/config.yaml +17 -0
  12. data/configs/config.yml +17 -0
  13. data/configs/config2.yaml +51 -0
  14. data/configs/config_old.yaml +28 -0
  15. data/configs/configtemplate.yaml +32 -0
  16. data/configs/webconfig.ru +4 -0
  17. data/dev_web.sh +1 -0
  18. data/lib/configurator.rb +38 -0
  19. data/lib/consumer.rb +32 -0
  20. data/lib/consumers/console_consumer.rb +21 -0
  21. data/lib/consumers/log4r_consumer.rb +36 -0
  22. data/lib/consumers/mongo_consumer.rb +35 -0
  23. data/lib/logger.rb +16 -0
  24. data/lib/rabbithutch.rb +78 -0
  25. data/lib/rabbithutchmgr.rb +48 -0
  26. data/lib/worker.rb +33 -0
  27. data/rabbithutch.gemspec +43 -0
  28. data/rabbithutchservice.rb +18 -0
  29. data/web/public/assets/css/bootstrap-responsive.css +1092 -0
  30. data/web/public/assets/css/bootstrap-responsive.min.css +9 -0
  31. data/web/public/assets/css/bootstrap.css +6046 -0
  32. data/web/public/assets/css/bootstrap.min.css +9 -0
  33. data/web/public/assets/css/main.css +30 -0
  34. data/web/public/assets/img/glyphicons-halflings-white.png +0 -0
  35. data/web/public/assets/img/glyphicons-halflings.png +0 -0
  36. data/web/public/assets/js/bootstrap.js +2159 -0
  37. data/web/public/assets/js/bootstrap.min.js +6 -0
  38. data/web/rabbithutchweb.rb +106 -0
  39. data/web/views/index.haml +50 -0
  40. data/web/views/layout.haml +65 -0
  41. data/web/views/manageconfig.haml +18 -0
  42. data/web/views/rabbitmqsettings.haml +37 -0
  43. metadata +313 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a67ec5f7dfd399853684ac15f0595b1b191504df84e8d9a127a744442c8894ad
4
+ data.tar.gz: 5fd0c3c15dbafc918620448965ad6f7dd495b87c5a8a0cd74a95ae68f8910aea
5
+ SHA512:
6
+ metadata.gz: 2dd9e88d56f1c07b72f0c552f89aea1b50710bfa341469b8e9f05725ed8138b72e74e35d0f2386a9d2210e3f2f563798527f992db181dcc4639073180ca9d5f9
7
+ data.tar.gz: bb7e2016a611ac7689a27bb9c188a16162f3f5a549cb1bd90a1161e9078664c9bdf3798d6ad5aeef370efb5122c7fee668cea1d6b07bea77f30125055d6eabf6
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hash-that-tree.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rabbithutch (0.1.6)
5
+ amqp
6
+ bson_ext
7
+ daemons
8
+ eventmachine
9
+ haml
10
+ log4r
11
+ logger
12
+ mongo
13
+ mongo_ext
14
+ mq
15
+ mustache
16
+ shotgun
17
+ sinatra
18
+ thin
19
+ thor
20
+ yard
21
+
22
+ GEM
23
+ remote: https://rubygems.org/
24
+ specs:
25
+ amq-client (0.9.10)
26
+ amq-protocol (>= 0.9.4)
27
+ eventmachine
28
+ amq-protocol (1.0.1)
29
+ amqp (0.9.8)
30
+ amq-client (~> 0.9.5)
31
+ amq-protocol (>= 0.9.4)
32
+ eventmachine
33
+ bson (1.8.2)
34
+ bson_ext (1.8.1)
35
+ bson (~> 1.8.1)
36
+ daemons (1.1.9)
37
+ eventmachine (1.0.0)
38
+ haml (3.1.7)
39
+ log4r (1.1.10)
40
+ logger (1.2.8)
41
+ mongo (1.8.1)
42
+ bson (~> 1.8.1)
43
+ mongo_ext (0.19.3)
44
+ mq (0.1.3)
45
+ mustache (0.99.4)
46
+ rack (1.4.4)
47
+ rack-protection (1.3.2)
48
+ rack
49
+ shotgun (0.9)
50
+ rack (>= 1.0)
51
+ sinatra (1.3.3)
52
+ rack (~> 1.3, >= 1.3.6)
53
+ rack-protection (~> 1.2)
54
+ tilt (~> 1.3, >= 1.3.3)
55
+ thin (1.5.0)
56
+ daemons (>= 1.0.9)
57
+ eventmachine (>= 0.12.6)
58
+ rack (>= 1.0.0)
59
+ thor (0.16.0)
60
+ tilt (1.3.3)
61
+ yard (0.8.3)
62
+
63
+ PLATFORMS
64
+ ruby
65
+ x86-mingw32
66
+
67
+ DEPENDENCIES
68
+ rabbithutch!
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 John Ryan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # rabbit-hutch
2
+ RabbitMq Trace Logger - Listen to multiple RabbitMq instances and log them to a single location or MongoDb database.
data/bin/rabbithutch ADDED
@@ -0,0 +1 @@
1
+ require_relative '../lib/rabbithutchservice.rb'
@@ -0,0 +1,6 @@
1
+ puts "============================="
2
+ puts "== Launching the rabbithutch web manager"
3
+ puts ">> Open the URL below to administer the rabbithutch service"
4
+ web_location = File.dirname(__FILE__) + '/../web/rabbithutchweb.rb'
5
+ system "shotgun #{web_location}"
6
+ puts "Finished"
data/config.yaml ADDED
@@ -0,0 +1,14 @@
1
+ ---
2
+ application:
3
+ exchangename: amq.rabbitmq.trace
4
+ queuename: rabbithutch
5
+ rabbitmq:
6
+ hosts:
7
+ - displayname: local1
8
+ enabled: true
9
+ hostname: localhost
10
+ username: admin
11
+ password: admin
12
+ consumers_config:
13
+ consumers:
14
+ - name: console_consumer
Binary file
@@ -0,0 +1,17 @@
1
+ application:
2
+ exchangename: amq.rabbitmq.trace
3
+ queuename: amq.gen-YxeA_wZnR8TsrqlRPEwNNQ
4
+
5
+ rabbitmq:
6
+ hosts:
7
+ - displayname: local1
8
+ enabled: true
9
+ hostname: localhost
10
+ username: admin
11
+ password: admin
12
+
13
+
14
+ consumers_config:
15
+ consumers:
16
+ - name: console_consumer
17
+
@@ -0,0 +1,17 @@
1
+ application:
2
+ exchangename: amq.rabbitmq.trace
3
+ queuename: amq.gen-YxeA_wZnR8TsrqlRPEwNNQ
4
+
5
+ rabbitmq:
6
+ hosts:
7
+ - displayname: local1
8
+ enabled: true
9
+ hostname: localhost:15672
10
+ username: admin
11
+ password: admin
12
+
13
+
14
+ consumers_config:
15
+ consumers:
16
+ - name: console_consumer
17
+
@@ -0,0 +1,51 @@
1
+ ---
2
+ application:
3
+ exchangename: amq.rabbitmq.trace
4
+ queuename: rabbithutch
5
+ rabbitmq:
6
+ hosts:
7
+ - id: 1
8
+ displayname: dev01dd
9
+ enabled: 'on'
10
+ hostname: 127.0.0.1dd
11
+ username: admind
12
+ password: admin
13
+ - id: 2
14
+ displayname: dev02e
15
+ enabled:
16
+ hostname: 127.0.0.23
17
+ username: admin
18
+ password:
19
+ - id: 3
20
+ displayname: QA
21
+ enabled: false
22
+ hostname: 127.0.0.3
23
+ username: admin
24
+ password: admin
25
+ - id: 4
26
+ displayname: STAGING
27
+ enabled: false
28
+ hostname: 127.0.0.4
29
+ username: admin
30
+ password: admin
31
+ - id: '7'
32
+ displayname: dev01dd
33
+ enabled: 'on'
34
+ hostname: ee
35
+ username: eee
36
+ password: eee
37
+ consumers_config:
38
+ consumers:
39
+ - name: console_consumer
40
+ enabled: true
41
+ - name: mongo_consumer
42
+ enabled: true
43
+ hostname: 127.0.0.1
44
+ username: admin
45
+ password: admin
46
+ database_prefix: rhutch_
47
+ port: 27017
48
+ - name: log4r_consumer
49
+ enabled: true
50
+ log_location: /tmp
51
+ log_prefix: rhutch_
@@ -0,0 +1,28 @@
1
+ application:
2
+ exchangename: amq.rabbitmq.trace
3
+ queuename: rabbithutch
4
+
5
+ rabbitmq:
6
+ hosts:
7
+ - id: 1
8
+ displayname: dev01
9
+ enabled: true
10
+ hostname: 127.0.0.1
11
+ username: admin
12
+ password: admin
13
+
14
+ consumers_config:
15
+ consumers:
16
+ - name: console_consumer
17
+ enabled: true
18
+ - name: mongo_consumer
19
+ enabled: true
20
+ hostname: 127.0.0.1
21
+ username: admin
22
+ password: admin
23
+ database_prefix: rhutch_
24
+ port: 27017
25
+ - name: log4r_consumer
26
+ enabled: true
27
+ log_location: /tmp
28
+ log_prefix: rhutch_
@@ -0,0 +1,32 @@
1
+ application:
2
+ exchangename: amq.rabbitmq.trace
3
+ queuename: rabbithutch
4
+
5
+ rabbitmq:
6
+ hosts:
7
+ - displayname: localserver
8
+ enabled: true
9
+ hostname: 127.0.0.1
10
+ username: admin
11
+ password: admin
12
+ - displayname: anotherserver
13
+ enabled: false
14
+ hostname: 127.0.0.2
15
+ username: admin
16
+ password: admin
17
+
18
+ consumers_config:
19
+ consumers:
20
+ - name: console_consumer
21
+ enabled: true
22
+ - name: mongo_consumer
23
+ enabled: true
24
+ hostname: 127.0.0.1
25
+ username: admin
26
+ password: admin
27
+ database_prefix: rhutch_
28
+ port: 27017
29
+ - name: log4r_consumer
30
+ enabled: true
31
+ log_location: /tmp
32
+ log_prefix: rhutch_
@@ -0,0 +1,4 @@
1
+ require 'sinatra'
2
+ require_relative "../web/rabbithutchweb"
3
+
4
+ run Sinatra::Application
data/dev_web.sh ADDED
@@ -0,0 +1 @@
1
+ shotgun ./web/rabbithutchweb.rb
@@ -0,0 +1,38 @@
1
+ require 'yaml'
2
+
3
+ module RabbitHutch
4
+ class Configurator
5
+
6
+ attr_accessor :config
7
+
8
+ def initialize options
9
+
10
+ file = options['config'] || (File.dirname(__FILE__) + '/../config.yaml')
11
+
12
+ puts "Using config from #{file}"
13
+
14
+ unless File.exists? file
15
+ raise "Configuration file [#{file}] doesn't exist"
16
+ end
17
+ @config = YAML::load(File.open(file))
18
+ end
19
+
20
+ def application
21
+ @config['application']
22
+ end
23
+
24
+ def log_config
25
+ @config['log4r_config']
26
+ end
27
+
28
+ def consumers
29
+ @config['consumers_config']["consumers"]
30
+ end
31
+
32
+ def rabbitmq_hosts
33
+ @config['rabbitmq']['hosts']
34
+ end
35
+
36
+ end
37
+ end
38
+
data/lib/consumer.rb ADDED
@@ -0,0 +1,32 @@
1
+ require "rubygems"
2
+ require_relative "configurator"
3
+ require_relative "consumers/mongo_consumer"
4
+
5
+ module RabbitHutch
6
+ # Controls the consumers that are to be kicked off based on the config file
7
+ class Consumer
8
+ def initialize(consumers)
9
+ @consumers = consumers
10
+ end
11
+
12
+ # Raised on receipt of a message from RabbitMq and uses the appropriate appender
13
+ def handle_message(metadata, payload)
14
+ # loop through appenders and fire each as required
15
+ @consumers.each do |consumer|
16
+ action = metadata.routing_key.split('.', 2).first
17
+ if(action == "publish")
18
+ exchange = metadata.attributes[:headers]["exchange_name"]
19
+ queue = metadata.routing_key.split('.', 2).last
20
+ item = {:date => Time.now,
21
+ :exchange => exchange,
22
+ :queue => queue,
23
+ :routing_keys => metadata.attributes[:headers]["routing_keys"].inspect,
24
+ :attributes => metadata.attributes.inspect,
25
+ :payload => payload.inspect
26
+ }
27
+ consumer.log_event(item)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require "mongo"
4
+
5
+ module RabbitHutch
6
+ class ConsoleConsumer
7
+
8
+ def initialize()
9
+ puts "\tInitializing Console Consumer"
10
+ end
11
+
12
+ def log_event(item)
13
+ begin
14
+ puts "console"
15
+ puts item
16
+ rescue Exception => e
17
+ puts "Error occurred Message Handler trying to write messages to Log #{e.inspect}"
18
+ end
19
+ end
20
+ end
21
+ end