@@ -9,7 +9,6 @@ module KernelIntrospection
99 Log .info { " pids ls_proc: #{ ls_proc } " }
1010 parsed_ls = KernelIntrospection .parse_ls(ls_proc[:output ])
1111 pids = KernelIntrospection .pids_from_ls_proc(parsed_ls)
12- Log .info { " pids pids: #{ pids } " }
1312 pids
1413 end
1514
@@ -64,42 +63,54 @@ module KernelIntrospection
6463 end
6564
6665 def self.proctree_by_pid (potential_parent_pid : String , node : JSON ::Any , proc_statuses : (Array (String ) | Nil ) = nil ) : Array (Hash (String , String )) # array of status hashes
67- Log .info { " proctree_by_node potential_parent_pid: #{ potential_parent_pid } " }
66+ Log .for( " proctree_by_pid " ). info { " proctree_by_pid potential_parent_pid: #{ potential_parent_pid } " }
6867 proctree = [] of Hash (String , String )
6968 potential_parent_status : Hash (String , String ) | Nil = nil
7069 unless proc_statuses
7170 pids = pids(node)
72- Log .info { " proctree_by_pid pids: #{ pids } " }
71+ Log .for( " proctree_by_pid " ).debug { " pids: #{ pids } " }
7372 proc_statuses = all_statuses_by_pids(pids, node)
7473 end
75- Log .debug { " proctree_by_pid proc_statuses: #{ proc_statuses } " }
74+ Log .for( " proctree_by_pid " ). debug { " proc_statuses: #{ proc_statuses } " }
7675 proc_statuses.each do |proc_status |
7776 parsed_status = KernelIntrospection .parse_status(proc_status)
78- Log .debug { " proctree_by_pid parsed_status: #{ parsed_status } " }
77+ Log .for( " proctree_by_pid " ). debug { " parsed_status: #{ parsed_status } " }
7978 if parsed_status
8079 ppid = parsed_status[" PPid" ].strip
8180 current_pid = parsed_status[" Pid" ].strip
82- Log .info { " potential_parent_pid, ppid, current_pid #{ potential_parent_pid } , #{ ppid } , #{ current_pid } " }
81+ Log .for(" proctree_by_pid" ).debug(& .emit(
82+ potential_parent_pid: potential_parent_pid,
83+ ppid: ppid,
84+ current_pid: current_pid
85+ ))
8386 # save potential parent pid
8487 if current_pid == potential_parent_pid
85- Log .info { " current_pid == potential_parent_pid" }
8688 cmdline = cmdline_by_pid(current_pid, node)[:output ]
87- Log .info { " cmdline: #{ cmdline } " }
89+ Log .for(" proctree_by_pid" ).debug(& .emit(
90+ " current_pid == potential_parent_pid" ,
91+ current_pid: current_pid,
92+ cmdline: cmdline
93+ ))
8894 potential_parent_status = parsed_status.merge({" cmdline" => cmdline})
89- proctree << potential_parent_status
90- # Add descendeds of the parent pid
95+ proctree << potential_parent_status
96+ # Add descendants of the parent pid
9197 elsif ppid == potential_parent_pid && ppid != current_pid
92- Log .info { " ppid == potential_parent_pid" }
93- Log .info { " proctree_by_pid ppid == pid && ppid != current_pid: pid, ppid,
94- current_pid #{ potential_parent_pid } , #{ ppid } , #{ current_pid } " }
98+ Log .for(" proctree_by_pid" ).debug(& .emit(
99+ " proctree_by_pid ppid == pid && ppid != current_pid" ,
100+ potential_parent_pid: potential_parent_pid,
101+ ppid: ppid,
102+ current_pid: current_pid
103+ ))
95104 cmdline = cmdline_by_pid(current_pid, node)[:output ]
96- Log .info { " the matched descendent is cmdline: #{ cmdline } " }
105+ Log .for( " proctree_by_pid " ).debug( & .emit( " Matched descendent cmdline " , cmdline: cmdline))
97106 proctree = proctree + proctree_by_pid(current_pid, node, proc_statuses)
98107 end
99108 end
100109 end
101- Log .info { " proctree_by_node final proctree: #{ proctree } " }
102- proctree.each{|x | Log .info { " Process name: #{ x[" Name" ] } , pid: #{ x[" Pid" ] } , ppid: #{ x[" PPid" ] } " } }
110+ Log .for(" proctree_by_pid" ).debug { " proctree: #{ proctree } " }
111+ proctree.each do |x |
112+ Log .for(" proctree_by_pid" ).debug(& .emit(process_name: x[" Name" ], pid: x[" Pid" ], ppid: x[" PPid" ]))
113+ end
103114 proctree
104115 end
105116 end
@@ -163,12 +174,16 @@ module KernelIntrospection
163174 # there are some nodes that wont have a proc with this pid in it
164175 # e.g. a stand alone pod gets installed on only one node
165176 process = ClusterTools .exec_by_node(" cat /proc/#{ pid } /cmdline" , node)
166- Log .info {" cat /proc/#{ pid } /cmdline process: #{ process[:output ] } " }
167177 status = ClusterTools .exec_by_node(" cat /proc/#{ pid } /status" , node)
168- Log .info {" status: #{ status } " }
178+ Log .for(" find_first_process" ).debug(& .emit(
179+ " process status and cmdline" ,
180+ pid: pid,
181+ cmdline: process[:output ],
182+ status: " #{ status } " ,
183+ ))
169184 if process[:output ] =~ /#{ process_name } /
170185 ret = {node: node, pod: pod, container_status: container_status, status: status[:output ], pid: pid.to_s, cmdline: process[:output ]}
171- Log .info { " status found: #{ ret } " }
186+ Log .for( " find_first_process " ). info { " status found: #{ ret } " }
172187 break
173188 end
174189 end
@@ -199,9 +214,13 @@ module KernelIntrospection
199214 # there are some nodes that wont have a proc with this pid in it
200215 # e.g. a stand alone pod gets installed on only one node
201216 process = ClusterTools .exec_by_node(" cat /proc/#{ pid } /cmdline" , node)
202- Log .info {" cat /proc/#{ pid } /cmdline process: #{ process[:output ] } " }
203- status = ClusterTools .exec_by_node(" cat /proc/#{ pid } /status" , node)
204- Log .info {" status: #{ status } " }
217+ cat_cmdline_cmd = " cat /proc/#{ pid } /status"
218+ status = ClusterTools .exec_by_node(cat_cmdline_cmd, node)
219+ Log .for(" find_matching_processes" ).debug(& .emit(
220+ cat_cmdline_cmd: cat_cmdline_cmd,
221+ process: " #{ process[:output ] } " ,
222+ status: " #{ status } "
223+ ))
205224 if process[:output ] =~ /#{ process_name } /
206225 result = {node: node, pod: pod, container_status: container_status, status: status[:output ], pid: pid.to_s, cmdline: process[:output ]}
207226 results.push(result)
0 commit comments