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 - In progress
- [x] Improve output: - [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] 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] Added memory report interval
- [x] Add delta memory info (the rate of change of available memory) - [x] Added delta memory info (the rate of change of available memory)
- [x] Print statistics on corrective actions after each corrective action - [x] Print statistics on corrective actions after each corrective action
- [x] Added ability to print a process table before 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] Added the ability to log into a separate file
- [x] Improve poll rate algorithm - [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 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] 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] 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] Find env without run `ps`
- [x] Handle all timeouts when notify-send starts - [x] Handle all timeouts when notify-send starts
- [x] Fix conf parsing: use of `line.partition('=')` instead of `line.split('=')` - [x] Fixed conf parsing: use of `line.partition('=')` instead of `line.split('=')`
- [x] Add `oom-sort` - [x] Added `oom-sort`
- [x] Add `--version` and `--test` flags - [x] Added new CLI options:
- [x] Remove self-defense options from config, use systemd unit scheduling instead - [x] -v, --version
- [x] Add the ability to send any signal instead of SIGTERM for processes with certain names - [x] -t, --test
- [x] Handle `UnicodeDecodeError` if victim name consists of many unicode characters ([rfjakob/earlyoom#110](https://github.com/rfjakob/earlyoom/issues/110)) - [x] --ppt, --print-proc-table
- [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] Removed self-defense options from config, use systemd unit scheduling instead
- [x] Reduce memory usage and startup time (using `sys.argv` instead of `argparse`) - [x] Added the ability to send any signal instead of SIGTERM for processes with certain names
- [x] Add initial support for `PSI` - [x] Handled `UnicodeDecodeError` if victim name consists of many unicode characters ([rfjakob/earlyoom#110](https://github.com/rfjakob/earlyoom/issues/110))
- [x] Improve modifing badness via matching with regular expressions: - [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] 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] 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()` - [x] Fix: replace `re.fullmatch()` by `re.search()`
- [ ] Redesign of the GUI notifications - [ ] Redesign of the GUI notifications
- [ ] Improve user input validation - [ ] Improve user input validation

52
nohang
View File

@ -674,6 +674,9 @@ def send_notify_etc(pid, name, command):
command.replace('&', '*') command.replace('&', '*')
) )
# write() -> wrinte_notify(title, body)
write('{}\x00{}'.format(title, body)) write('{}\x00{}'.format(title, body))
os.system(notify_helper_path + ' &') os.system(notify_helper_path + ' &')
''' '''
@ -698,9 +701,8 @@ def sleep_after_send_signal(signal):
sleep(min_delay_after_sigkill) sleep(min_delay_after_sigkill)
else: else:
if print_sleep_periods: if print_sleep_periods:
log( log('Sleep {} sec after implementing a corrective action'.format(
'Sleep {} sec after implementing a corrective action'.format( min_delay_after_sigterm))
min_delay_after_sigterm))
sleep(min_delay_after_sigterm) sleep(min_delay_after_sigterm)
@ -1047,11 +1049,21 @@ def find_victim_info(pid, victim_badness, name):
return victim_info return victim_info
# для дедупликации уведомлений
dick = dict()
dick['v'] = [1, 2, 3, time()]
def implement_corrective_action(signal): def implement_corrective_action(signal):
""" """
Find victim with highest badness and send SIGTERM/SIGKILL Find victim with highest badness and send SIGTERM/SIGKILL
""" """
notif = True
log(mem_info) log(mem_info)
pid, victim_badness, name = find_victim(print_proc_table) pid, victim_badness, name = find_victim(print_proc_table)
@ -1152,7 +1164,39 @@ def implement_corrective_action(signal):
) )
if gui_notifications: if gui_notifications:
send_notify(signal, name, pid)
# 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: except FileNotFoundError:
response_time = time() - time0 response_time = time() - time0

View File

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