what 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/what +7 -0
- data/example/what.yml +9 -6
- data/lib/what/helpers.rb +8 -0
- data/lib/what/modules/what.rb +26 -0
- data/lib/what/version.rb +1 -1
- data/lib/what.rb +1 -0
- data/what.gemspec +1 -0
- metadata +19 -4
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:
|
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
@@ -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
data/lib/what.rb
CHANGED
data/what.gemspec
CHANGED
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:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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-
|
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
|