Class: What::Modules::Process
- Inherits:
-
Base
- Object
- Base
- What::Modules::Process
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
Instance Method Details
#check ⇒ Object
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
|
#details ⇒ Object
23
24
25
|
# File 'lib/what/modules/process.rb', line 23
def details
{'processes' => @processes}
end
|
#health ⇒ Object
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_module ⇒ Object
3
4
5
6
|
# File 'lib/what/modules/process.rb', line 3
def initialize_module
@regexp = Regexp.new(@config['regexp'] || @name)
@processes = []
end
|