##// END OF EJS Templates
system-info: use real memory usage based on new psutil api available from 4.0 release....
marcink -
r1116:6aa0fbf7 default
parent child Browse files
Show More
@@ -139,21 +139,22 b' def uptime():'
139
139
140 def memory():
140 def memory():
141 from rhodecode.lib.helpers import format_byte_size_binary
141 from rhodecode.lib.helpers import format_byte_size_binary
142 value = dict(available=0, used=0, cached=0, percent=0, percent_used=0,
142 value = dict(available=0, used=0, used_real=0, cached=0, percent=0,
143 free=0, inactive=0, active=0, shared=0, total=0, buffers=0,
143 percent_used=0, free=0, inactive=0, active=0, shared=0,
144 text='')
144 total=0, buffers=0, text='')
145
145
146 state = STATE_OK_DEFAULT
146 state = STATE_OK_DEFAULT
147 if not psutil:
147 if not psutil:
148 return SysInfoRes(value=value, state=state)
148 return SysInfoRes(value=value, state=state)
149
149
150 value.update(dict(psutil.virtual_memory()._asdict()))
150 value.update(dict(psutil.virtual_memory()._asdict()))
151 value['used_real'] = value['total'] - value['available']
151 value['percent_used'] = psutil._common.usage_percent(
152 value['percent_used'] = psutil._common.usage_percent(
152 (value['total'] - value['free']), value['total'], 1)
153 value['used_real'], value['total'], 1)
153
154
154 human_value = value.copy()
155 human_value = value.copy()
155 human_value['text'] = '%s/%s, %s%% used' % (
156 human_value['text'] = '%s/%s, %s%% used' % (
156 format_byte_size_binary(value['used']),
157 format_byte_size_binary(value['used_real']),
157 format_byte_size_binary(value['total']),
158 format_byte_size_binary(value['total']),
158 value['percent_used'],)
159 value['percent_used'],)
159
160
General Comments 0
You need to be logged in to leave comments. Login now