Class: What::Modules::Base
- Inherits:
-
Object
- Object
- What::Modules::Base
show all
- Defined in:
- lib/what/modules/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ Base
Returns a new instance of Base.
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/what/modules/base.rb', line 6
def initialize(params={})
defaults = (self.class)::DEFAULTS rescue {}
@name = params['name']
@config = defaults.merge(params['config'] || {})
@max = params['max'] || 'alert'
@interval = params['interval'] || Config['interval']
initialize_module
end
|
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
4
5
6
|
# File 'lib/what/modules/base.rb', line 4
def interval
@interval
end
|
Instance Method Details
#check! ⇒ Object
24
25
|
# File 'lib/what/modules/base.rb', line 24
def check!
end
|
#details ⇒ Object
46
47
48
|
# File 'lib/what/modules/base.rb', line 46
def details
{}
end
|
#health ⇒ Object
42
43
44
|
# File 'lib/what/modules/base.rb', line 42
def health
raise "Module #{self.class.name} doesn't override 'health'"
end
|
#initialize_module ⇒ Object
17
18
|
# File 'lib/what/modules/base.rb', line 17
def initialize_module
end
|
#name ⇒ Object
20
21
22
|
# File 'lib/what/modules/base.rb', line 20
def name
Helpers.underscore(self.class.name.split('::').last)
end
|
#status ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/what/modules/base.rb', line 27
def status
status = {}
status['name'] = @name if @name
status['type'] = name status['health'] = if @max == 'ok' || health == 'ok'
'ok'
elsif @max == 'warning' || health == 'warning'
'warning'
else
'alert'
end
status['details'] = details
status
end
|