display VmSize of victim in reports

This commit is contained in:
Alexey Avramov 2018-12-12 02:29:35 +09:00
parent 72a6ca50af
commit 158404867f
2 changed files with 12 additions and 4 deletions

View File

@ -116,7 +116,7 @@ The program can be configured by editing the [config file](https://github.com/ha
1. Memory levels to respond to as an OOM threat
2. The frequency of checking the level of available memory (and CPU usage)
3. The prevention of killing innocent victims
4. Impact on the badness of processes via matching their names and cmdlines with regular expressions
4. Impact on the badness of processes via matching their names, cmdlines and UIDs with regular expressions
5. The execution of a specific command instead of sending the SIGTERM signal
6. GUI notifications:
- results of preventing OOM
@ -190,7 +190,7 @@ Please create [issues](https://github.com/hakavlad/nohang/issues). Use cases, fe
- Fix: replace `re.fullmatch()` by `re.search()`
- Validation RE patterns at startup
- Improve output:
- Display `UID`, `RssAnon`, `RssFile`, `RssShmem` and `cmdline` of the victim in corrective action reports
- Display `UID`, `VmSize`, `RssAnon`, `RssFile`, `RssShmem` and `cmdline` of the victim in corrective action reports
- Print in terminal with colors
- Optimize limiting `oom_score_adj`: now it can works without UID=0
- Optimize GUI warnings: find env without run `ps` and `env` (partially implemented)

12
nohang
View File

@ -422,6 +422,11 @@ def find_victim_and_send_signal(signal):
uid = line.split('\t')[1]
continue
if n is vm_size_index:
vm_size = kib_to_mib(int(line.split('\t')[1][:-4]))
continue
if n is vm_rss_index:
vm_rss = kib_to_mib(int(line.split('\t')[1][:-4]))
continue
@ -477,12 +482,13 @@ def find_victim_and_send_signal(signal):
'\n PID: \033[33m{}\033[0m' \
'\n UID: \033[33m{}\033[0m' \
'\n Badness: \033[33m{}\033[0m' \
'\n VmSize: \033[33m{}\033[0m MiB' \
'\n VmRSS: \033[33m{}\033[0m MiB' \
'\n VmSwap: \033[33m{}\033[0m MiB' \
'\n CmdLine: \033[33m{}\033[0m' \
'\n Execute the command: \033[4m{}\033[0m' \
'\n Exit status: {}; response time: {} ms'.format(
name, pid, uid, victim_badness, vm_rss, vm_swap,
name, pid, uid, victim_badness, vm_size, vm_rss, vm_swap,
cmdline, command, exit_status,
round(response_time * 1000))
@ -516,11 +522,12 @@ def find_victim_and_send_signal(signal):
'\n PID: \033[33m{}\033[0m' \
'\n UID: \033[33m{}\033[0m' \
'\n Badness: \033[33m{}\033[0m' \
'\n VmSize: \033[33m{}\033[0m MiB' \
'\n VmRSS: \033[33m{}\033[0m MiB' \
'\n VmSwap: \033[33m{}\033[0m MiB' \
'\n CmdLine: \033[33m{}\033[0m' \
'\n Sending \033[4m{}\033[0m to the victim; {}'.format(
name, pid, uid, victim_badness, vm_rss, vm_swap,
name, pid, uid, victim_badness, vm_size, vm_rss, vm_swap,
cmdline, sig_dict[signal], send_result)
print(mem_info)
print(preventing_oom_message)
@ -704,6 +711,7 @@ status_names = []
for s in status_list:
status_names.append(s.split(':')[0])
vm_size_index = status_names.index('VmSize')
vm_rss_index = status_names.index('VmRSS')
vm_swap_index = status_names.index('VmSwap')
uid_index = status_names.index('Uid')