Class: What::Modules::Process

Inherits:
Base
  • Object
show all
Defined in:
lib/what/modules/process.rb

Instance Attribute Summary

Attributes inherited from Base

#interval

Instance Method Summary collapse

Methods inherited from Base

#identifier, #initialize, #name, #shared_status, #start_monitoring, #status

Constructor Details

This class inherits a constructor from What::Modules::Base

Instance Method Details

#checkObject



8
9
10
11
12
13
# File 'lib/what/modules/process.rb', line 8

def check
  @processes = Helpers.process_lines.grep(@regexp).map do |ln|
                 ln =~ /^\w+\s+(\d+).*(\d+:\d\d(?:\.\d\d)?) (.*)$/
                 {'pid' => $1, 'cpu_time' => $2, 'proctitle' => $3.strip}
               end
end

#detailsObject



23
24
25
# File 'lib/what/modules/process.rb', line 23

def details
  {'processes' => @processes}
end

#healthObject



15
16
17
18
19
20
21
# File 'lib/what/modules/process.rb', line 15

def health
  if @processes.count > 0
    'ok'
  else
    'alert'
  end
end

#initialize_moduleObject



3
4
5
6
# File 'lib/what/modules/process.rb', line 3

def initialize_module
  @regexp = Regexp.new(@config['regexp'] || @name)
  @processes = []
end