fix readme

This commit is contained in:
Alexey Avramov 2019-03-21 13:47:35 +09:00
parent 74a20ce28e
commit 0bb7d706b9
3 changed files with 67 additions and 20 deletions

View File

@ -214,30 +214,33 @@ Please create [issues](https://github.com/hakavlad/nohang/issues). Use cases, fe
- In progress
- [x] Improve output:
- [x] Display `oom_score`, `oom_score_adj`, `Ancestry`, `EUID`, `State`, `VmSize`, `RssAnon`, `RssFile`, `RssShmem`, `Realpath`, `Cmdline` and `Lifetime` of the victim in corrective action reports
- [x] Add memory report interval
- [x] Add delta memory info (the rate of change of available memory)
- [x] Added memory report interval
- [x] Added delta memory info (the rate of change of available memory)
- [x] Print statistics on corrective actions after each corrective action
- [x] Added ability to print a process table before each corrective action
- [x] Added the ability to log into a separate file
- [x] Improve poll rate algorithm
- [x] Add `max_post_sigterm_victim_lifetime` option: send SIGKILL to the victim if it doesn't respond to SIGTERM for a certain time
- [x] Added `max_post_sigterm_victim_lifetime` option: send SIGKILL to the victim if it doesn't respond to SIGTERM for a certain time
- [x] Improve victim search algorithm (do it ~30% faster) ([rfjakob/earlyoom#114](https://github.com/rfjakob/earlyoom/issues/114))
- [x] Improve limiting `oom_score_adj`: now it can works with UID != 0
- [x] Fixed process crash before performing corrective actions if Python 3.3 or Python 3.4 are used to interpret nohang
- [x] Improve GUI warnings:
- [x] Improved GUI warnings:
- [x] Find env without run `ps`
- [x] Handle all timeouts when notify-send starts
- [x] Fix conf parsing: use of `line.partition('=')` instead of `line.split('=')`
- [x] Add `oom-sort`
- [x] Add `--version` and `--test` flags
- [x] Remove self-defense options from config, use systemd unit scheduling instead
- [x] Add the ability to send any signal instead of SIGTERM for processes with certain names
- [x] Handle `UnicodeDecodeError` if victim name consists of many unicode characters ([rfjakob/earlyoom#110](https://github.com/rfjakob/earlyoom/issues/110))
- [x] Reduce memory usage with `mlockall()` using `MCL_ONFAULT` ([rfjakob/earlyoom#112](https://github.com/rfjakob/earlyoom/issues/112)) and lock all memory by default
- [x] Reduce memory usage and startup time (using `sys.argv` instead of `argparse`)
- [x] Add initial support for `PSI`
- [x] Improve modifing badness via matching with regular expressions:
- [x] Adding the ability to set many different `badness_adj` for processes depending on the matching `name`, `cmdline` and `euid` with the specified regular expressions ([issue #74](https://github.com/hakavlad/nohang/issues/11))
- [x] Fixed conf parsing: use of `line.partition('=')` instead of `line.split('=')`
- [x] Added `oom-sort`
- [x] Added new CLI options:
- [x] -v, --version
- [x] -t, --test
- [x] --ppt, --print-proc-table
- [x] Removed self-defense options from config, use systemd unit scheduling instead
- [x] Added the ability to send any signal instead of SIGTERM for processes with certain names
- [x] Handled `UnicodeDecodeError` if victim name consists of many unicode characters ([rfjakob/earlyoom#110](https://github.com/rfjakob/earlyoom/issues/110))
- [x] Reduced memory usage with `mlockall()` using `MCL_ONFAULT` ([rfjakob/earlyoom#112](https://github.com/rfjakob/earlyoom/issues/112)) and lock all memory by default
- [x] Reduced memory usage and startup time (using `sys.argv` instead of `argparse`)
- [x] Added initial support for `PSI`
- [x] Improved modifing badness via matching with regular expressions:
- [x] Added the ability to set many different `badness_adj` for processes depending on the matching `name`, `cmdline` and `euid` with the specified regular expressions ([issue #74](https://github.com/hakavlad/nohang/issues/11))
- [x] Fix: replace `re.fullmatch()` by `re.search()`
- [ ] Redesign of the GUI notifications
- [ ] Improve user input validation

48
nohang
View File

@ -674,6 +674,9 @@ def send_notify_etc(pid, name, command):
command.replace('&', '*')
)
# write() -> wrinte_notify(title, body)
write('{}\x00{}'.format(title, body))
os.system(notify_helper_path + ' &')
'''
@ -698,8 +701,7 @@ def sleep_after_send_signal(signal):
sleep(min_delay_after_sigkill)
else:
if print_sleep_periods:
log(
'Sleep {} sec after implementing a corrective action'.format(
log('Sleep {} sec after implementing a corrective action'.format(
min_delay_after_sigterm))
sleep(min_delay_after_sigterm)
@ -1047,11 +1049,21 @@ def find_victim_info(pid, victim_badness, name):
return victim_info
# для дедупликации уведомлений
dick = dict()
dick['v'] = [1, 2, 3, time()]
def implement_corrective_action(signal):
"""
Find victim with highest badness and send SIGTERM/SIGKILL
"""
notif = True
log(mem_info)
pid, victim_badness, name = find_victim(print_proc_table)
@ -1152,8 +1164,40 @@ def implement_corrective_action(signal):
)
if gui_notifications:
# min delay after same notification
# все не так. От этого вообще пол дедупликация . терминация один раз покажется при любом раскладе.
delay_after_same_notify = 1
x = dick['v']
dick['v'] = [signal, name, pid, time()]
y = dick['v']
print(y[3] - x[3])
if x[0] == y[0] and x[1] == y[1] and x[2] == y[2]:
print('совпадение имени, пид, сигнала')
# сохр в словаре первре совпавшее время
dt = y[3] - x[3]
print(dt, 'dt')
if dt < delay_after_same_notify:
notif = False
if notif:
send_notify(signal, name, pid)
except FileNotFoundError:
response_time = time() - time0
send_result = 'no such process; response time: {} ms'.format(

View File

@ -309,7 +309,7 @@ $ETC apache2 /// systemctl restart apache2
See also wiki.archlinux.org/index.php/Desktop_notifications
Valid values are True and False.
gui_notifications = False
gui_notifications = True
Enable GUI notifications about the low level of available memory.
Valid values are True and False.