Class: What::Modules::Unicorn
Constant Summary collapse
- DEFAULTS =
{ 'warning' => 1, 'alert' => 0 }
Instance Method Summary collapse
- #check! ⇒ Object
- #details ⇒ Object
- #health ⇒ Object
-
#initialize ⇒ Unicorn
constructor
A new instance of Unicorn.
Methods inherited from Base
Constructor Details
#initialize ⇒ Unicorn
Returns a new instance of Unicorn.
8 9 10 11 |
# File 'lib/what/modules/unicorn.rb', line 8 def initialize super @unicorns = [] end |
Instance Method Details
#check! ⇒ Object
13 14 15 16 17 18 |
# File 'lib/what/modules/unicorn.rb', line 13 def check! @unicorns = `ps aux`.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
30 31 32 |
# File 'lib/what/modules/unicorn.rb', line 30 def details {'workers' => @unicorns.count, 'details' => @unicorns} end |
#health ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/what/modules/unicorn.rb', line 20 def health if @unicorns.count > @config['warning'] 'ok' elsif @unicorns.count > @config['alert'] 'warning' else 'alert' end end |