what 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.md +1 -1
- data/example/what.yml +8 -0
- data/lib/what/config.rb +11 -0
- data/lib/what/formatters.rb +19 -0
- data/lib/what/modules/processes.rb +33 -0
- data/lib/what/modules/unicorn.rb +4 -1
- data/lib/what/server.rb +2 -2
- data/lib/what/version.rb +1 -1
- data/lib/what.rb +1 -0
- data/what.gemspec +3 -3
- metadata +8 -5
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Academia, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
What? A simple server monitoring tool.
|
2
2
|
======================================
|
3
3
|
|
4
|
-
![WHAT !](http://
|
4
|
+
![WHAT !](http://rwfitzge.github.com/what.png)
|
5
5
|
|
6
6
|
What is a modular, easily-extensible server monitoring tool which is still in
|
7
7
|
the early stages of development.
|
data/example/what.yml
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Config file for the What monitoring system.
|
2
2
|
|
3
|
+
### Choose between JSON and YAML formatting. (default: json)
|
4
|
+
formatter: yaml
|
5
|
+
|
3
6
|
### Set the polling interval for all services.
|
4
7
|
interval: 10
|
5
8
|
|
@@ -10,6 +13,7 @@ interval: 10
|
|
10
13
|
### List all modules to be monitored.
|
11
14
|
modules:
|
12
15
|
- unicorn
|
16
|
+
#- processes
|
13
17
|
|
14
18
|
### Pass parameters into modules.
|
15
19
|
module_config:
|
@@ -17,6 +21,10 @@ module_config:
|
|
17
21
|
# minimum number of workers before warning and alert statuses
|
18
22
|
warning: 1
|
19
23
|
alert: 0
|
24
|
+
# processes:
|
25
|
+
# postgres: postgres
|
26
|
+
# beanstalkd: beanstalkd
|
27
|
+
# redis: redis-server
|
20
28
|
|
21
29
|
### Specify any other config files to load.
|
22
30
|
# configs:
|
data/lib/what/config.rb
CHANGED
@@ -40,4 +40,15 @@ class What::Config
|
|
40
40
|
def self.all
|
41
41
|
@config
|
42
42
|
end
|
43
|
+
|
44
|
+
def self.formatter
|
45
|
+
@formatter ||= case @config['formatter']
|
46
|
+
when 'json'
|
47
|
+
What::JsonFormatter.new
|
48
|
+
when 'yaml'
|
49
|
+
What::YamlFormatter.new
|
50
|
+
else
|
51
|
+
What::JsonFormatter.new
|
52
|
+
end
|
53
|
+
end
|
43
54
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class What::JsonFormatter
|
2
|
+
def mime
|
3
|
+
'application/json'
|
4
|
+
end
|
5
|
+
|
6
|
+
def format(hash)
|
7
|
+
JSON.unparse(hash) + "\n"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class What::YamlFormatter
|
12
|
+
def mime
|
13
|
+
'application/x-yaml'
|
14
|
+
end
|
15
|
+
|
16
|
+
def format(hash)
|
17
|
+
hash.to_yaml
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class What::Modules::Processes < What::Modules::Base
|
2
|
+
def initialize
|
3
|
+
super
|
4
|
+
@config.each do |name, regexp_str|
|
5
|
+
@config[name] = Regexp.new(regexp_str)
|
6
|
+
end
|
7
|
+
@processes = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def check!
|
11
|
+
@config.each do |name, regexp|
|
12
|
+
@processes[name] = `ps aux`.split("\n").grep(regexp).map do |ln|
|
13
|
+
ln =~ /^\w+\s+(\d+).*(\d+:\d\d(?:\.\d\d)?) (.*)$/
|
14
|
+
{:pid => $1, :cpu_time => $2, :proctitle => $3.strip}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def health
|
20
|
+
all_ok = true
|
21
|
+
@processes.each do |name, results|
|
22
|
+
if results.count == 0
|
23
|
+
all_ok = false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
all_ok ? :ok : :alert
|
27
|
+
end
|
28
|
+
|
29
|
+
def details
|
30
|
+
@processes
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
data/lib/what/modules/unicorn.rb
CHANGED
data/lib/what/server.rb
CHANGED
@@ -7,8 +7,8 @@ class What::Server
|
|
7
7
|
def call(_)
|
8
8
|
[
|
9
9
|
What::Status[:health] != :alert ? 200 : 503,
|
10
|
-
{'Content-Type' =>
|
11
|
-
|
10
|
+
{'Content-Type' => What::Config.formatter.mime},
|
11
|
+
What::Config.formatter.format(What::Status.all)
|
12
12
|
]
|
13
13
|
end
|
14
14
|
end
|
data/lib/what/version.rb
CHANGED
data/lib/what.rb
CHANGED
data/what.gemspec
CHANGED
@@ -10,9 +10,9 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["team@academia.edu"]
|
11
11
|
s.homepage = "http://academia.edu/"
|
12
12
|
s.summary = %q{Simple server monitoring tool}
|
13
|
-
s.description = "What uses WEBrick to serve a JSON object representing the" +
|
14
|
-
"state of services running on a machine. It currently only" +
|
15
|
-
"includes a module for monitoring Unicorn workers, but" +
|
13
|
+
s.description = "What uses WEBrick to serve a JSON object representing the " +
|
14
|
+
"state of services running on a machine. It currently only " +
|
15
|
+
"includes a module for monitoring Unicorn workers, but " +
|
16
16
|
"it's easy to add custom modules."
|
17
17
|
|
18
18
|
s.rubyforge_project = "what"
|
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: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
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-11 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: "0"
|
50
50
|
type: :runtime
|
51
51
|
version_requirements: *id002
|
52
|
-
description: What uses WEBrick to serve a JSON object representing
|
52
|
+
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
53
|
email:
|
54
54
|
- team@academia.edu
|
55
55
|
executables:
|
@@ -61,15 +61,18 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- .gitignore
|
63
63
|
- Gemfile
|
64
|
+
- LICENSE
|
64
65
|
- README.md
|
65
66
|
- Rakefile
|
66
67
|
- bin/what
|
67
68
|
- example/what.yml
|
68
69
|
- lib/what.rb
|
69
70
|
- lib/what/config.rb
|
71
|
+
- lib/what/formatters.rb
|
70
72
|
- lib/what/helpers.rb
|
71
73
|
- lib/what/modules.rb
|
72
74
|
- lib/what/modules/base.rb
|
75
|
+
- lib/what/modules/processes.rb
|
73
76
|
- lib/what/modules/unicorn.rb
|
74
77
|
- lib/what/monitor.rb
|
75
78
|
- lib/what/server.rb
|