]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
control.py: fix get_memory_usage, add a sample client tool
authorBrian Warner <warner@lothar.com>
Thu, 8 Mar 2007 03:31:49 +0000 (20:31 -0700)
committerBrian Warner <warner@lothar.com>
Thu, 8 Mar 2007 03:31:49 +0000 (20:31 -0700)
misc/getmem.py [new file with mode: 0644]
src/allmydata/control.py

diff --git a/misc/getmem.py b/misc/getmem.py
new file mode 100644 (file)
index 0000000..171340d
--- /dev/null
@@ -0,0 +1,18 @@
+#! /usr/bin/python
+
+from foolscap import Tub
+from foolscap.eventual import eventually
+import sys
+from twisted.internet import reactor
+
+def go():
+    t = Tub()
+    d = t.getReference(sys.argv[1])
+    d.addCallback(lambda rref: rref.callRemote("get_memory_usage"))
+    def _got(res):
+        print res
+        reactor.stop()
+    d.addCallback(_got)
+
+eventually(go)
+reactor.run()
index 4c4ea1eb6b15dfddb95643f224cc9431a27d318e..d2d756daf376cf44a4ab91b6448b3dab5c339c8a 100644 (file)
@@ -29,5 +29,7 @@ class ControlServer(Referenceable, service.Service):
         for line in open("/proc/self/status", "r").readlines():
             name, right = line.split(":",2)
             if name in stat_names:
-                stats[name] = int(right.strip()) * 1024
+                assert right.endswith(" kB\n")
+                right = right[:-4]
+                stats[name] = int(right) * 1024
         return stats