##// END OF EJS Templates
processes: use resources library to fetch limits in better way.
marcink -
r2674:c19b5f32 default
parent child Browse files
Show More
@@ -23,9 +23,10 b' import os'
23 23 import sys
24 24 import time
25 25 import platform
26 import subprocess32
26 import collections
27 27 import pkg_resources
28 28 import logging
29 import resource
29 30
30 31 from pyramid.compat import configparser
31 32
@@ -142,23 +143,23 b' def platform_type():'
142 143
143 144
144 145 def ulimit_info():
145 data = {}
146 data = collections.OrderedDict([
147 ('cpu time (seconds)', resource.getrlimit(resource.RLIMIT_CPU)),
148 ('file size', resource.getrlimit(resource.RLIMIT_FSIZE)),
149 ('stack size', resource.getrlimit(resource.RLIMIT_STACK)),
150 ('core file size', resource.getrlimit(resource.RLIMIT_CORE)),
151 ('address space size', resource.getrlimit(resource.RLIMIT_AS)),
152 ('locked in mem size', resource.getrlimit(resource.RLIMIT_MEMLOCK)),
153 ('heap size', resource.getrlimit(resource.RLIMIT_DATA)),
154 ('rss size', resource.getrlimit(resource.RLIMIT_RSS)),
155 ('number of processes', resource.getrlimit(resource.RLIMIT_NPROC)),
156 ('open files', resource.getrlimit(resource.RLIMIT_NOFILE)),
157 ])
146 158
147 text = 'ulimit -a unavailable'
148 try:
149 result = subprocess32.check_output(
150 ['ulimit -a'], timeout=10, stderr=subprocess32.STDOUT,
151 shell=True)
152
153 for line in result.splitlines():
154 key, val = line.split(' ', 1)
155 data[key.strip()] = val.strip()
156 159 text = ', '.join('{}:{}'.format(k,v) for k,v in data.items())
157 except Exception:
158 log.exception('ulimit check problem')
159 160
160 161 value = {
161 'ulimit': data,
162 'limits': data,
162 163 'text': text,
163 164 }
164 165 return SysInfoRes(value=value)
General Comments 0
You need to be logged in to leave comments. Login now