Deal with deleted users before logind restart
This commit is contained in:
parent
007b0efb5d
commit
1071f4b66e
|
@ -36,6 +36,7 @@ def get_users_list():
|
|||
|
||||
|
||||
def get_resources_percent(username=None):
|
||||
try:
|
||||
if username is None:
|
||||
user_opt = ['-e']
|
||||
else:
|
||||
|
@ -46,6 +47,8 @@ def get_resources_percent(username=None):
|
|||
cmd = Popen(['ps', '-o', 'pmem', '--no-headers'] + user_opt, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
|
||||
output = map(float, cmd.stdout.read().decode('utf8').split())
|
||||
mem_percent = sum(output)
|
||||
except:
|
||||
cpu_percent = mem_percent = 0
|
||||
return cpu_percent, mem_percent
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue