Show More
@@ -124,7 +124,7 b' class AdminSystemInfoSettingsView(AdminS' | |||||
124 | ('', '', ''), # spacer |
|
124 | ('', '', ''), # spacer | |
125 |
|
125 | |||
126 | # Systems stats |
|
126 | # Systems stats | |
127 | (_('CPU'), val('cpu'), state('cpu')), |
|
127 | (_('CPU'), val('cpu')['text'], state('cpu')), | |
128 | (_('Load'), val('load')['text'], state('load')), |
|
128 | (_('Load'), val('load')['text'], state('load')), | |
129 | (_('Memory'), val('memory')['text'], state('memory')), |
|
129 | (_('Memory'), val('memory')['text'], state('memory')), | |
130 | (_('Uptime'), val('uptime')['text'], state('uptime')), |
|
130 | (_('Uptime'), val('uptime')['text'], state('uptime')), |
@@ -206,14 +206,20 b' def machine_load():' | |||||
206 |
|
206 | |||
207 |
|
207 | |||
208 | def cpu(): |
|
208 | def cpu(): | |
209 | value = 0 |
|
209 | value = {'cpu': 0, 'cpu_count': 0, 'cpu_usage': []} | |
210 | state = STATE_OK_DEFAULT |
|
210 | state = STATE_OK_DEFAULT | |
211 |
|
211 | |||
212 | if not psutil: |
|
212 | if not psutil: | |
213 | return SysInfoRes(value=value, state=state) |
|
213 | return SysInfoRes(value=value, state=state) | |
214 |
|
214 | |||
215 | value = psutil.cpu_percent(0.5) |
|
215 | value['cpu'] = psutil.cpu_percent(0.5) | |
216 | human_value = '{} %'.format(value) |
|
216 | value['cpu_usage'] = psutil.cpu_percent(0.5, percpu=True) | |
|
217 | value['cpu_count'] = psutil.cpu_count() | |||
|
218 | ||||
|
219 | human_value = value.copy() | |||
|
220 | human_value['text'] = '{} cores at {} %'.format( | |||
|
221 | value['cpu_count'], value['cpu']) | |||
|
222 | ||||
217 | return SysInfoRes(value=value, state=state, human_value=human_value) |
|
223 | return SysInfoRes(value=value, state=state, human_value=human_value) | |
218 |
|
224 | |||
219 |
|
225 |
General Comments 0
You need to be logged in to leave comments.
Login now