Added solaris to the list of supported operating systems for memory stats.

This commit is contained in:
Jeremy Fincher 2003-10-28 20:18:33 +00:00
parent 05f8d6a2f8
commit 2757f239b1

View File

@ -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))