redmon 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -31,8 +31,15 @@ Intuitively introspect registered keys. ** Coming Soon **
31
31
 
32
32
  ----
33
33
 
34
+ ## Installation
35
+
36
+ Redmon is available as a RubyGem:
37
+
38
+ ```bash
39
+ gem install redmon
40
+ ```
41
+
34
42
  ## Usage
35
- Currently not a registered gem, but soon. For now clone the repo and start the app as demonstrated below
36
43
 
37
44
  ```bash
38
45
  $ bundle install
@@ -60,6 +67,30 @@ $ ruby load_sim.rb
60
67
 
61
68
  Open your browser to 0.0.0.0:4567
62
69
 
70
+
71
+ ## Using in a Rails application
72
+
73
+ Add to Gemfile:
74
+
75
+ gem 'redmon', require: false
76
+
77
+ Add to config/routes.rb:
78
+
79
+ require 'redmon/app'
80
+ mount Redmon::App => '/redmon'
81
+
82
+ You can configure the Redmon using an initializer config/initializers/redmon.rb:
83
+
84
+ ```ruby
85
+ Redmon.configure do |config|
86
+ config.redis_url = 'redis://127.0.0.1:6379'
87
+ config.namespace = 'redmon'
88
+ config.poll_interval = 10
89
+ end
90
+ ```
91
+
92
+ This will mount the Redmon application to the /redmon/ path. The trailing slash is important.
93
+
63
94
  ## License
64
95
 
65
96
  Copyright (c) 2012 Sean McDaniel
@@ -68,4 +99,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
68
99
 
69
100
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
70
101
 
71
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
102
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/redmon/app.rb CHANGED
@@ -1,5 +1,12 @@
1
+ require 'redmon/helpers'
2
+
1
3
  module Redmon
2
4
  class App < Sinatra::Base
5
+ use Rack::Static, {
6
+ urls: [/\.css$/, /\.js$/],
7
+ root: "#{root}/public",
8
+ cache_control: 'public, max-age=3600'
9
+ }
3
10
 
4
11
  helpers Redmon::Helpers
5
12
 
@@ -36,4 +43,4 @@ module Redmon
36
43
  end
37
44
 
38
45
  end
39
- end
46
+ end
@@ -0,0 +1,26 @@
1
+ module Redmon
2
+ def self.configure
3
+ yield config
4
+ end
5
+
6
+ def self.config
7
+ @config ||= Config.new
8
+ end
9
+
10
+ class Config
11
+ DEFAULTS = {
12
+ :web_interface => ['0.0.0.0', 4567],
13
+ :redis_url => 'redis://127.0.0.1:6379',
14
+ :namespace => 'redmon',
15
+ :worker => true,
16
+ :poll_interval => 10
17
+ }
18
+
19
+ attr_accessor(*DEFAULTS.keys)
20
+
21
+ def initialize
22
+ DEFAULTS.each { |k,v| send("#{k}=", v) }
23
+ end
24
+
25
+ end
26
+ end
@@ -1,3 +1,5 @@
1
+ require 'redmon/redis'
2
+
1
3
  module Redmon
2
4
  module Helpers
3
5
  include Redmon::Redis
@@ -7,7 +9,7 @@ module Redmon
7
9
  end
8
10
 
9
11
  def poll_interval
10
- Redmon[:poll_interval] * 1000
12
+ Redmon.config.poll_interval * 1000
11
13
  end
12
14
 
13
15
  def count
@@ -15,4 +17,4 @@ module Redmon
15
17
  end
16
18
 
17
19
  end
18
- end
20
+ end
data/lib/redmon/redis.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'redmon/config'
2
+
1
3
  module Redmon
2
4
  module Redis
3
5
  extend self
@@ -13,15 +15,15 @@ module Redmon
13
15
  ]
14
16
 
15
17
  def redis
16
- @redis ||= ::Redis.connect(:url => Redmon[:redis_url])
18
+ @redis ||= ::Redis.connect(:url => Redmon.config.redis_url)
17
19
  end
18
20
 
19
21
  def ns
20
- Redmon[:namespace]
22
+ Redmon.config.namespace
21
23
  end
22
24
 
23
25
  def redis_url
24
- @redis_url ||= Redmon[:redis_url].gsub(/\w*:\w*@/, '')
26
+ @redis_url ||= Redmon.config.redis_url.gsub(/\w*:\w*@/, '')
25
27
  end
26
28
 
27
29
  def redis_host
@@ -60,4 +62,4 @@ module Redmon
60
62
  "#{ns}:redis:#{redis_host}:stats"
61
63
  end
62
64
  end
63
- end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Redmon
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/redmon/worker.rb CHANGED
@@ -34,8 +34,8 @@ module Redmon
34
34
  end
35
35
 
36
36
  def interval
37
- Redmon[:poll_interval]
37
+ Redmon.config.poll_interval
38
38
  end
39
39
 
40
40
  end
41
- end
41
+ end
data/lib/redmon.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'redmon/config'
1
2
  require 'active_support/core_ext'
2
3
  require 'eventmachine'
3
4
  require 'haml'
@@ -10,16 +11,8 @@ module Redmon
10
11
 
11
12
  attr_reader :opts
12
13
 
13
- @opts = {
14
- :web_interface => ['0.0.0.0', 4567],
15
- :redis_url => 'redis://127.0.0.1:6379',
16
- :namespace => 'redmon',
17
- :worker => true,
18
- :poll_interval => 10
19
- }
20
-
21
14
  def run(opts={})
22
- @opts.merge! opts
15
+ @opts = Redmon::Config::DEFAULTS.merge(opts)
23
16
  start_em
24
17
  rescue Exception => e
25
18
  log "!!! Redmon has shit the bed, restarting... #{e.message}"
@@ -55,6 +48,7 @@ module Redmon
55
48
  puts "[#{Time.now.strftime('%y-%m-%d %H:%M:%S')}] #{msg}"
56
49
  end
57
50
 
51
+ # @deprecated
58
52
  def [](option)
59
53
  opts[option]
60
54
  end
@@ -64,4 +58,4 @@ end
64
58
  require 'redmon/redis'
65
59
  require 'redmon/helpers'
66
60
  require 'redmon/app'
67
- require 'redmon/worker'
61
+ require 'redmon/worker'
data/spec/helpers_spec.rb CHANGED
@@ -4,7 +4,7 @@ describe "Helpers" do
4
4
 
5
5
  describe "redis" do
6
6
  it "should call Redis.connect" do
7
- Redis.should_receive(:connect).with({:url => Redmon[:redis_url]})
7
+ Redis.should_receive(:connect).with({:url => Redmon.config.redis_url})
8
8
  Redmon::Redis.redis
9
9
  end
10
10
  end
@@ -19,19 +19,19 @@ describe "Helpers" do
19
19
 
20
20
  describe "#ns" do
21
21
  it "should return the configured namespace" do
22
- Redmon[:namespace].should == Redmon::Redis.ns
22
+ Redmon.config.namespace.should == Redmon::Redis.ns
23
23
  end
24
24
  end
25
25
 
26
26
  describe "#redis_url" do
27
27
  it "should return the configured redis url" do
28
- Redmon[:redis_url].should == Redmon::Redis.redis_url
28
+ Redmon.config.redis_url.should == Redmon::Redis.redis_url
29
29
  end
30
30
  end
31
31
 
32
32
  describe "#redis_host" do
33
33
  it "should return the configured redis host" do
34
- Redmon[:redis_url].gsub('redis://', '').should == Redmon::Redis.redis_host
34
+ Redmon.config.redis_url.gsub('redis://', '').should == Redmon::Redis.redis_host
35
35
  end
36
36
  end
37
37
 
@@ -83,4 +83,4 @@ describe "Helpers" do
83
83
  end
84
84
  end
85
85
 
86
- end
86
+ end
data/spec/worker_spec.rb CHANGED
@@ -55,8 +55,8 @@ describe "worker" do
55
55
 
56
56
  describe "#interval" do
57
57
  it "should return the configured poll interval" do
58
- @worker.interval.should == Redmon[:poll_interval]
58
+ @worker.interval.should == Redmon.config.poll_interval
59
59
  end
60
60
  end
61
61
 
62
- end
62
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-25 00:00:00.000000000 Z
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
16
- requirement: &70250847178440 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.4.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70250847178440
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: sinatra
27
- requirement: &70250847177320 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 1.2.6
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70250847177320
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.2.6
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: hiredis
38
- requirement: &70250847176300 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.4.0
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70250847176300
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: redis
49
- requirement: &70250847175520 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 2.2.2
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70250847175520
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 2.2.2
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: eventmachine
60
- requirement: &70250847174640 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70250847174640
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: i18n
71
- requirement: &70250847172620 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70250847172620
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: haml
82
- requirement: &70250847171980 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '0'
88
118
  type: :runtime
89
119
  prerelease: false
90
- version_requirements: *70250847171980
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: rack
93
- requirement: &70250847202180 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,10 +133,15 @@ dependencies:
98
133
  version: '0'
99
134
  type: :runtime
100
135
  prerelease: false
101
- version_requirements: *70250847202180
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: thin
104
- requirement: &70250847200940 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
147
  - - ! '>='
@@ -109,10 +149,15 @@ dependencies:
109
149
  version: '0'
110
150
  type: :runtime
111
151
  prerelease: false
112
- version_requirements: *70250847200940
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
113
158
  - !ruby/object:Gem::Dependency
114
159
  name: activesupport
115
- requirement: &70250847199620 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
116
161
  none: false
117
162
  requirements:
118
163
  - - ! '>='
@@ -120,10 +165,15 @@ dependencies:
120
165
  version: '0'
121
166
  type: :runtime
122
167
  prerelease: false
123
- version_requirements: *70250847199620
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
124
174
  - !ruby/object:Gem::Dependency
125
175
  name: mixlib-cli
126
- requirement: &70250847197980 !ruby/object:Gem::Requirement
176
+ requirement: !ruby/object:Gem::Requirement
127
177
  none: false
128
178
  requirements:
129
179
  - - ! '>='
@@ -131,10 +181,15 @@ dependencies:
131
181
  version: '0'
132
182
  type: :runtime
133
183
  prerelease: false
134
- version_requirements: *70250847197980
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
135
190
  - !ruby/object:Gem::Dependency
136
191
  name: sinatra-contrib
137
- requirement: &70250847197040 !ruby/object:Gem::Requirement
192
+ requirement: !ruby/object:Gem::Requirement
138
193
  none: false
139
194
  requirements:
140
195
  - - ~>
@@ -142,10 +197,15 @@ dependencies:
142
197
  version: 1.3.1
143
198
  type: :development
144
199
  prerelease: false
145
- version_requirements: *70250847197040
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: 1.3.1
146
206
  - !ruby/object:Gem::Dependency
147
207
  name: rack-test
148
- requirement: &70250847196180 !ruby/object:Gem::Requirement
208
+ requirement: !ruby/object:Gem::Requirement
149
209
  none: false
150
210
  requirements:
151
211
  - - ! '>='
@@ -153,10 +213,15 @@ dependencies:
153
213
  version: '0'
154
214
  type: :development
155
215
  prerelease: false
156
- version_requirements: *70250847196180
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
157
222
  - !ruby/object:Gem::Dependency
158
223
  name: rake
159
- requirement: &70250847195320 !ruby/object:Gem::Requirement
224
+ requirement: !ruby/object:Gem::Requirement
160
225
  none: false
161
226
  requirements:
162
227
  - - ! '>='
@@ -164,10 +229,15 @@ dependencies:
164
229
  version: '0'
165
230
  type: :development
166
231
  prerelease: false
167
- version_requirements: *70250847195320
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
168
238
  - !ruby/object:Gem::Dependency
169
239
  name: rspec
170
- requirement: &70250846940040 !ruby/object:Gem::Requirement
240
+ requirement: !ruby/object:Gem::Requirement
171
241
  none: false
172
242
  requirements:
173
243
  - - ~>
@@ -175,10 +245,15 @@ dependencies:
175
245
  version: 2.8.0
176
246
  type: :development
177
247
  prerelease: false
178
- version_requirements: *70250846940040
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ~>
252
+ - !ruby/object:Gem::Version
253
+ version: 2.8.0
179
254
  - !ruby/object:Gem::Dependency
180
255
  name: shoulda
181
- requirement: &70250846939060 !ruby/object:Gem::Requirement
256
+ requirement: !ruby/object:Gem::Requirement
182
257
  none: false
183
258
  requirements:
184
259
  - - ! '>='
@@ -186,7 +261,12 @@ dependencies:
186
261
  version: '0'
187
262
  type: :development
188
263
  prerelease: false
189
- version_requirements: *70250846939060
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
190
270
  description: Redis Admin interface and monitor.
191
271
  email:
192
272
  - sean.mcdaniel@me.com
@@ -204,6 +284,7 @@ files:
204
284
  - bin/redmon
205
285
  - lib/redmon.rb
206
286
  - lib/redmon/app.rb
287
+ - lib/redmon/config.rb
207
288
  - lib/redmon/helpers.rb
208
289
  - lib/redmon/public/redmon.css
209
290
  - lib/redmon/public/redmon.js
@@ -239,7 +320,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
320
  version: '0'
240
321
  segments:
241
322
  - 0
242
- hash: -3944178042738235931
323
+ hash: -783449072633030627
243
324
  required_rubygems_version: !ruby/object:Gem::Requirement
244
325
  none: false
245
326
  requirements:
@@ -248,10 +329,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
329
  version: '0'
249
330
  segments:
250
331
  - 0
251
- hash: -3944178042738235931
332
+ hash: -783449072633030627
252
333
  requirements: []
253
334
  rubyforge_project: redmon
254
- rubygems_version: 1.8.15
335
+ rubygems_version: 1.8.24
255
336
  signing_key:
256
337
  specification_version: 3
257
338
  summary: Redis monitor