what 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -27,13 +27,7 @@ the HTTP request returns 503 instead of 200. This means What can easily
27
27
  be used in conjunction with monitoring tools like Pingdom.
28
28
 
29
29
  Writing monitoring modules is easy: the only requirement is that they
30
- implement a `health` method, which returns `:ok`, `:warning`, or `:alert`.
30
+ implement a `health` method, which returns `'ok'`, `'warning'`, or `'alert'`.
31
31
  They can also implement a `details` method, which returns the hash
32
32
  that's included in the HTTP response. See the included `What::Modules::Base`
33
- and `What::Modules::Unicorn` classes for the implementation details.
34
-
35
- ### What's the plan?
36
-
37
- Eventually, it should be possible to write a What module which monitors other
38
- What servers across an entire deployment, pulling together all relevant
39
- information into one JSON object.
33
+ and `What::Modules::Unicorn` classes for the implementation details.
data/example/what.yml CHANGED
@@ -13,6 +13,7 @@ module_paths:
13
13
  ### List all modules to be monitored.
14
14
  modules:
15
15
  - custom_module
16
+ #- disk
16
17
  #- processes
17
18
  #- unicorn
18
19
  #- what
@@ -23,6 +24,14 @@ module_config:
23
24
  custom_module:
24
25
  hello: world
25
26
  world: hello
27
+ # disk:
28
+ # # percentage of disk space filled
29
+ # "/$":
30
+ # warning: 70%
31
+ # alert: 80%
32
+ # "/Volumes/BOOTCAMP":
33
+ # warning: 80%
34
+ # alert: 90%
26
35
  # processes:
27
36
  # postgres: postgres
28
37
  # beanstalkd: beanstalkd
@@ -0,0 +1,60 @@
1
+ module What
2
+ class Modules::Disk < Modules::Base
3
+ def initialize
4
+ super
5
+ @config.each do |name, config|
6
+ if config.is_a?(Hash)
7
+ @config[name] = {
8
+ 'warning' => @config['warning'].to_i,
9
+ 'alert' => @config['alert'].to_i
10
+ }
11
+ else
12
+ @config[name] = {
13
+ 'warning' => config.to_i,
14
+ 'alert' => 100
15
+ }
16
+ end
17
+ end
18
+ @drives = {}
19
+ end
20
+
21
+ def check!
22
+ @config.each do |name, config|
23
+ ln = `df -h`.split("\n").grep(Regexp.new(name)).first
24
+ if ln
25
+ fields = ln.split(/\s+/)
26
+ @drives[name] = {
27
+ 'size' => fields[1],
28
+ 'used' => fields[2],
29
+ 'avail' => fields[3],
30
+ 'use%' => fields[4].to_i,
31
+ 'warning%' => config['warning'],
32
+ 'alert%' => config['alert']
33
+ }
34
+ else
35
+ @drives[name] = nil
36
+ end
37
+ end
38
+ end
39
+
40
+ def health
41
+ healths = @drives.map do |name, attrs|
42
+ puts name, attrs.inspect
43
+ if attrs.nil?
44
+ 'alert'
45
+ elsif attrs['use%'] >= attrs['alert%']
46
+ 'alert'
47
+ elsif attrs['use%'] >= attrs['warning%']
48
+ 'warning'
49
+ else
50
+ 'ok'
51
+ end
52
+ end
53
+ Helpers.overall_health(healths)
54
+ end
55
+
56
+ def details
57
+ @drives
58
+ end
59
+ end
60
+ end
data/lib/what/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module What
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 12
10
- version: 0.0.12
9
+ - 13
10
+ version: 0.0.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Fitzgerald
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-05-18 00:00:00 -07:00
19
+ date: 2011-05-19 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -98,6 +98,7 @@ files:
98
98
  - lib/what/helpers.rb
99
99
  - lib/what/modules.rb
100
100
  - lib/what/modules/base.rb
101
+ - lib/what/modules/disk.rb
101
102
  - lib/what/modules/existence.rb
102
103
  - lib/what/modules/processes.rb
103
104
  - lib/what/modules/unicorn.rb