Class: What::Modules::Unicorn
- Inherits:
-
Base
- Object
- Base
- What::Modules::Unicorn
show all
- Defined in:
- lib/what/modules/unicorn.rb
Constant Summary
collapse
- DEFAULTS =
{
'warning' => 1,
'alert' => 0
}
Instance Attribute Summary
Attributes inherited from Base
#interval
Instance Method Summary
collapse
Methods inherited from Base
#identifier, #initialize, #name, #shared_status, #start_monitoring, #status
Instance Method Details
#check ⇒ Object
12
13
14
15
16
17
|
# File 'lib/what/modules/unicorn.rb', line 12
def check
@unicorns = Helpers.process_lines.split("\n").grep(/unicorn_rails worker/).map do |ln|
ln =~ /^\w+\s+(\d+).*(\d+:\d\d(?:\.\d\d)?) unicorn/
{'pid' => $1, 'cpu_time' => $2}
end
end
|
#details ⇒ Object
29
30
31
|
# File 'lib/what/modules/unicorn.rb', line 29
def details
{'workers' => @unicorns.count, 'details' => @unicorns}
end
|
#health ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/what/modules/unicorn.rb', line 19
def health
if @unicorns.count > @config['warning']
'ok'
elsif @unicorns.count > @config['alert']
'warning'
else
'alert'
end
end
|
#initialize_module ⇒ Object
8
9
10
|
# File 'lib/what/modules/unicorn.rb', line 8
def initialize_module
@unicorns = []
end
|