Class: What::Modules::Processes
- Defined in:
- lib/what/modules/processes.rb
Instance Method Summary collapse
- #check! ⇒ Object
- #details ⇒ Object
- #health ⇒ Object
-
#initialize ⇒ Processes
constructor
A new instance of Processes.
Methods inherited from Base
Constructor Details
#initialize ⇒ Processes
Returns a new instance of Processes.
3 4 5 6 7 8 9 |
# File 'lib/what/modules/processes.rb', line 3 def initialize super @config.each do |name, regexp_str| @config[name] = Regexp.new(regexp_str) end @processes = {} end |
Instance Method Details
#check! ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/what/modules/processes.rb', line 11 def check! @config.each do |name, regexp| @processes[name] = `ps aux`.split("\n").grep(regexp).map do |ln| ln =~ /^\w+\s+(\d+).*(\d+:\d\d(?:\.\d\d)?) (.*)$/ {'pid' => $1, 'cpu_time' => $2, 'proctitle' => $3.strip} end end end |
#details ⇒ Object
30 31 32 |
# File 'lib/what/modules/processes.rb', line 30 def details @processes end |
#health ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/what/modules/processes.rb', line 20 def health all_ok = true @processes.each do |name, results| if results.count == 0 all_ok = false end end all_ok ? 'ok' : 'alert' end |