[SERVER-28711] Change hang_analyzer.py to use psutil to find running processes Created: 10/Apr/17  Updated: 06/Dec/22  Resolved: 11/May/20

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Jonathan Abrahams Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Won't Fix Votes: 0
Labels: stm, tig-hanganalyzer
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Assigned Teams:
Server Tooling & Methods
Participants:

 Description   

Simplify the way running processes are found.



 Comments   
Comment by Ryan Timmons [ 11/May/20 ]

Closing as wont-fix to indicate that there is currently no intention of doing this. Please re-open if there is priority for this. Perhaps this change could self-service by an appropriate server team if this is necessary rather than having to go thru the STM prioritization queue.

Comment by Jonathan Abrahams [ 24/May/17 ]

Sample python code to do this:

import os
import psutil
 
 
def get_pid_proc():
    all_processes = []
    for pid in psutil.pids():
        all_processes.append([pid, psutil.Process(pid).name()])
    return all_processes
 
 
def main():
    interesting_processes = ["mongo", "mongod", "mongos", "_test", "dbtest", "python", "java"]
    greedy = []
    exact = []
 
    all_processes = get_pid_proc()
    for pid, pname in all_processes:
        print pid, pname
        if any(ip in pname.lower() for ip in interesting_processes) and pid != os.getpid():
            greedy.append([pid, pname])
        if any(pname.lower() == ip for ip in interesting_processes) and pid != os.getpid():
            exact.append([pid, pname])
 
    print("Greedy", greedy)
    print("Exact", exact)
 
if __name__ == "__main__":
    main()

Generated at Thu Feb 08 04:18:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.