Get the process IDs that we want to kill but are still alive.
(ip, port, killed_pids)
| 76 | |
| 77 | |
| 78 | def get_killed_pids(ip, port, killed_pids): |
| 79 | """Get the process IDs that we want to kill but are still alive.""" |
| 80 | killed_pids = [str(pid) for pid in killed_pids] |
| 81 | killed_pids = ",".join(killed_pids) |
| 82 | ps_cmd = ( |
| 83 | "ssh -o StrictHostKeyChecking=no -p " |
| 84 | + str(port) |
| 85 | + " " |
| 86 | + ip |
| 87 | + " 'ps -p {} -h'".format(killed_pids) |
| 88 | ) |
| 89 | res = subprocess.run(ps_cmd, shell=True, stdout=subprocess.PIPE) |
| 90 | pids = [] |
| 91 | for p in res.stdout.decode("utf-8").split("\n"): |
| 92 | l = p.split() |
| 93 | if len(l) > 0: |
| 94 | pids.append(int(l[0])) |
| 95 | return pids |
| 96 | |
| 97 | |
| 98 | def execute_remote( |