mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-27 14:50:03 +00:00
control.py: fix get_memory_usage, add a sample client tool
This commit is contained in:
parent
751587f376
commit
228e17560a
18
misc/getmem.py
Normal file
18
misc/getmem.py
Normal file
@ -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()
|
@ -29,5 +29,7 @@ class ControlServer(Referenceable, service.Service):
|
|||||||
for line in open("/proc/self/status", "r").readlines():
|
for line in open("/proc/self/status", "r").readlines():
|
||||||
name, right = line.split(":",2)
|
name, right = line.split(":",2)
|
||||||
if name in stat_names:
|
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
|
return stats
|
||||||
|
Loading…
x
Reference in New Issue
Block a user