Last active
August 29, 2015 14:04
-
-
Save FrostyX/95822fa5ce34ead7b140 to your computer and use it in GitHub Desktop.
Print list of processes with deleted files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import psutil | |
import re | |
paths = ['/usr/bin', '/usr/sbin', '/usr/lib', '/lib'] | |
combined = "(" + ")|(".join(paths) + ")" | |
processes = [] | |
for pid in psutil.get_pid_list(): | |
try: | |
p = psutil.Process(pid) | |
for mmap in p.get_memory_maps(): | |
if re.match(combined, mmap.path): | |
if mmap.path.endswith('(deleted)'): | |
processes.append(p) | |
except psutil.AccessDenied: | |
pass | |
except psutil.NoSuchProcess: | |
pass | |
for p in set(processes): | |
print p.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment