what 0.0.9 → 0.0.10

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.
data/bin/what CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  require 'rubygems'
2
4
  require 'optparse'
3
5
  require 'webrick'
@@ -12,6 +14,11 @@ opts = OptionParser.new do |opts|
12
14
  What::Config.load(fn)
13
15
  end
14
16
 
17
+ opts.on_tail('-v', '--version', 'Show the version number.') do
18
+ puts What::VERSION
19
+ exit
20
+ end
21
+
15
22
  opts.on_tail('-h', '--help', 'Show this message.') do
16
23
  puts opts
17
24
  exit
data/example/what.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  # Config file for the What monitoring system.
2
2
 
3
3
  ### Choose between JSON and YAML formatting. (default: json)
4
- formatter: yaml
4
+ formatter: json
5
5
 
6
6
  ### Set the polling interval for all services, in seconds. (default: 10)
7
7
  # interval: 10
@@ -12,23 +12,26 @@ module_paths:
12
12
 
13
13
  ### List all modules to be monitored.
14
14
  modules:
15
- - unicorn
16
15
  - custom_module
17
16
  #- processes
17
+ #- unicorn
18
+ #- what
18
19
 
19
20
  ### Pass parameters into modules.
20
21
  module_config:
21
22
  custom_module:
22
23
  hello: world
23
24
  world: hello
24
- unicorn:
25
- # minimum number of workers before warning and alert statuses
26
- warning: 1
27
- alert: 0
28
25
  # processes:
29
26
  # postgres: postgres
30
27
  # beanstalkd: beanstalkd
31
28
  # redis: redis-server
29
+ # unicorn:
30
+ # # minimum number of workers before warning and alert statuses
31
+ # warning: 1
32
+ # alert: 0
33
+ # what:
34
+ # some_server: server.com
32
35
 
33
36
  ### Specify any other config files to load.
34
37
  # configs:
data/lib/what/helpers.rb CHANGED
@@ -33,5 +33,13 @@ module What
33
33
  word.downcase!
34
34
  word
35
35
  end
36
+
37
+ def self.curl(uri)
38
+ curl = Curl::Easy.new(uri)
39
+ curl.on_complete do |easy|
40
+ yield(easy.body_str)
41
+ end
42
+ curl.perform
43
+ end
36
44
  end
37
45
  end
@@ -0,0 +1,26 @@
1
+ # This module assumes the other servers are using the JSON formatter.
2
+ module What
3
+ class Modules::What < Modules::Base
4
+ def initialize
5
+ super
6
+ @config.each do |name, host|
7
+ @config[name] = "http://#{host}:9428"
8
+ end
9
+ @whats = {}
10
+ end
11
+
12
+ def check!
13
+ @config.map do |name, uri|
14
+ Helpers.curl(uri) { |body| @whats[name] = JSON.parse(body) rescue nil }
15
+ end
16
+ end
17
+
18
+ def health
19
+ Helpers.overall_health(@whats.map { |_, attrs| attrs[:health] })
20
+ end
21
+
22
+ def details
23
+ @whats
24
+ end
25
+ end
26
+ end
data/lib/what/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module What
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/lib/what.rb CHANGED
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'yaml'
6
6
  require 'webrick'
7
7
  require 'rack'
8
+ require 'curl'
8
9
 
9
10
  require 'what/config'
10
11
  require 'what/formatter'
data/what.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_dependency("rack", ">= 1.1.2")
26
26
  s.add_dependency("json")
27
+ s.add_dependency("curb")
27
28
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: what
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Lower
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-05-17 00:00:00 -07:00
19
+ date: 2011-05-18 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -49,6 +49,20 @@ dependencies:
49
49
  version: "0"
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: curb
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :runtime
65
+ version_requirements: *id003
52
66
  description: What uses WEBrick to serve a JSON object representing the state of services running on a machine. It currently only includes a module for monitoring Unicorn workers, but it's easy to add custom modules.
53
67
  email:
54
68
  - team@academia.edu
@@ -79,6 +93,7 @@ files:
79
93
  - lib/what/modules/base.rb
80
94
  - lib/what/modules/processes.rb
81
95
  - lib/what/modules/unicorn.rb
96
+ - lib/what/modules/what.rb
82
97
  - lib/what/monitor.rb
83
98
  - lib/what/server.rb
84
99
  - lib/what/status.rb