Created
July 27, 2015 12:13
-
-
Save Ivlyth/d7e0f1f3762a56f73bfd to your computer and use it in GitHub Desktop.
how_many_open_files
This file contains hidden or 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
def how_many_open_files(): | |
import psutil | |
pss = psutil.process_iter() | |
total_count = 0 | |
for p in pss: | |
if p.num_fds() != len(p.open_files()): | |
print u'%s with pid %d has diff fds num %d and open files num %d'%(p.name, p.pid, p.num_fds(), len(p.open_files())) | |
total_count += len(p.open_files()) | |
return total_count | |
how_many_open_files() | |
for p in sorted(list(psutil.process_iter()), key=lambda x:len(x.open_files()), reverse=True)[:30]: | |
print u'%s %d %d'%(p.name(), len(p.open_files()), p.num_fds()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment