redmon 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -27,10 +27,6 @@ Dynamically update your server configuration.
27
27
 
28
28
  ----
29
29
 
30
- Intuitively introspect registered keys. ** Coming Soon **
31
-
32
- ----
33
-
34
30
  ## Installation
35
31
 
36
32
  Redmon is available as a RubyGem:
@@ -72,12 +68,16 @@ Open your browser to 0.0.0.0:4567
72
68
 
73
69
  Add to Gemfile:
74
70
 
75
- gem 'redmon', require: false
71
+ ```ruby
72
+ gem 'redmon', require: false
73
+ ```
76
74
 
77
75
  Add to config/routes.rb:
78
76
 
79
- require 'redmon/app'
80
- mount Redmon::App => '/redmon'
77
+ ```ruby
78
+ require 'redmon/app'
79
+ mount Redmon::App => '/redmon'
80
+ ```
81
81
 
82
82
  You can configure the Redmon using an initializer config/initializers/redmon.rb:
83
83
 
@@ -89,7 +89,8 @@ Redmon.configure do |config|
89
89
  end
90
90
  ```
91
91
 
92
- This will mount the Redmon application to the /redmon/ path. The trailing slash is important.
92
+ This will mount the Redmon application to the /redmon/ path. The trailing slash
93
+ is important.
93
94
 
94
95
  ## License
95
96
 
@@ -99,4 +100,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
99
100
 
100
101
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
101
102
 
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.
103
+ 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/bin/redmon CHANGED
@@ -54,18 +54,12 @@ class RedmonCLI
54
54
  :default => true,
55
55
  :description => 'Do not run a worker to collect the stats'
56
56
 
57
- def parse
57
+ def run
58
58
  parse_options
59
- config[:web_interface] = web_interface
59
+ config[:web_interface] = [config[:address], config[:port]]
60
60
  config
61
61
  end
62
62
 
63
- def web_interface
64
- if config[:app]
65
- config[:web_interface] = [config[:address], config[:port]]
66
- end
67
- end
68
-
69
63
  end
70
64
 
71
- Redmon.run RedmonCLI.new.parse
65
+ Redmon.run RedmonCLI.new.run
data/lib/redmon.rb CHANGED
@@ -9,10 +9,8 @@ require 'thin'
9
9
  module Redmon
10
10
  extend self
11
11
 
12
- attr_reader :opts
13
-
14
12
  def run(opts={})
15
- @opts = Redmon::Config::DEFAULTS.merge(opts)
13
+ config.apply opts
16
14
  start_em
17
15
  rescue Exception => e
18
16
  log "!!! Redmon has shit the bed, restarting... #{e.message}"
@@ -23,15 +21,15 @@ module Redmon
23
21
  EM.run do
24
22
  trap 'TERM', &method(:shutdown)
25
23
  trap 'INT', &method(:shutdown)
26
- start_app if opts[:web_interface]
27
- start_worker if opts[:worker]
24
+ start_app if config.app
25
+ start_worker if config.worker
28
26
  end
29
27
  end
30
28
 
31
29
  def start_app
32
30
  app = Redmon::App.new
33
- Thin::Server.start(*opts[:web_interface], app)
34
- log "listening on http##{opts[:web_interface].join(':')}"
31
+ Thin::Server.start(*config.web_interface, app)
32
+ log "listening on http##{config.web_interface.join(':')}"
35
33
  rescue Exception => e
36
34
  log "Can't start Redmon::App. port in use? Error #{e}"
37
35
  end
@@ -40,7 +38,7 @@ module Redmon
40
38
  Worker.new.run!
41
39
  end
42
40
 
43
- def shutdown
41
+ def shutdown(code)
44
42
  EM.stop
45
43
  end
46
44
 
@@ -50,7 +48,7 @@ module Redmon
50
48
 
51
49
  # @deprecated
52
50
  def [](option)
53
- opts[option]
51
+ config.send :option
54
52
  end
55
53
 
56
54
  end
@@ -58,4 +56,4 @@ end
58
56
  require 'redmon/redis'
59
57
  require 'redmon/helpers'
60
58
  require 'redmon/app'
61
- require 'redmon/worker'
59
+ require 'redmon/worker'
data/lib/redmon/app.rb CHANGED
@@ -2,14 +2,15 @@ require 'redmon/helpers'
2
2
 
3
3
  module Redmon
4
4
  class App < Sinatra::Base
5
+
6
+ helpers Redmon::Helpers
7
+
5
8
  use Rack::Static, {
6
9
  urls: [/\.css$/, /\.js$/],
7
10
  root: "#{root}/public",
8
11
  cache_control: 'public, max-age=3600'
9
12
  }
10
13
 
11
- helpers Redmon::Helpers
12
-
13
14
  get '/' do
14
15
  haml :app
15
16
  end
@@ -43,4 +44,4 @@ module Redmon
43
44
  end
44
45
 
45
46
  end
46
- end
47
+ end
data/lib/redmon/config.rb CHANGED
@@ -9,18 +9,23 @@ module Redmon
9
9
 
10
10
  class Config
11
11
  DEFAULTS = {
12
- :web_interface => ['0.0.0.0', 4567],
13
- :redis_url => 'redis://127.0.0.1:6379',
14
12
  :namespace => 'redmon',
13
+ :redis_url => 'redis://127.0.0.1:6379',
14
+ :app => true,
15
15
  :worker => true,
16
+ :web_interface => ['0.0.0.0', 4567],
16
17
  :poll_interval => 10
17
18
  }
18
19
 
19
20
  attr_accessor(*DEFAULTS.keys)
20
21
 
21
22
  def initialize
22
- DEFAULTS.each { |k,v| send("#{k}=", v) }
23
+ apply DEFAULTS
24
+ end
25
+
26
+ def apply(opts)
27
+ opts.each {|k,v| send("#{k}=", v) if respond_to? k}
23
28
  end
24
29
 
25
30
  end
26
- end
31
+ end
data/lib/redmon/redis.rb CHANGED
@@ -62,4 +62,4 @@ module Redmon
62
62
  "#{ns}:redis:#{redis_host}:stats"
63
63
  end
64
64
  end
65
- end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Redmon
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -22,8 +22,6 @@
22
22
  %ul.nav
23
23
  %li.active{:id => 'dashboard'}
24
24
  %a Dashboard
25
- %li{:id => 'keys'}
26
- %a Keys
27
25
  %li{:id => 'cli'}
28
26
  %a CLI
29
27
  %li{:id => 'config'}
@@ -125,16 +123,6 @@
125
123
  %tr
126
124
  %td VM Enabled
127
125
  %td{:id => "vm_enabled"}
128
- .keys.hidden
129
- .content
130
- .page-header
131
- %h1 Keys - Coming soon!
132
- .row
133
- .span6
134
- .input-prepend
135
- %span.add-on pattern
136
- %input.span5
137
- .span15
138
126
 
139
127
  .cli.hidden
140
128
  .content
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Redmon" do
4
+ describe "#configure" do
5
+ it "should allow block style config" do
6
+ Redmon.configure do |config|
7
+ config.app = false
8
+ end
9
+ Redmon.config.app.should be_false
10
+ end
11
+ end
12
+ end
13
+
14
+ describe "Config" do
15
+ subject {Redmon::Config.new}
16
+ describe "#initialize" do
17
+ it "should apply the defaults" do
18
+ Redmon::Config::DEFAULTS.each do |k,v|
19
+ subject.send(k).should === v
20
+ end
21
+ end
22
+ end
23
+
24
+ describe "#apply" do
25
+ it "should apply the passed options hash" do
26
+ subject.app.should be_true
27
+ subject.worker.should be_true
28
+
29
+ subject.apply app: false, worker: false
30
+ subject.app.should be_false
31
+ subject.worker.should be_false
32
+ end
33
+ end
34
+ 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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-26 00:00:00.000000000 Z
12
+ date: 2012-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
@@ -303,6 +303,7 @@ files:
303
303
  - load_sim.rb
304
304
  - redmon.gemspec
305
305
  - spec/app_spec.rb
306
+ - spec/config_spec.rb
306
307
  - spec/helpers_spec.rb
307
308
  - spec/spec_helper.rb
308
309
  - spec/worker_spec.rb
@@ -320,7 +321,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
320
321
  version: '0'
321
322
  segments:
322
323
  - 0
323
- hash: -783449072633030627
324
+ hash: 2796523061834501590
324
325
  required_rubygems_version: !ruby/object:Gem::Requirement
325
326
  none: false
326
327
  requirements:
@@ -329,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
330
  version: '0'
330
331
  segments:
331
332
  - 0
332
- hash: -783449072633030627
333
+ hash: 2796523061834501590
333
334
  requirements: []
334
335
  rubyforge_project: redmon
335
336
  rubygems_version: 1.8.24
@@ -338,6 +339,7 @@ specification_version: 3
338
339
  summary: Redis monitor
339
340
  test_files:
340
341
  - spec/app_spec.rb
342
+ - spec/config_spec.rb
341
343
  - spec/helpers_spec.rb
342
344
  - spec/spec_helper.rb
343
345
  - spec/worker_spec.rb