##// END OF EJS Templates
system-info: use safer resource.getrlimit becuase of #5501
marcink -
r3184:343cf3c2 default
parent child Browse files
Show More
@@ -74,10 +74,17 b' def get_storage_size(storage_path):'
74 74 return sum(sizes)
75 75
76 76
77 def get_resource(resource_type):
78 try:
79 return resource.getrlimit(resource_type)
80 except Exception:
81 return 'NOT_SUPPORTED'
82
83
77 84 class SysInfoRes(object):
78 def __init__(self, value, state=STATE_OK_DEFAULT, human_value=None):
85 def __init__(self, value, state=None, human_value=None):
79 86 self.value = value
80 self.state = state
87 self.state = state or STATE_OK_DEFAULT
81 88 self.human_value = human_value or value
82 89
83 90 def __json__(self):
@@ -159,16 +166,16 b' def locale_info():'
159 166
160 167 def ulimit_info():
161 168 data = collections.OrderedDict([
162 ('cpu time (seconds)', resource.getrlimit(resource.RLIMIT_CPU)),
163 ('file size', resource.getrlimit(resource.RLIMIT_FSIZE)),
164 ('stack size', resource.getrlimit(resource.RLIMIT_STACK)),
165 ('core file size', resource.getrlimit(resource.RLIMIT_CORE)),
166 ('address space size', resource.getrlimit(resource.RLIMIT_AS)),
167 ('locked in mem size', resource.getrlimit(resource.RLIMIT_MEMLOCK)),
168 ('heap size', resource.getrlimit(resource.RLIMIT_DATA)),
169 ('rss size', resource.getrlimit(resource.RLIMIT_RSS)),
170 ('number of processes', resource.getrlimit(resource.RLIMIT_NPROC)),
171 ('open files', resource.getrlimit(resource.RLIMIT_NOFILE)),
169 ('cpu time (seconds)', get_resource(resource.RLIMIT_CPU)),
170 ('file size', get_resource(resource.RLIMIT_FSIZE)),
171 ('stack size', get_resource(resource.RLIMIT_STACK)),
172 ('core file size', get_resource(resource.RLIMIT_CORE)),
173 ('address space size', get_resource(resource.RLIMIT_AS)),
174 ('locked in mem size', get_resource(resource.RLIMIT_MEMLOCK)),
175 ('heap size', get_resource(resource.RLIMIT_DATA)),
176 ('rss size', get_resource(resource.RLIMIT_RSS)),
177 ('number of processes', get_resource(resource.RLIMIT_NPROC)),
178 ('open files', get_resource(resource.RLIMIT_NOFILE)),
172 179 ])
173 180
174 181 text = ', '.join('{}:{}'.format(k,v) for k,v in data.items())
General Comments 0
You need to be logged in to leave comments. Login now