changeset 821:7c2dbd45c346

rss example program
author Jeff Hammel <k0scist@gmail.com>
date Tue, 31 Jan 2017 17:38:05 -0800
parents 737b9eda7f77
children 570ace9ed7c2
files python/example/rss.py
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/example/rss.py	Tue Jan 31 17:38:05 2017 -0800
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+import psutil
+
+PSNAME = 'python'
+
+for process in psutil.process_iter():
+    try:
+        memory = process.memory_info()
+        if process.name() == PSNAME:
+            print int(memory.rss)
+    except Exception:
+        pass