fix oom-sort

This commit is contained in:
Alexey Avramov 2018-12-09 11:40:40 +09:00
parent d4591c2126
commit 3830179a68

View File

@ -2,6 +2,9 @@
""" """
sort processes by oom_score sort processes by oom_score
""" """
# нужна еще валидация cli ввода
from operator import itemgetter from operator import itemgetter
from os import listdir from os import listdir
from argparse import ArgumentParser from argparse import ArgumentParser
@ -11,7 +14,7 @@ parser = ArgumentParser()
parser.add_argument( parser.add_argument(
'--num', '--num',
'-n', '-n',
help="""max number of lines; integer, not negative; default: 99999""", help="""max number of lines; default: 99999""",
default=None, default=None,
type=str type=str
) )
@ -76,10 +79,10 @@ for pid in listdir('/proc'):
oom_list_sorted = sorted(oom_list, key=itemgetter(1), reverse=True) oom_list_sorted = sorted(oom_list, key=itemgetter(1), reverse=True)
if display_cmdline == '0': if display_cmdline == '0':
print('oom_score oom_score_adj Uid Pid Name VmRSS VmSwap') print('oom_score oom_score_adj UID PID Name VmRSS VmSwap')
print('--------- ------------- ----- ----- --------------- -------- --------') print('--------- ------------- ----- ----- --------------- -------- --------')
else: else:
print('oom_score oom_score_adj Uid Pid Name VmRSS VmSwap cmdline') print('oom_score oom_score_adj UID PID Name VmRSS VmSwap cmdline')
print('--------- ------------- ----- ----- --------------- -------- -------- -------') print('--------- ------------- ----- ----- --------------- -------- -------- -------')
# итерируемся по сортированному списку oom_score, печатая name, pid etc # итерируемся по сортированному списку oom_score, печатая name, pid etc