annotate python/example/rss.py @ 897:ba2630ce851b

update default branch for git
author Jeff Hammel <k0scist@gmail.com>
date Mon, 01 Aug 2022 16:40:53 -0700
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