annotate python/example/rss.py @ 833:f91b1b475dee

add silvermirror
author Jeff Hammel <k0scist@gmail.com>
date Mon, 20 Feb 2017 20:17:51 -0800
parents 7c2dbd45c346
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
821
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 import psutil
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 PSNAME = 'python'
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 for process in psutil.process_iter():
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 try:
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 memory = process.memory_info()
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 if process.name() == PSNAME:
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 print int(memory.rss)
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 except Exception:
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 pass