7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/eye/process/child.rb', line 7
def add_or_update_childs
return unless self[:monitor_children]
return unless self.up?
unless self.pid
warn 'Cant add childs, because no pid'
return
end
now_childs = Eye::SystemResources.childs(self.pid)
new_childs = []
exist_childs = []
now_childs.each do |child_pid|
if self.childs[child_pid]
exist_childs << child_pid
else
new_childs << child_pid
end
end
removed_childs = self.childs.keys - now_childs
if new_childs.present?
new_childs.each do |child_pid|
self.childs[child_pid] = Eye::ChildProcess.new(child_pid, self[:monitor_children], logger.prefix)
end
end
if removed_childs.present?
removed_childs.each{|child_pid| remove_child(child_pid) }
end
h = {:new => new_childs.size, :removed => removed_childs.size, :exists => exist_childs.size }
debug "childs info: #{ h.inspect }"
h
end
|