mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Added solaris to the list of supported operating systems for memory stats.
This commit is contained in:
parent
05f8d6a2f8
commit
2757f239b1
@ -185,25 +185,16 @@ class Status(callbacks.Privmsg):
|
|||||||
activeThreads))
|
activeThreads))
|
||||||
mem = None
|
mem = None
|
||||||
pid = os.getpid()
|
pid = os.getpid()
|
||||||
|
plat = sys.platform
|
||||||
try:
|
try:
|
||||||
if sys.platform.startswith('linux'):
|
if plat.startswith('linux') or plat.startswith('sunos') or \
|
||||||
mem = 0
|
plat.startswith('freebsd') or plat.startswith('openbsd'):
|
||||||
fd = file('/proc/%s/status' % pid)
|
r = os.popen('ps -o vsz -p %s' % pid)
|
||||||
for line in fd:
|
r.readline() # VSZ Header.
|
||||||
if line.startswith('VmSize'):
|
mem = int(r.readline().strip())
|
||||||
line = line.rstrip()
|
r.close()
|
||||||
mem = int(line.split()[1])
|
|
||||||
break
|
|
||||||
assert mem, 'Format changed in /proc/<pid>/status'
|
|
||||||
elif sys.platform.startswith('netbsd'):
|
elif sys.platform.startswith('netbsd'):
|
||||||
mem = os.stat('/proc/%s/mem')[7]
|
mem = os.stat('/proc/%s/mem')[7]
|
||||||
elif sys.platform.startswith('freebsd') or \
|
|
||||||
sys.platform.startswith('openbsd'):
|
|
||||||
r = os.popen('/bin/ps -l -p %s' % pid)
|
|
||||||
line = r.readline()
|
|
||||||
line = line.strip()
|
|
||||||
r.close()
|
|
||||||
mem = int(line.split()[20])
|
|
||||||
response += ' I\'m taking up %s kB of memory.' % mem
|
response += ' I\'m taking up %s kB of memory.' % mem
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
debug.msg(debug.exnToString(e))
|
debug.msg(debug.exnToString(e))
|
||||||
|
Loading…
Reference in New Issue
Block a user