From: Brian Warner Date: Thu, 8 Mar 2007 03:31:49 +0000 (-0700) Subject: control.py: fix get_memory_usage, add a sample client tool X-Git-Url: https://git.rkrishnan.org/webform_css?a=commitdiff_plain;h=228e17560a95f37169c91a5df8faf55b28880a13;p=tahoe-lafs%2Ftahoe-lafs.git control.py: fix get_memory_usage, add a sample client tool --- diff --git a/misc/getmem.py b/misc/getmem.py new file mode 100644 index 00000000..171340d2 --- /dev/null +++ b/misc/getmem.py @@ -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() diff --git a/src/allmydata/control.py b/src/allmydata/control.py index 4c4ea1eb..d2d756da 100644 --- a/src/allmydata/control.py +++ b/src/allmydata/control.py @@ -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