From eb0b1d9356de7b29032c3386ca382d816ca85bcf Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Tue, 10 Jul 2018 18:14:53 +0900 Subject: [PATCH] update readme and conf --- README.md | 25 +++++++++++++---- nohang | 10 +++---- nohang.conf | 81 ++++++++++++++++++++++++++++++----------------------- 3 files changed, 70 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 375176c..0e6db6f 100644 --- a/README.md +++ b/README.md @@ -64,17 +64,17 @@ MemAvail: 4610 M, 78.5 % | SwapFree: 9024 M, 83.9 % ### Requirements -- Linux 3.14+ -- Python 3.4+ +- `Linux 3.14+` (because the MemAvailable parameter appeared in /proc/meminfo since kernel version 3.14) and `Python 3.4+` (compatibility with earlier versions was not tested) for basic usage +- `libnotify` (Fedora, Arch) or `libnotify-bin` (Debian, Ubuntu) for desktop notifications and `sudo` for desktop notifications as root ### Memory and CPU usage -- VmRSS is 10 - 14 MiB depending on the settings +- VmRSS is 10 — 13.5 MiB depending on the settings - CPU usage depends on the level of available memory (the frequency of memory status checks increases as the amount of available memory decreases) and monitoring intensity (can be changed by user via config) ### Status -The program is unstable and some fixes are required before the first stable version will be released. (Need documentation, translation, review.) +The program is unstable and some fixes are required before the first stable version will be released (need documentation, translation, review and some optimisation). ### Download @@ -110,9 +110,22 @@ optional arguments: ### How to configure nohang -Just read the config and edit values. Run the command `sudo systemctl restart nohang` to apply changes. +The program can be configured by editing the config file. The configuration includes the following sections: + +- I. STANDARD OUTPUT VERBOSITY +- II. SELF-DEFENSE +- III. INTENSITY OF MONITORING +- IV. THRESHOLDS FOR SENDING SIGNALS +- V. PREVENTION OF KILLING INNOCENT VICTIMS +- VI. DESKTOP NOTIFICATIONS +- VII. AVOID AND PREFER VICTIM NAMES VIA REGEX +- VIII. LOGGING +- IX. LOW MEMORY WARNINGS +- X. EXECUTE THE COMMAND INSTEAD OF SENDING THE SIGTERM SIGNAL + +Just read the description of the parameters and edit the values. Run the command `sudo systemctl restart nohang` to apply changes. ### Feedback -Please create [issues](https://github.com/hakavlad/nohang/issues). +Please create [issues](https://github.com/hakavlad/nohang/issues). Use cases, feature requests and any questions are welcome. diff --git a/nohang b/nohang index a8f2e8b..5a360b4 100755 --- a/nohang +++ b/nohang @@ -1208,7 +1208,7 @@ if print_config: print('print_mem_check_results: {}'.format(print_mem_check_results)) print('print_sleep_periods: {}'.format(print_sleep_periods)) - print('\nII. SELF-DEFENSE') + print('\nII. SELF-DEFENSE [displaying these options need fix]') print('mlockall: {} ({})'.format(mlockall, mla_res)) print('self_nice: {} ({})'.format( self_nice, self_nice_result @@ -1217,12 +1217,12 @@ if print_config: self_oom_score_adj, self_oom_score_adj_result )) - print('\nIII. MONITORING INTENSITY') + print('\nIII. INTENSITY OF MONITORING') print('rate_mem: {}'.format(rate_mem)) print('rate_swap: {}'.format(rate_swap)) print('rate_zram: {}'.format(rate_zram)) - print('\nIV. THRESHOLDS FOR SENDING SIGNALS') + print('\nIV. THRESHOLDS FOR SENDING SIGNALS [displaying these options need fix]') print('mem_min_sigterm: {} MiB, {} %'.format( round(mem_min_sigterm_mb), round(mem_min_sigterm_percent, 1))) @@ -1255,7 +1255,7 @@ if print_config: print('notify_options: {}'.format(notify_options)) print('root_display: {}'.format(root_display)) - print('\nVII. BLACK, WHITE, AVOID AND PREFER LISTS') + print('\nVII. AVOID AND PREFER VICTIM NAMES VIA REGEX') print('use_regex_lists: {}'.format(use_regex_lists)) if use_regex_lists: print('whitelist_regex: {}'.format(whitelist_regex)) @@ -1285,7 +1285,7 @@ if print_config: print('\nX. EXECUTE THE COMMAND INSTEAD OF SENDING THE SIGTERM SIGNAL') - print('execute_the_command: {}'.format(execute_the_command)) + print('execute_the_command: {}'.format(execute_the_command)) if execute_the_command: print('\nPROCESS NAME COMMAND TO EXECUTE') for key in etc_dict: diff --git a/nohang.conf b/nohang.conf index 2c8245b..dbb809b 100644 --- a/nohang.conf +++ b/nohang.conf @@ -1,7 +1,23 @@ This is nohang config file. - Lines beginning with #, tabs and spaces are comments. + Lines starting with #, tabs and spaces are comments. + + The configuration includes the following sections: + + I. STANDARD OUTPUT VERBOSITY + II. SELF-DEFENSE + III. INTENSITY OF MONITORING + IV. THRESHOLDS FOR SENDING SIGNALS + V. PREVENTION OF KILLING INNOCENT VICTIMS + VI. DESKTOP NOTIFICATIONS + VII. AVOID AND PREFER VICTIM NAMES VIA REGEX + VIII. LOGGING + IX. LOW MEMORY WARNINGS + X. EXECUTE THE COMMAND INSTEAD OF SENDING THE SIGTERM SIGNAL + + Just read the description of the parameters and edit the values. + Please restart the program after editing the config. ##################################################################### @@ -52,12 +68,11 @@ self_oom_score_adj = -100 ##################################################################### - III. MONITORING INTENSITY + III. INTENSITY OF MONITORING - Коэффициенты, влияющие на интенсивность мониторинга. - Допустимыми значениями являются положительные числа. - Уменьшение коэффициентов способно снизить нагрузку на - прцессор и увеличить периоды между проверками памяти. + Coefficients that affect the intensity of monitoring. Reducing + the coefficients can reduce CPU usage and increase the periods + between memory checks. Почему три коэффициента, а не один? - Потому что скорость наполнения свопа обычно ниже скорости наполнения RAM. @@ -69,6 +84,10 @@ self_oom_score_adj = -100 достаточно хорошо, успешно справляясь с резкими скачками потребления памяти. + Default values are well for desktop. + On servers without rapid fluctuations in memory level, the + values can be reduced. + Valid values are positive floating-point numbers. rate_mem = 6 @@ -79,14 +98,11 @@ rate_zram = 1 IV. THRESHOLDS FOR SENDING SIGNALS - Задание уровней доступной памяти, ниже которых происходит - отправка сигналов SIGTERM или SIGKILL. - - Сигнал отправляется если MemAvailable и SwapFree одновременно - опустятся ниже соответствующих значений. - - Can be specified in % (percent) and M (MiB). - Valid values are floating-point numbers from the range [0; 100] %. + Sets the available memory levels below which SIGTERM or SIGKILL + signals are sent. The signal will be sent if MemAvailable and + SwapFree at the same time will drop below the corresponding + values. Can be specified in % (percent) and M (MiB). Valid values + are floating-point numbers from the range [0; 100] %. mem_min_sigterm = 9 % mem_min_sigkill = 6 % @@ -94,15 +110,13 @@ mem_min_sigkill = 6 % swap_min_sigterm = 9 % swap_min_sigkill = 6 % - Задание общей доли zram в памяти, при превышении которой - происходит отправка соответствующих сигналов. - По мере увеличения доли zram в памяти может падать - отзывчивость системы. + Specifying the total share of zram in memory, if exceeded the + corresponding signals are sent. As the share of zram in memory + increases, it may fall responsiveness of the system. 90 % is a + usual hang level, not recommended to set very high. - Can also be specified in % and M. - Valid values are floating-point numbers from the range [0; 100] %. - 90 % is a usual hang level, not recommended to set very high - level. + Can be specified in % and M. Valid values are floating-point + numbers from the range [0; 100] %. zram_max_sigterm = 55 % zram_max_sigkill = 60 % @@ -118,7 +132,7 @@ zram_max_sigkill = 60 % Valid values are integers from the range [0; 1000]. -oom_score_min = 20 +oom_score_min = 10 Минимальная задержка после отправки соответствующих сигналов для предотвращения риска убийства сразу множества процессов. @@ -136,8 +150,6 @@ min_delay_after_sigkill = 3 в значение True, то у процессов, имеющих oom_score_adj выше oom_score_adj_max значение oom_score_adj будет опущено до oom_score_adj_max перед поиском жертвы. - False - не изменять oom_score_adj процессов перед поиском - жертвы. Значения чувствительны к регистру! Enabling the option requires root privileges. Valid values are True and False. @@ -152,7 +164,7 @@ oom_score_adj_max = 20 VI. DESKTOP NOTIFICATIONS - Эта возможность требует наличия notify-send в системе. + Включение этой опции требует наличия notify-send в системе. В Debian/Ubuntu это обеспечивается установкой пакета libnotify-bin. В Fedora и Arch Linux - пакет libnotify. Также требуется наличие сервера уведомлений. @@ -180,7 +192,7 @@ root_display = :0 ##################################################################### - VII. BLACK, WHITE, AVOID AND PREFER LISTS + VII. AVOID AND PREFER VICTIM NAMES VIA REGEX Можно задать регулярные выражения (Perl-compatible regular expressions), которые будут использоваться для сопоставления с @@ -238,8 +250,8 @@ avoidlist_factor = 3 VIII. LOGGING - Date, the amount of available memory and OOM prevention progress - can be logged. + OOM prevention progress can be logged. + Valid values are True and False. logging = True @@ -263,7 +275,7 @@ low_memory_warnings = False min_time_between_warnings = 20 - Уровни MemAvailable и SwapFree одновременно будут ниже + Если значения MemAvailable и SwapFree одновременно будут ниже соотвестствующих значений, то будут отправлены уведомления. Can be specified in % (percent) and M (MiB). @@ -274,7 +286,7 @@ mem_min_warnings = 20 % swap_min_warnings = 20 % Если доля zram в памяти превысит значение zram_max_warnings, - то будут отправляться уведомления с минимальным периодом + то будут отправляться уведомления с минимальным периодом равным min_time_between_warnings. zram_max_warnings = 40 % @@ -299,13 +311,12 @@ execute_the_command = False содержащими имена процессов и соотвестствующие команды для перезапуска этих процессов. После имени процесса через двойное двоеточие (::) следует команда. + Амперсанд (&) в конце команды позволит nohang продолжить работу + не дожидаясь окончания выполнения команды. For example: ** mysqld :: systemctl restart mariadb.service & ** php-fpm7.0 :: systemctl restart php7.0-fpm.service & - Амперсанд (&) в конце команды позволит nohang продолжить работу - не дожидаясь окончания выполнения команды. - -** processname :: some command & +** processname :: some command