growl-amqp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,44 @@
1
+ This package includes an AMQP icon from www.amqp.org, the AMQP public website.
2
+ The icon is distributed under the following license, obtained from
3
+ http://www.amqp.org/confluence/display/AMQP/Terms+of+Use. This license
4
+ does not apply to the software, which is public domain.
5
+
6
+ Terms and Conditions
7
+
8
+ AS USED HEREIN, THE TERM "YOU" SHALL MEAN ANY VISITOR TO THE WEBSITE.
9
+
10
+ PLEASE READ THESE TERMS AND CONDITIONS CAREFULLY. BY ACCESSING THIS WEBSITE YOU
11
+ AGREE TO BE BOUND BY THE TERMS AND CONDITIONS BELOW. THESE TERMS AND CONDITIONS
12
+ ARE SUBJECT TO CHANGE WITHOUT NOTICE, FROM TIME TO TIME IN OUR SOLE DISCRETION.
13
+ WE WILL NOTIFY YOU OF AMENDMENTS TO THESE TERMS AND CONDITIONS BY POSTING THEM
14
+ TO THIS WEBSITE. IF YOU DO NOT AGREE WITH THESE TERMS AND CONDITIONS, PLEASE DO
15
+ NOT ACCESS THIS WEBSITE.
16
+
17
+ You are strictly prohibited from unauthorized use of our systems or this
18
+ website, including but not limited to unauthorized entry into our systems,
19
+ misuse of passwords, or misuse of any information posted to this website.
20
+ Copyright Notice
21
+
22
+ © Copyright 2005-2009 AMQP Working Group. All rights reserved.
23
+
24
+ The participants in the AMQP Working Group (collectively the "AMQP Working
25
+ Group") are:
26
+
27
+ Bank of America, N.A., Barclays Bank PLC, Cisco Systems, Credit Suisse, Deutsche
28
+ Börse Systems, Envoy Technologies Inc.,Goldman Sachs, IONA Technologies PLC,
29
+ iMatix Corporation sprl.,JPMorgan Chase Bank Inc. N.A, Microsoft Corporation,
30
+ Novell, Rabbit Technologies Ltd., Red Hat Inc., Solace Systems Inc., Tervela
31
+ Inc., TWIST Process Innovations Ltd, WS02 Inc. and 29West Inc.
32
+
33
+ The works of authorship contained in this website, including but not limited to
34
+ all design, text, and images, are owned, or used under license by the AMQP
35
+ Working Group.
36
+
37
+ AMQP Working Group hereby grants you a limited copyright license to download,
38
+ evaluate, copy and distribute posted and available documents and related
39
+ graphics delivered from this AMQP Working Group website ("Content") provided
40
+ that you: (1) include the above copyright notice in all copies; (2) do not
41
+ modify the Content; and (3) use the Content for evaluation purposes or for
42
+ inclusion in collateral materials (i.e. advertising, articles, product briefs,
43
+ marketing and sales materials) on AMQP technology; except where the Content
44
+ bears a license with more favourable terms.
@@ -0,0 +1,29 @@
1
+ # GrowlAMQP
2
+
3
+ Display AMQP messages in growl.
4
+
5
+ The built in binary, 'growlamqp', will run out-of-the-box to report
6
+ messages with non-binary data. It looks like this:
7
+
8
+ ### growlamqp example
9
+ $ growlamqp -e amq.direct -k my.key.name
10
+ $
11
+
12
+ If your data requires post-processing, or you only want to see some data,
13
+ write a wrapper script. Return whatever you want and growl will print it.
14
+ Return nil and it won't print it.
15
+
16
+ ### queuemon
17
+
18
+ # queuemon
19
+ #!/usr/bin/env ruby
20
+ require 'growlamqp'
21
+ require 'bert'
22
+
23
+ GrowlAMQP.monitor! do | msg |
24
+ BERT.decode(msg)
25
+ end
26
+
27
+ The file 'queuemon' is now a workable executable,
28
+ complete with config files, command line options,
29
+ and more. Enjoy.
@@ -0,0 +1,28 @@
1
+ Please note that this only applies to the software in this package.
2
+ An additional image has been added, distribued under the accompanying
3
+ LICENSE file.
4
+
5
+ This is free and unencumbered software released into the public domain.
6
+
7
+ Anyone is free to copy, modify, publish, use, compile, sell, or
8
+ distribute this software, either in source code form or as a compiled
9
+ binary, for any purpose, commercial or non-commercial, and by any
10
+ means.
11
+
12
+ In jurisdictions that recognize copyright laws, the author or authors
13
+ of this software dedicate any and all copyright interest in the
14
+ software to the public domain. We make this dedication for the benefit
15
+ of the public at large and to the detriment of our heirs and
16
+ successors. We intend this dedication to be an overt act of
17
+ relinquishment in perpetuity of all present and future rights to this
18
+ software under copyright law.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26
+ OTHER DEALINGS IN THE SOFTWARE.
27
+
28
+ For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: . unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
4
+ require 'growl-amqp'
5
+
6
+ GrowlAMQP.monitor!
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: . unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
4
+ require 'bert'
5
+ require 'growl-amqp'
6
+
7
+ GrowlAMQP.monitor! do | msg |
8
+ BERT.decode(msg)
9
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: . unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
4
+ require 'bert'
5
+ require 'growl-amqp'
6
+
7
+ GrowlAMQP.monitor!(:host => "example.org") do | msg |
8
+ msg
9
+ end
@@ -0,0 +1,122 @@
1
+
2
+ require 'amqp'
3
+ require 'mq'
4
+ require 'growl'
5
+ require 'daemons'
6
+
7
+
8
+ module GrowlAMQP
9
+
10
+ # monitor a given AMQP stream
11
+ # the given_opts may contain options for AMQP.start!
12
+ # and also :queue, :exchange, :vhost, :user, :pass,
13
+ # :routing_key, :file, and :ontop.
14
+ def monitor!(given_opts = nil, &block)
15
+
16
+ # default options
17
+ opts = {}
18
+ unless given_opts
19
+ opts[:exchange] = 'amq.fanout'
20
+ opts[:queue] = 'amqpgrowl'
21
+ end
22
+
23
+ parser = OptionParser.new do | o |
24
+ o.banner = "Usage: #{File.basename($0)} [OPTIONS] <start|stop>"
25
+ o.banner = "Relay AMQP messages via growl. Handy for debugging AMQP applications."
26
+
27
+ o.on('-q','--queue <queue>','The name of the AMQP queue to subscribe to') do | queue |
28
+ opts[:queue] = queue
29
+ end
30
+
31
+ o.on('-e','--exchange <exchange>','The name of the AMQP exchange to bind to. Can be specified multiple times') do | exch |
32
+ opts[:exchange] = exch
33
+ end
34
+
35
+ o.on('-k','--key <routing key>','The routing key to bind to (on diret and topic exchanges)') do | key |
36
+ opts[:key] = key
37
+ end
38
+
39
+ o.on('-v','--vhost <vhost>','The name of the AMQP vhost to connect to') do | vhost |
40
+ opts[:vhost] = vhost
41
+ end
42
+
43
+ o.on('-r','--remote <host>','The AMQP broker hostname') do | host |
44
+ opts[:host] = host
45
+ end
46
+
47
+ o.on('-u','--user <user>','AMQP username') do | user |
48
+ opts[:user] = user
49
+ end
50
+
51
+ o.on('-p','--pass <pass>','AMQP password') do | pass |
52
+ opts[:pass] = pass
53
+ end
54
+
55
+ o.on('-c','--file <filename>',"Use the given configuration file for options") do | file |
56
+ opts[:file] = file
57
+ end
58
+
59
+ o.on('-t','--ontop','Stay on top (does not daemonize)') do
60
+ opts[:ontop] = true
61
+ end
62
+
63
+ o.on('-s','--stop','Stop daemon') do
64
+ opts[:command] = "stop"
65
+ end
66
+
67
+ o.on('-h','--help','This help screen') do | nix |
68
+ puts o
69
+ abort ""
70
+ end
71
+
72
+ end
73
+
74
+ parser.parse!
75
+
76
+ # overwrite file options with CLI options
77
+ if opts[:file]
78
+ opts = YAML.load_file(opts[:file]).merge(opts)
79
+ end
80
+
81
+ # overwrite given options with CLI options
82
+ opts = given_opts.merge(opts) if given_opts
83
+
84
+ opts[:proc] = block || nil
85
+ opts[:command] ||= "start"
86
+ daemons_argv = [opts[:command]]
87
+
88
+ unless opts[:command] == "stop"
89
+ puts "Want to save these options? Use this as a configuration file, and use -f to find it next time."
90
+ puts YAML.dump(opts.reject { |k, v| [:proc,:command].include? k})
91
+ end
92
+
93
+ opts[:icon] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'resources','amqp.jpg'))
94
+
95
+ Daemons.run_proc("growlamqp", { :multiple => true,
96
+ :ARGV => daemons_argv,
97
+ :ontop => opts[:ontop]
98
+ } ) do
99
+ trap(:INT) do AMQP.stop { EM.stop_event_loop }; abort "" end
100
+ AMQP.start(opts) do
101
+
102
+ queue = MQ::Queue.new(MQ.new,opts[:queue], :autodelete => true)
103
+ queue.bind(opts[:exchange], :routing_key => opts[:key])
104
+
105
+ queue.subscribe do | header, body |
106
+
107
+ message = opts[:proc] ? opts[:proc].call(body) : body
108
+ if ! message.nil?
109
+ Growl.notify do | m |
110
+ m.image = opts[:icon]
111
+ m.message = message
112
+ end
113
+ end
114
+
115
+ end
116
+ end
117
+
118
+ end
119
+ end
120
+ module_function :monitor!
121
+
122
+ end
Binary file
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: growl-amqp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Lavender
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-20 00:00:00 +01:00
13
+ default_executable: growlamqp
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: amqp
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.6.5
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: daemons
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.10
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: growl
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.3
44
+ version:
45
+ description: Report AMQP messages via Growl. Grr, grr!
46
+ email: blavender@gmail.com
47
+ executables:
48
+ - growlamqp
49
+ extensions: []
50
+
51
+ extra_rdoc_files: []
52
+
53
+ files:
54
+ - README.md
55
+ - LICENSE
56
+ - UNLICENSE
57
+ - bin/growlamqp
58
+ - lib/growl-amqp.rb
59
+ - examples/bert-decode
60
+ - examples/options
61
+ - resources/amqp.jpg
62
+ has_rdoc: true
63
+ homepage:
64
+ licenses:
65
+ - Public Domain
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.8.2
76
+ version:
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ requirements:
84
+ - daemons
85
+ - amqp
86
+ - mq
87
+ - growl
88
+ rubyforge_project:
89
+ rubygems_version: 1.3.5
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Report AMQP messages via Growl. Grr, grr!
93
+ test_files: []
94
+