summaryrefslogtreecommitdiff
path: root/scripts/profiling/doc_put_memory_usage/get-soledad-and-couch-mem.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-10-07 18:56:31 +0200
committerKali Kaneko <kali@leap.se>2014-10-07 18:56:31 +0200
commit42d9b82af327fee94a8b626e2606b0b854140ce2 (patch)
tree846eaf6fae05d1c6755f87535b35d44ab022b0b1 /scripts/profiling/doc_put_memory_usage/get-soledad-and-couch-mem.py
parenta7568bd38bdc63de5f074861862390281f49abf0 (diff)
parent0a66ad2bbebb366a72de925ab6ebf65e1bd117c0 (diff)
Merge remote-tracking branch 'remotes/drebs-github/deb-0.6.0' into debian
Diffstat (limited to 'scripts/profiling/doc_put_memory_usage/get-soledad-and-couch-mem.py')
-rwxr-xr-xscripts/profiling/doc_put_memory_usage/get-soledad-and-couch-mem.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/profiling/doc_put_memory_usage/get-soledad-and-couch-mem.py b/scripts/profiling/doc_put_memory_usage/get-soledad-and-couch-mem.py
new file mode 100755
index 00000000..b2b35d30
--- /dev/null
+++ b/scripts/profiling/doc_put_memory_usage/get-soledad-and-couch-mem.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+
+import logging
+import argparse
+import psutil
+import time
+
+
+def find_procs(procs):
+ result = []
+ for name, executable in procs:
+ found = filter(
+ lambda p: executable == p.name,
+ psutil.process_iter())
+ if len(found) == 1:
+ result.append(found[0])
+ return result
+
+
+def log_memory(soledad, bigcouch):
+ while True:
+ print "%f %f" % \
+ (soledad.get_memory_percent(), bigcouch.get_memory_percent())
+ time.sleep(1)
+
+
+if __name__ == '__main__':
+
+ # configure logger
+ logger = logging.getLogger(__name__)
+ LOG_FORMAT = '%(asctime)s %(message)s'
+ logging.basicConfig(format=LOG_FORMAT, level=logging.INFO)
+
+
+ # parse command line
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ '-l', dest='logfile',
+ help='log output to file')
+ args = parser.parse_args()
+
+ log_memory(*find_procs([
+ ('Soledad', 'twistd'),
+ ('Bigcouch', 'beam.smp')]))
+