annotate python/example/rss.py @ 871:1b6f0650dabb

add script to generate passwords
author Jeff Hammel <k0scist@gmail.com>
date Tue, 07 May 2019 10:34:38 -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