what 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/example/what.yml CHANGED
@@ -23,11 +23,13 @@ modules:
23
23
  alert: 0
24
24
  - name: hello world
25
25
  type: custom_module
26
+ interval: 1
26
27
  config:
27
28
  hello: hello
28
29
  world: world
29
30
  - name: world hello
30
31
  type: custom_module
32
+ interval: 5
31
33
  config:
32
34
  hello: world
33
35
  world: hello
@@ -1,10 +1,16 @@
1
1
  module What
2
2
  class Modules::Base
3
+
4
+ attr_reader :interval
5
+
3
6
  def initialize(params={})
4
7
  defaults = (self.class)::DEFAULTS rescue {}
5
8
  @name = params['name']
6
9
  @config = defaults.merge(params['config'] || {})
7
10
  @max = params['max'] || 'alert'
11
+ # Use global interval setting if not set on a
12
+ # per module basis
13
+ @interval = params['interval'] || Config['interval']
8
14
  initialize_module
9
15
  end
10
16
 
data/lib/what/monitor.rb CHANGED
@@ -8,18 +8,29 @@ module What
8
8
  end
9
9
 
10
10
  Thread.abort_on_exception = true
11
- @thread = Thread.new(@modules) { |modules| self.do_it(modules) }
11
+ @threads = @modules.collect do |mod|
12
+ Thread.new do
13
+ loop do
14
+ mod.check!
15
+ Thread.current[:status] = mod.status
16
+ sleep mod.interval
17
+ end
18
+ end
19
+ end
20
+
21
+ Thread.new { self.do_it }
12
22
  end
13
23
 
14
- def self.do_it(modules)
24
+ def self.do_it
15
25
  Status['details'] = []
16
26
  loop do
17
27
  statuses = []
18
28
  healths = []
19
- modules.each do |mod|
20
- mod.check!
21
- healths << mod.status['health']
22
- statuses << mod.status
29
+ @threads.each do |th|
30
+ if th[:status]
31
+ healths << th[:status]['health']
32
+ statuses << th[:status]
33
+ end
23
34
  end
24
35
  Status['health'] = Helpers.overall_health(healths)
25
36
  Status['details'] = statuses
data/lib/what/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module What
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/what.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = What::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Ryan Fitzgerald", "Ryan Lower"]
10
- s.email = ["team@academia.edu"]
10
+ s.email = ["rwfitzge@gmail.com", "rpjlower@gmail.com"]
11
11
  s.homepage = "http://academia.edu/"
12
12
  s.summary = %q{Simple server monitoring tool}
13
13
  s.description = <<-EOS
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: what
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-01 00:00:00.000000000Z
13
+ date: 2012-05-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
17
- requirement: &70189107394580 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: 1.1.2
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70189107394580
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 1.1.2
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: excon
28
- requirement: &70189107394060 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ~>
@@ -33,10 +38,15 @@ dependencies:
33
38
  version: 0.6.1
34
39
  type: :runtime
35
40
  prerelease: false
36
- version_requirements: *70189107394060
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.6.1
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: json
39
- requirement: &70189107393640 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,7 +54,12 @@ dependencies:
44
54
  version: '0'
45
55
  type: :runtime
46
56
  prerelease: false
47
- version_requirements: *70189107393640
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
48
63
  description: ! 'What uses WEBrick to serve a JSON object representing the state of
49
64
  services
50
65
 
@@ -56,7 +71,8 @@ description: ! 'What uses WEBrick to serve a JSON object representing the state
56
71
 
57
72
  '
58
73
  email:
59
- - team@academia.edu
74
+ - rwfitzge@gmail.com
75
+ - rpjlower@gmail.com
60
76
  executables:
61
77
  - what
62
78
  extensions: []
@@ -110,9 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
126
  version: '0'
111
127
  requirements: []
112
128
  rubyforge_project: what
113
- rubygems_version: 1.8.11
129
+ rubygems_version: 1.8.23
114
130
  signing_key:
115
131
  specification_version: 3
116
132
  summary: Simple server monitoring tool
117
133
  test_files: []
118
- has_rdoc: