rename config keys

This commit is contained in:
Alexey Avramov 2019-07-17 02:09:27 +09:00
parent d233b17bd5
commit 444904bbaf
2 changed files with 307 additions and 306 deletions

535
nohang
View File

@ -26,49 +26,43 @@ def check_config():
log('0. Common zram settings') log('0. Common zram settings')
log(' ignore_zram: {}'.format(ignore_zram)) log(' zram_checking_enabled: {}'.format(zram_checking_enabled))
log('1. Thresholds below which a signal should be sent to the victim') log('1. Thresholds below which a signal should be sent to the victim')
log(' mem_min_sigterm: {} MiB, {} %'.format( log(' soft_threshold_min_mem: {} MiB, {} %'.format(round(soft_threshold_min_mem_mb), round(soft_threshold_min_mem_percent, 1)))
round(mem_min_sigterm_mb), round(mem_min_sigterm_percent, 1))) log(' hard_threshold_min_mem: {} MiB, {} %'.format(round(hard_threshold_min_mem_mb), round(hard_threshold_min_mem_percent, 1)))
log(' mem_min_sigkill: {} MiB, {} %'.format( log(' soft_threshold_min_swap: {}'.format(soft_threshold_min_swap))
round(mem_min_sigkill_mb), round(mem_min_sigkill_percent, 1))) log(' hard_threshold_min_swap: {}'.format(hard_threshold_min_swap))
log(' soft_threshold_max_zram: {} MiB, {} %'.format(round(soft_threshold_max_zram_mb), round(soft_threshold_max_zram_percent, 1)))
log(' swap_min_sigterm: {}'.format(swap_min_sigterm)) log(' hard_threshold_max_zram: {} MiB, {} %'.format(round(hard_threshold_max_zram_mb), round(hard_threshold_max_zram_percent, 1)))
log(' swap_min_sigkill: {}'.format(swap_min_sigkill))
log(' zram_max_sigterm: {} MiB, {} %'.format(
round(zram_max_sigterm_mb), round(zram_max_sigterm_percent, 1)))
log(' zram_max_sigkill: {} MiB, {} %'.format(
round(zram_max_sigkill_mb), round(zram_max_sigkill_percent, 1)))
log('2. Response on PSI memory metrics') log('2. Response on PSI memory metrics')
log(' ignore_psi: {}'.format(ignore_psi)) log(' psi_checking_enabled: {}'.format(psi_checking_enabled))
log(' psi_path: {}'.format(psi_path)) log(' psi_path: {}'.format(psi_path))
log(' psi_metrics: {}'.format(psi_metrics)) log(' psi_metrics: {}'.format(psi_metrics))
log(' sigterm_psi_threshold: {}'.format(sigterm_psi_threshold)) log(' soft_threshold_max_psi: {}'.format(soft_threshold_max_psi))
log(' sigkill_psi_threshold: {}'.format(sigkill_psi_threshold)) log(' hard_threshold_max_psi: {}'.format(hard_threshold_max_psi))
log(' psi_excess_duration: {} sec'.format(psi_excess_duration)) log(' psi_excess_duration: {} sec'.format(psi_excess_duration))
log(' psi_post_action_delay: {} sec'.format(psi_post_action_delay)) log(' psi_post_action_delay: {} sec'.format(psi_post_action_delay))
log('3. The frequency of checking the amount of available memory') log('3. The frequency of checking the amount of available memory')
log(' rate_mem: {}'.format(rate_mem)) log(' fill_rate_mem: {}'.format(fill_rate_mem))
log(' rate_swap: {}'.format(rate_swap)) log(' fill_rate_swap: {}'.format(fill_rate_swap))
log(' rate_zram: {}'.format(rate_zram)) log(' fill_rate_zram: {}'.format(fill_rate_zram))
log(' max_sleep: {} sec'.format(max_sleep)) log(' max_sleep: {} sec'.format(max_sleep))
log(' min_sleep: {} sec'.format(min_sleep)) log(' min_sleep: {} sec'.format(min_sleep))
log(' over_sleep: {} sec'.format(over_sleep)) log(' over_sleep: {} sec'.format(over_sleep))
log('4. The prevention of killing innocent victims') log('4. The prevention of killing innocent victims')
log(' min_badness: {}'.format(min_badness)) log(' min_badness: {}'.format(min_badness))
log(' min_delay_after_sigterm: {} sec'.format(min_delay_after_sigterm)) log(' post_soft_action_delay: {} sec'.format(post_soft_action_delay))
log(' post_zombie_delay: {} sec'.format(post_zombie_delay)) log(' post_zombie_delay: {} sec'.format(post_zombie_delay))
log(' victim_cache_time: {} sec'.format(victim_cache_time)) log(' victim_cache_time: {} sec'.format(victim_cache_time))
log(' ignore_positive_oom_score_adj: {}'.format(ignore_positive_oom_score_adj)) log(' ignore_positive_oom_score_adj: {}'.format(ignore_positive_oom_score_adj))
log('5. Impact on the badness of processes') log('5. Impact on the badness of processes')
@ -139,40 +133,36 @@ def check_config():
log('7. GUI notifications') log('7. GUI notifications')
log(' gui_notifications: {}'.format(gui_notifications)) log(' post_action_gui_notifications: {}'.format(post_action_gui_notifications))
log(' gui_low_memory_warnings: {}'.format(gui_low_memory_warnings)) log(' low_memory_warnings_enabled: {}'.format(low_memory_warnings_enabled))
log(' warning_exe: {}'.format(warning_exe)) log(' warning_exe: {}'.format(warning_exe))
log(' mem_min_warnings: {} MiB, {} %'.format( log(' warning_threshold_min_mem: {} MiB, {} %'.format(round(warning_threshold_min_mem_mb), round(warning_threshold_min_mem_percent, 1)))
round(mem_min_warnings_mb), round(mem_min_warnings_percent, 1))) log(' warning_threshold_min_swap: {}'.format(warning_threshold_min_swap))
log(' swap_min_warnings: {}'.format(swap_min_warnings)) log(' warning_threshold_max_zram: {} MiB, {} %'.format(round(warning_threshold_max_zram_mb), round(warning_threshold_max_zram_percent, 1)))
log(' zram_max_warnings: {} MiB, {} %'.format( log(' warning_threshold_max_psi: {}'.format(warning_threshold_max_psi))
round(zram_max_warnings_mb), round(zram_max_warnings_percent, 1))) log(' min_post_warning_delay: {} sec'.format(min_post_warning_delay))
log(' psi_avg_warnings: {}'.format(psi_avg_warnings))
log(' min_time_between_warnings: {} sec'.format(
min_time_between_warnings))
log('8. Verbosity') log('8. Verbosity')
log(' print_config: {}'.format(print_config)) log(' print_config_at_startup: {}'.format(print_config_at_startup))
log(' print_mem_check_results: {}'.format(print_mem_check_results)) log(' print_mem_check_results: {}'.format(print_mem_check_results))
log(' min_mem_report_interval: {} sec'.format(min_mem_report_interval)) log(' min_mem_report_interval: {} sec'.format(min_mem_report_interval))
log(' print_sleep_periods: {}'.format(print_sleep_periods)) log(' debug_sleep: {}'.format(debug_sleep))
log(' print_total_stat: {}'.format(print_total_stat)) log(' print_statistics: {}'.format(print_statistics))
log(' print_proc_table: {}'.format(print_proc_table)) log(' print_proc_table: {}'.format(print_proc_table))
log(' extra_table_info: {}'.format(extra_table_info)) log(' extra_table_info: {}'.format(extra_table_info))
log(' print_victim_info: {}'.format(print_victim_info)) log(' print_victim_status: {}'.format(print_victim_status))
log(' print_victim_cmdline: {}'.format(print_victim_cmdline)) log(' print_victim_cmdline: {}'.format(print_victim_cmdline))
log(' max_ancestry_depth: {}'.format(max_ancestry_depth)) log(' max_victim_ancestry_depth: {}'.format(max_victim_ancestry_depth))
log(' debug_gui_notifications: {}'.format(debug_gui_notifications)) log(' debug_gui_notifications: {}'.format(debug_gui_notifications))
log(' separate_log: {}'.format(separate_log)) log(' separate_log: {}'.format(separate_log))
log(' psi_debug: {}'.format(psi_debug)) log(' debug_psi: {}'.format(debug_psi))
log('9. Misc') log('9. Misc')
log(' max_post_sigterm_victim_lifetime: {} sec'.format( log(' max_soft_exit_time: {} sec'.format(max_soft_exit_time))
max_post_sigterm_victim_lifetime)) log(' post_kill_exe: {}'.format(post_kill_exe))
log(' post_kill_exe: {}'.format(post_kill_exe)) log(' forbid_negative_badness: {}'.format(
log(' forbid_negative_badness: {}'.format(
forbid_negative_badness)) forbid_negative_badness))
# log(': {}'.format()) # log(': {}'.format())
@ -471,17 +461,17 @@ def pid_to_ppid(pid):
return f_list[i].split('\t')[1] return f_list[i].split('\t')[1]
def pid_to_ancestry(pid, max_ancestry_depth=1): def pid_to_ancestry(pid, max_victim_ancestry_depth=1):
""" """
""" """
if max_ancestry_depth == 1: if max_victim_ancestry_depth == 1:
ppid = pid_to_ppid(pid) ppid = pid_to_ppid(pid)
pname = pid_to_name(ppid) pname = pid_to_name(ppid)
return '\n PPID: {} ({})'.format(ppid, pname) return '\n PPID: {} ({})'.format(ppid, pname)
if max_ancestry_depth == 0: if max_victim_ancestry_depth == 0:
return '' return ''
anc_list = [] anc_list = []
for i in range(max_ancestry_depth): for i in range(max_victim_ancestry_depth):
ppid = pid_to_ppid(pid) ppid = pid_to_ppid(pid)
pname = pid_to_name(ppid) pname = pid_to_name(ppid)
anc_list.append((ppid, pname)) anc_list.append((ppid, pname))
@ -762,7 +752,7 @@ def update_stat_dict_and_print(key):
new_value = stat_dict[key] + 1 new_value = stat_dict[key] + 1
stat_dict.update({key: new_value}) stat_dict.update({key: new_value})
if print_total_stat: if print_statistics:
stats_msg = 'Total stat (what happened in the last {}):'.format( stats_msg = 'Total stat (what happened in the last {}):'.format(
format_time(time() - start_time)) format_time(time() - start_time))
@ -1379,7 +1369,7 @@ def find_victim_info(pid, victim_badness, name):
'The victim died in the search process: FileNotFoundError') 'The victim died in the search process: FileNotFoundError')
return None return None
ancestry = pid_to_ancestry(pid, max_ancestry_depth) ancestry = pid_to_ancestry(pid, max_victim_ancestry_depth)
if print_victim_cmdline is False: if print_victim_cmdline is False:
cmdline = '' cmdline = ''
@ -1445,34 +1435,34 @@ def check_mem_swap_ex():
mem_available, swap_total, swap_free = check_mem_and_swap() mem_available, swap_total, swap_free = check_mem_and_swap()
# if swap_min_sigkill is set in percent # if hard_threshold_min_swap is set in percent
if swap_kill_is_percent: if swap_kill_is_percent:
swap_min_sigkill_kb = swap_total * swap_min_sigkill_percent / 100.0 hard_threshold_min_swap_kb = swap_total * hard_threshold_min_swap_percent / 100.0
else: else:
swap_min_sigkill_kb = swap_kb_dict['swap_min_sigkill_kb'] hard_threshold_min_swap_kb = swap_kb_dict['hard_threshold_min_swap_kb']
if swap_term_is_percent: if swap_term_is_percent:
swap_min_sigterm_kb = swap_total * swap_min_sigterm_percent / 100.0 soft_threshold_min_swap_kb = swap_total * soft_threshold_min_swap_percent / 100.0
else: else:
swap_min_sigterm_kb = swap_kb_dict['swap_min_sigterm_kb'] soft_threshold_min_swap_kb = swap_kb_dict['soft_threshold_min_swap_kb']
if swap_warn_is_percent: if swap_warn_is_percent:
swap_min_warnings_kb = swap_total * swap_min_warnings_percent / 100.0 warning_threshold_min_swap_kb = swap_total * warning_threshold_min_swap_percent / 100.0
else: else:
swap_min_warnings_kb = swap_kb_dict['swap_min_warnings_kb'] warning_threshold_min_swap_kb = swap_kb_dict['warning_threshold_min_swap_kb']
if swap_total > swap_min_sigkill_kb: if swap_total > hard_threshold_min_swap_kb:
swap_sigkill_pc = percent(swap_min_sigkill_kb / (swap_total + 0.1)) swap_sigkill_pc = percent(hard_threshold_min_swap_kb / (swap_total + 0.1))
else: else:
swap_sigkill_pc = '-' swap_sigkill_pc = '-'
if swap_total > swap_min_sigterm_kb: if swap_total > soft_threshold_min_swap_kb:
swap_sigterm_pc = percent(swap_min_sigterm_kb / (swap_total + 0.1)) swap_sigterm_pc = percent(soft_threshold_min_swap_kb / (swap_total + 0.1))
else: else:
swap_sigterm_pc = '-' swap_sigterm_pc = '-'
if (mem_available <= mem_min_sigkill_kb and if (mem_available <= hard_threshold_min_mem_kb and
swap_free <= swap_min_sigkill_kb): swap_free <= hard_threshold_min_swap_kb):
mem_info = 'Memory status that requ' \ mem_info = 'Memory status that requ' \
'ires corrective actions (hard threshold exceeded):' \ 'ires corrective actions (hard threshold exceeded):' \
@ -1481,18 +1471,18 @@ def check_mem_swap_ex():
'p_min_sigkill [{} MiB, {} %]'.format( 'p_min_sigkill [{} MiB, {} %]'.format(
kib_to_mib(mem_available), kib_to_mib(mem_available),
percent(mem_available / mem_total), percent(mem_available / mem_total),
kib_to_mib(mem_min_sigkill_kb), kib_to_mib(hard_threshold_min_mem_kb),
percent(mem_min_sigkill_kb / mem_total), percent(hard_threshold_min_mem_kb / mem_total),
kib_to_mib(swap_free), kib_to_mib(swap_free),
percent(swap_free / (swap_total + 0.1)), percent(swap_free / (swap_total + 0.1)),
kib_to_mib(swap_min_sigkill_kb), kib_to_mib(hard_threshold_min_swap_kb),
swap_sigkill_pc) swap_sigkill_pc)
return (SIGKILL, mem_info, mem_available, swap_min_sigkill_kb, return (SIGKILL, mem_info, mem_available, hard_threshold_min_swap_kb,
swap_min_sigterm_kb, swap_free, swap_total) soft_threshold_min_swap_kb, swap_free, swap_total)
if (mem_available <= mem_min_sigterm_kb and if (mem_available <= soft_threshold_min_mem_kb and
swap_free <= swap_min_sigterm_kb): swap_free <= soft_threshold_min_swap_kb):
mem_info = 'Memory status that requi' \ mem_info = 'Memory status that requi' \
'res corrective actions (soft threshold exceeded):' \ 'res corrective actions (soft threshold exceeded):' \
@ -1501,25 +1491,25 @@ def check_mem_swap_ex():
'p_min_sigterm [{} MiB, {} %]'.format( 'p_min_sigterm [{} MiB, {} %]'.format(
kib_to_mib(mem_available), kib_to_mib(mem_available),
percent(mem_available / mem_total), percent(mem_available / mem_total),
kib_to_mib(mem_min_sigterm_kb), kib_to_mib(soft_threshold_min_mem_kb),
round(mem_min_sigterm_percent, 1), round(soft_threshold_min_mem_percent, 1),
kib_to_mib(swap_free), kib_to_mib(swap_free),
percent(swap_free / (swap_total + 0.1)), percent(swap_free / (swap_total + 0.1)),
kib_to_mib(swap_min_sigterm_kb), kib_to_mib(soft_threshold_min_swap_kb),
swap_sigterm_pc) swap_sigterm_pc)
return (SIGTERM, mem_info, mem_available, swap_min_sigkill_kb, return (SIGTERM, mem_info, mem_available, hard_threshold_min_swap_kb,
swap_min_sigterm_kb, swap_free, swap_total) soft_threshold_min_swap_kb, swap_free, swap_total)
if gui_low_memory_warnings: if low_memory_warnings_enabled:
if (mem_available <= mem_min_warnings_kb and swap_free <= if (mem_available <= warning_threshold_min_mem_kb and swap_free <=
swap_min_warnings_kb + 0.1): warning_threshold_min_swap_kb + 0.1):
return ('WARN', None, mem_available, swap_min_sigkill_kb, return ('WARN', None, mem_available, hard_threshold_min_swap_kb,
swap_min_sigterm_kb, swap_free, swap_total) soft_threshold_min_swap_kb, swap_free, swap_total)
return (None, None, mem_available, swap_min_sigkill_kb, return (None, None, mem_available, hard_threshold_min_swap_kb,
swap_min_sigterm_kb, swap_free, swap_total) soft_threshold_min_swap_kb, swap_free, swap_total)
def check_zram_ex(): def check_zram_ex():
@ -1527,7 +1517,7 @@ def check_zram_ex():
""" """
mem_used_zram = check_zram() mem_used_zram = check_zram()
if mem_used_zram >= zram_max_sigkill_kb: if mem_used_zram >= hard_threshold_max_zram_kb:
mem_info = 'Memory status that requir' \ mem_info = 'Memory status that requir' \
'es corrective actions (hard threshold exceeded):' \ 'es corrective actions (hard threshold exceeded):' \
@ -1535,25 +1525,25 @@ def check_zram_ex():
'kill [{} MiB, {} %]'.format( 'kill [{} MiB, {} %]'.format(
kib_to_mib(mem_used_zram), kib_to_mib(mem_used_zram),
percent(mem_used_zram / mem_total), percent(mem_used_zram / mem_total),
kib_to_mib(zram_max_sigkill_kb), kib_to_mib(hard_threshold_max_zram_kb),
percent(zram_max_sigkill_kb / mem_total)) percent(hard_threshold_max_zram_kb / mem_total))
return SIGKILL, mem_info, mem_used_zram return SIGKILL, mem_info, mem_used_zram
if mem_used_zram >= zram_max_sigterm_kb: if mem_used_zram >= soft_threshold_max_zram_kb:
mem_info = 'Memory status that requires corrective actions (soft th' \ mem_info = 'Memory status that requires corrective actions (soft th' \
'reshold exceeded):\n MemUsedZram [{} MiB, {} %] >= zram_max_s' \ 'reshold exceeded):\n MemUsedZram [{} MiB, {} %] >= zram_max_s' \
'igterm [{} M, {} %]'.format( 'igterm [{} M, {} %]'.format(
kib_to_mib(mem_used_zram), kib_to_mib(mem_used_zram),
percent(mem_used_zram / mem_total), percent(mem_used_zram / mem_total),
kib_to_mib(zram_max_sigterm_kb), kib_to_mib(soft_threshold_max_zram_kb),
percent(zram_max_sigterm_kb / mem_total)) percent(soft_threshold_max_zram_kb / mem_total))
return SIGTERM, mem_info, mem_used_zram return SIGTERM, mem_info, mem_used_zram
if gui_low_memory_warnings: if low_memory_warnings_enabled:
if mem_used_zram >= zram_max_warnings_kb: if mem_used_zram >= warning_threshold_max_zram_kb:
return 'WARN', None, mem_used_zram return 'WARN', None, mem_used_zram
return None, None, mem_used_zram return None, None, mem_used_zram
@ -1586,14 +1576,14 @@ def check_psi_ex(psi_t0, psi_kill_exceeded_timer, psi_term_exceeded_timer, x0):
else: else:
psi_post_action_delay_exceeded = False psi_post_action_delay_exceeded = False
if psi_avg_value >= sigkill_psi_threshold: if psi_avg_value >= hard_threshold_max_psi:
sigkill_psi_exceeded = True sigkill_psi_exceeded = True
psi_kill_exceeded_timer += delta0 psi_kill_exceeded_timer += delta0
else: else:
sigkill_psi_exceeded = False sigkill_psi_exceeded = False
psi_kill_exceeded_timer = 0 psi_kill_exceeded_timer = 0
if psi_debug: if debug_psi:
log('psi_post_action_delay_timer: {}'.format( log('psi_post_action_delay_timer: {}'.format(
round(psi_post_action_delay_timer, 3))) round(psi_post_action_delay_timer, 3)))
@ -1609,11 +1599,11 @@ def check_psi_ex(psi_t0, psi_kill_exceeded_timer, psi_term_exceeded_timer, x0):
if (psi_kill_exceeded_timer >= psi_excess_duration and if (psi_kill_exceeded_timer >= psi_excess_duration and
psi_post_action_delay_exceeded): psi_post_action_delay_exceeded):
mem_info = 'PSI avg ({}) > sigkill_psi_threshold ({})\n' \ mem_info = 'PSI avg ({}) > hard_threshold_max_psi ({})\n' \
'PSI avg exceeded psi_excess_duration (value' \ 'PSI avg exceeded psi_excess_duration (value' \
' = {} sec) for {} seconds'.format( ' = {} sec) for {} seconds'.format(
psi_avg_value, psi_avg_value,
sigkill_psi_threshold, hard_threshold_max_psi,
psi_excess_duration, psi_excess_duration,
round(psi_kill_exceeded_timer, 1) round(psi_kill_exceeded_timer, 1)
) )
@ -1621,14 +1611,14 @@ def check_psi_ex(psi_t0, psi_kill_exceeded_timer, psi_term_exceeded_timer, x0):
return (SIGKILL, mem_info, psi_t0, psi_kill_exceeded_timer, return (SIGKILL, mem_info, psi_t0, psi_kill_exceeded_timer,
psi_term_exceeded_timer, x0) psi_term_exceeded_timer, x0)
if psi_avg_value >= sigterm_psi_threshold: if psi_avg_value >= soft_threshold_max_psi:
sigterm_psi_exceeded = True sigterm_psi_exceeded = True
psi_term_exceeded_timer += delta0 psi_term_exceeded_timer += delta0
else: else:
sigterm_psi_exceeded = False sigterm_psi_exceeded = False
psi_term_exceeded_timer = 0 psi_term_exceeded_timer = 0
if psi_debug: if debug_psi:
log('sigterm_psi_exceeded: {}\n' log('sigterm_psi_exceeded: {}\n'
'psi_term_exceeded_timer: {}\n'.format( 'psi_term_exceeded_timer: {}\n'.format(
@ -1640,11 +1630,11 @@ def check_psi_ex(psi_t0, psi_kill_exceeded_timer, psi_term_exceeded_timer, x0):
if (psi_term_exceeded_timer >= psi_excess_duration and if (psi_term_exceeded_timer >= psi_excess_duration and
psi_post_action_delay_exceeded): psi_post_action_delay_exceeded):
mem_info = 'PSI avg ({}) > sigterm_psi_threshold ({})\n' \ mem_info = 'PSI avg ({}) > soft_threshold_max_psi ({})\n' \
'PSI avg exceeded psi_excess_duration (value' \ 'PSI avg exceeded psi_excess_duration (value' \
' = {} sec) for {} seconds'.format( ' = {} sec) for {} seconds'.format(
psi_avg_value, psi_avg_value,
sigterm_psi_threshold, soft_threshold_max_psi,
psi_excess_duration, psi_excess_duration,
round(psi_term_exceeded_timer, 1) round(psi_term_exceeded_timer, 1)
) )
@ -1652,9 +1642,9 @@ def check_psi_ex(psi_t0, psi_kill_exceeded_timer, psi_term_exceeded_timer, x0):
return (SIGTERM, mem_info, psi_t0, psi_kill_exceeded_timer, return (SIGTERM, mem_info, psi_t0, psi_kill_exceeded_timer,
psi_term_exceeded_timer, x0) psi_term_exceeded_timer, x0)
if gui_low_memory_warnings: if low_memory_warnings_enabled:
if psi_avg_value >= psi_avg_warnings: if psi_avg_value >= warning_threshold_max_psi:
return ('WARN', None, psi_t0, psi_kill_exceeded_timer, return ('WARN', None, psi_t0, psi_kill_exceeded_timer,
psi_term_exceeded_timer, x0) psi_term_exceeded_timer, x0)
@ -1796,8 +1786,8 @@ def implement_corrective_action(
log('Recheck memory levels...') log('Recheck memory levels...')
(masf_threshold, masf_info, mem_available, swap_min_sigkill_kb, (masf_threshold, masf_info, mem_available, hard_threshold_min_swap_kb,
swap_min_sigterm_kb, swap_free, swap_total) = check_mem_swap_ex() soft_threshold_min_swap_kb, swap_free, swap_total) = check_mem_swap_ex()
if CHECK_ZRAM: if CHECK_ZRAM:
zram_threshold, zram_info, mem_used_zram = check_zram_ex() zram_threshold, zram_info, mem_used_zram = check_zram_ex()
@ -1857,16 +1847,16 @@ def implement_corrective_action(
if threshold is SIGTERM: if threshold is SIGTERM:
if victim_id in v_dict: if victim_id in v_dict:
dt = time() - v_dict[victim_id]['time'] dt = time() - v_dict[victim_id]['time']
if dt > max_post_sigterm_victim_lifetime: if dt > max_soft_exit_time:
log('max_post_sigterm_victim_lifetime is exceeded: the ' log('max_soft_exit_time is exceeded: the '
'victim will get SIGKILL') 'victim will get SIGKILL')
threshold = SIGKILL threshold = SIGKILL
else: else:
log('max_post_sigterm_victim_lifetime is not exceeded (' log('max_soft_exit_time is not exceeded ('
'{} < {}) for the victim'.format(round( '{} < {}) for the victim'.format(round(
dt, 1), max_post_sigterm_victim_lifetime)) dt, 1), max_soft_exit_time))
if print_sleep_periods: if debug_sleep:
log('Sleep {} sec (over_sleep)'.format(over_sleep)) log('Sleep {} sec (over_sleep)'.format(over_sleep))
sleep(over_sleep) sleep(over_sleep)
@ -1876,7 +1866,7 @@ def implement_corrective_action(
# log('Try to implement a corrective action...') # log('Try to implement a corrective action...')
if print_victim_info: if print_victim_status:
# victim badness ищи снова, не полагайся на старое # victim badness ищи снова, не полагайся на старое
victim_info = find_victim_info(pid, victim_badness, name) victim_info = find_victim_info(pid, victim_badness, name)
log(victim_info) log(victim_info)
@ -2058,7 +2048,7 @@ def implement_corrective_action(
exe(cmd) exe(cmd)
if gui_notifications: if post_action_gui_notifications:
if soft_match: if soft_match:
send_notify_etc(pid, name, cmd) send_notify_etc(pid, name, cmd)
else: else:
@ -2081,7 +2071,7 @@ def implement_corrective_action(
if vwd is None: if vwd is None:
if print_sleep_periods: if debug_sleep:
log('Sleep {} sec (over_sleep)'.format(over_sleep)) log('Sleep {} sec (over_sleep)'.format(over_sleep))
sleep(over_sleep) sleep(over_sleep)
@ -2095,21 +2085,21 @@ def sleep_after_check_mem():
if stable_sleep: if stable_sleep:
if print_sleep_periods: if debug_sleep:
log('Sleep {} sec'.format(min_sleep)) log('Sleep {} sec'.format(min_sleep))
stdout.flush() stdout.flush()
sleep(min_sleep) sleep(min_sleep)
return None return None
if mem_min_sigkill_kb < mem_min_sigterm_kb: if hard_threshold_min_mem_kb < soft_threshold_min_mem_kb:
mem_point = mem_available - mem_min_sigterm_kb mem_point = mem_available - soft_threshold_min_mem_kb
else: else:
mem_point = mem_available - mem_min_sigkill_kb mem_point = mem_available - hard_threshold_min_mem_kb
if swap_min_sigkill_kb < swap_min_sigterm_kb: if hard_threshold_min_swap_kb < soft_threshold_min_swap_kb:
swap_point = swap_free - swap_min_sigterm_kb swap_point = swap_free - soft_threshold_min_swap_kb
else: else:
swap_point = swap_free - swap_min_sigkill_kb swap_point = swap_free - hard_threshold_min_swap_kb
if swap_point < 0: if swap_point < 0:
swap_point = 0 swap_point = 0
@ -2117,11 +2107,11 @@ def sleep_after_check_mem():
if mem_point < 0: if mem_point < 0:
mem_point = 0 mem_point = 0
t_mem = mem_point / rate_mem t_mem = mem_point / fill_rate_mem
t_swap = swap_point / rate_swap t_swap = swap_point / fill_rate_swap
if CHECK_ZRAM: if CHECK_ZRAM:
t_zram = (mem_total * 0.8 - mem_used_zram) / rate_zram t_zram = (mem_total * 0.8 - mem_used_zram) / fill_rate_zram
if t_zram < 0: if t_zram < 0:
t_zram = 0 t_zram = 0
t_mem_zram = t_mem + t_zram t_mem_zram = t_mem + t_zram
@ -2147,7 +2137,7 @@ def sleep_after_check_mem():
else: else:
pass pass
if print_sleep_periods: if debug_sleep:
log('Sleep {} sec (t_mem={}, t_swap={}{})'.format(round(t, 2), round( log('Sleep {} sec (t_mem={}, t_swap={}{})'.format(round(t, 2), round(
t_mem, 2), round(t_swap, 2), z)) t_mem, 2), round(t_swap, 2), z))
@ -2187,7 +2177,7 @@ def calculate_percent(arg_key):
'ge [0; 100]\nExit'.format(arg_key)) 'ge [0; 100]\nExit'.format(arg_key))
exit(1) exit(1)
# mem_min_sigterm_percent is clean and valid float percentage. Can # soft_threshold_min_mem_percent is clean and valid float percentage. Can
# translate into Kb # translate into Kb
mem_min_kb = mem_min_percent / 100 * mem_total mem_min_kb = mem_min_percent / 100 * mem_total
mem_min_mb = round(mem_min_kb / 1024) mem_min_mb = round(mem_min_kb / 1024)
@ -2621,19 +2611,30 @@ else:
# extracting parameters from the dictionary # extracting parameters from the dictionary
# check for all necessary parameters # check for all necessary parameters
# validation of all parameters # validation of all parameters
psi_debug = conf_parse_bool('psi_debug') debug_psi = conf_parse_bool('debug_psi')
print_total_stat = conf_parse_bool('print_total_stat') print_statistics = conf_parse_bool('print_statistics')
print_proc_table = conf_parse_bool('print_proc_table') print_proc_table = conf_parse_bool('print_proc_table')
forbid_negative_badness = conf_parse_bool('forbid_negative_badness') forbid_negative_badness = conf_parse_bool('forbid_negative_badness')
print_victim_info = conf_parse_bool('print_victim_info') print_victim_status = conf_parse_bool('print_victim_status')
print_victim_cmdline = conf_parse_bool('print_victim_cmdline') print_victim_cmdline = conf_parse_bool('print_victim_cmdline')
print_config = conf_parse_bool('print_config') print_config_at_startup = conf_parse_bool('print_config_at_startup')
print_mem_check_results = conf_parse_bool('print_mem_check_results') print_mem_check_results = conf_parse_bool('print_mem_check_results')
print_sleep_periods = conf_parse_bool('print_sleep_periods') debug_sleep = conf_parse_bool('debug_sleep')
gui_low_memory_warnings = conf_parse_bool('gui_low_memory_warnings') low_memory_warnings_enabled = conf_parse_bool('low_memory_warnings_enabled')
gui_notifications = conf_parse_bool('gui_notifications') post_action_gui_notifications = conf_parse_bool('post_action_gui_notifications')
ignore_psi = conf_parse_bool('ignore_psi')
ignore_zram = conf_parse_bool('ignore_zram')
psi_checking_enabled = conf_parse_bool('psi_checking_enabled')
ignore_psi = not psi_checking_enabled
zram_checking_enabled = conf_parse_bool('zram_checking_enabled')
ignore_zram = not zram_checking_enabled
debug_gui_notifications = conf_parse_bool('debug_gui_notifications') debug_gui_notifications = conf_parse_bool('debug_gui_notifications')
ignore_positive_oom_score_adj = conf_parse_bool('ignore_positive_oom_score_adj') ignore_positive_oom_score_adj = conf_parse_bool('ignore_positive_oom_score_adj')
@ -2641,23 +2642,23 @@ ignore_positive_oom_score_adj = conf_parse_bool('ignore_positive_oom_score_adj')
(mem_min_sigterm_kb, mem_min_sigterm_mb, mem_min_sigterm_percent (soft_threshold_min_mem_kb, soft_threshold_min_mem_mb, soft_threshold_min_mem_percent
) = calculate_percent('mem_min_sigterm') ) = calculate_percent('soft_threshold_min_mem')
(mem_min_sigkill_kb, mem_min_sigkill_mb, mem_min_sigkill_percent (hard_threshold_min_mem_kb, hard_threshold_min_mem_mb, hard_threshold_min_mem_percent
) = calculate_percent('mem_min_sigkill') ) = calculate_percent('hard_threshold_min_mem')
(zram_max_sigterm_kb, zram_max_sigterm_mb, zram_max_sigterm_percent (soft_threshold_max_zram_kb, soft_threshold_max_zram_mb, soft_threshold_max_zram_percent
) = calculate_percent('zram_max_sigterm') ) = calculate_percent('soft_threshold_max_zram')
(zram_max_sigkill_kb, zram_max_sigkill_mb, zram_max_sigkill_percent (hard_threshold_max_zram_kb, hard_threshold_max_zram_mb, hard_threshold_max_zram_percent
) = calculate_percent('zram_max_sigkill') ) = calculate_percent('hard_threshold_max_zram')
(mem_min_warnings_kb, mem_min_warnings_mb, mem_min_warnings_percent (warning_threshold_min_mem_kb, warning_threshold_min_mem_mb, warning_threshold_min_mem_percent
) = calculate_percent('mem_min_warnings') ) = calculate_percent('warning_threshold_min_mem')
(zram_max_warnings_kb, zram_max_warnings_mb, zram_max_warnings_percent (warning_threshold_max_zram_kb, warning_threshold_max_zram_mb, warning_threshold_max_zram_percent
) = calculate_percent('zram_max_warnings') ) = calculate_percent('warning_threshold_max_zram')
if 'post_zombie_delay' in config_dict: if 'post_zombie_delay' in config_dict:
@ -2688,70 +2689,70 @@ else:
exit(1) exit(1)
if 'rate_mem' in config_dict: if 'fill_rate_mem' in config_dict:
rate_mem = string_to_float_convert_test(config_dict['rate_mem']) fill_rate_mem = string_to_float_convert_test(config_dict['fill_rate_mem'])
if rate_mem is None: if fill_rate_mem is None:
errprint('Invalid rate_mem value, not float\nExit') errprint('Invalid fill_rate_mem value, not float\nExit')
exit(1) exit(1)
if rate_mem <= 0: if fill_rate_mem <= 0:
errprint('rate_mem MUST be > 0\nExit') errprint('fill_rate_mem MUST be > 0\nExit')
exit(1) exit(1)
else: else:
errprint('rate_mem not in config\nExit') errprint('fill_rate_mem not in config\nExit')
exit(1) exit(1)
if 'rate_swap' in config_dict: if 'fill_rate_swap' in config_dict:
rate_swap = string_to_float_convert_test(config_dict['rate_swap']) fill_rate_swap = string_to_float_convert_test(config_dict['fill_rate_swap'])
if rate_swap is None: if fill_rate_swap is None:
errprint('Invalid rate_swap value, not float\nExit') errprint('Invalid fill_rate_swap value, not float\nExit')
exit(1) exit(1)
if rate_swap <= 0: if fill_rate_swap <= 0:
errprint('rate_swap MUST be > 0\nExit') errprint('fill_rate_swap MUST be > 0\nExit')
exit(1) exit(1)
else: else:
errprint('rate_swap not in config\nExit') errprint('fill_rate_swap not in config\nExit')
exit(1) exit(1)
if 'rate_zram' in config_dict: if 'fill_rate_zram' in config_dict:
rate_zram = string_to_float_convert_test(config_dict['rate_zram']) fill_rate_zram = string_to_float_convert_test(config_dict['fill_rate_zram'])
if rate_zram is None: if fill_rate_zram is None:
errprint('Invalid rate_zram value, not float\nExit') errprint('Invalid fill_rate_zram value, not float\nExit')
exit(1) exit(1)
if rate_zram <= 0: if fill_rate_zram <= 0:
errprint('rate_zram MUST be > 0\nExit') errprint('fill_rate_zram MUST be > 0\nExit')
exit(1) exit(1)
else: else:
errprint('rate_zram not in config\nExit') errprint('fill_rate_zram not in config\nExit')
exit(1) exit(1)
if 'swap_min_sigterm' in config_dict: if 'soft_threshold_min_swap' in config_dict:
swap_min_sigterm = config_dict['swap_min_sigterm'] soft_threshold_min_swap = config_dict['soft_threshold_min_swap']
else: else:
errprint('swap_min_sigterm not in config\nExit') errprint('soft_threshold_min_swap not in config\nExit')
exit(1) exit(1)
if 'swap_min_sigkill' in config_dict: if 'hard_threshold_min_swap' in config_dict:
swap_min_sigkill = config_dict['swap_min_sigkill'] hard_threshold_min_swap = config_dict['hard_threshold_min_swap']
else: else:
errprint('swap_min_sigkill not in config\nExit') errprint('hard_threshold_min_swap not in config\nExit')
exit(1) exit(1)
if 'min_delay_after_sigterm' in config_dict: if 'post_soft_action_delay' in config_dict:
min_delay_after_sigterm = string_to_float_convert_test( post_soft_action_delay = string_to_float_convert_test(
config_dict['min_delay_after_sigterm']) config_dict['post_soft_action_delay'])
if min_delay_after_sigterm is None: if post_soft_action_delay is None:
errprint('Invalid min_delay_after_sigterm value, not float\nExit') errprint('Invalid post_soft_action_delay value, not float\nExit')
exit(1) exit(1)
if min_delay_after_sigterm < 0: if post_soft_action_delay < 0:
errprint('min_delay_after_sigterm must be positiv\nExit') errprint('post_soft_action_delay must be positiv\nExit')
exit(1) exit(1)
else: else:
errprint('min_delay_after_sigterm not in config\nExit') errprint('post_soft_action_delay not in config\nExit')
exit(1) exit(1)
@ -2769,45 +2770,45 @@ else:
exit(1) exit(1)
if 'sigkill_psi_threshold' in config_dict: if 'hard_threshold_max_psi' in config_dict:
sigkill_psi_threshold = string_to_float_convert_test( hard_threshold_max_psi = string_to_float_convert_test(
config_dict['sigkill_psi_threshold']) config_dict['hard_threshold_max_psi'])
if sigkill_psi_threshold is None: if hard_threshold_max_psi is None:
errprint('Invalid sigkill_psi_threshold value, not float\nExit') errprint('Invalid hard_threshold_max_psi value, not float\nExit')
exit(1) exit(1)
if sigkill_psi_threshold < 0 or sigkill_psi_threshold > 100: if hard_threshold_max_psi < 0 or hard_threshold_max_psi > 100:
errprint('sigkill_psi_threshold must be in the range [0; 100]\nExit') errprint('hard_threshold_max_psi must be in the range [0; 100]\nExit')
exit(1) exit(1)
else: else:
errprint('sigkill_psi_threshold not in config\nExit') errprint('hard_threshold_max_psi not in config\nExit')
exit(1) exit(1)
if 'sigterm_psi_threshold' in config_dict: if 'soft_threshold_max_psi' in config_dict:
sigterm_psi_threshold = string_to_float_convert_test( soft_threshold_max_psi = string_to_float_convert_test(
config_dict['sigterm_psi_threshold']) config_dict['soft_threshold_max_psi'])
if sigterm_psi_threshold is None: if soft_threshold_max_psi is None:
errprint('Invalid sigterm_psi_threshold value, not float\nExit') errprint('Invalid soft_threshold_max_psi value, not float\nExit')
exit(1) exit(1)
if sigterm_psi_threshold < 0 or sigterm_psi_threshold > 100: if soft_threshold_max_psi < 0 or soft_threshold_max_psi > 100:
errprint('sigterm_psi_threshold must be in the range [0; 100]\nExit') errprint('soft_threshold_max_psi must be in the range [0; 100]\nExit')
exit(1) exit(1)
else: else:
errprint('sigterm_psi_threshold not in config\nExit') errprint('soft_threshold_max_psi not in config\nExit')
exit(1) exit(1)
if 'psi_avg_warnings' in config_dict: if 'warning_threshold_max_psi' in config_dict:
psi_avg_warnings = string_to_float_convert_test( warning_threshold_max_psi = string_to_float_convert_test(
config_dict['psi_avg_warnings']) config_dict['warning_threshold_max_psi'])
if psi_avg_warnings is None: if warning_threshold_max_psi is None:
errprint('Invalid psi_avg_warnings value, not float\nExit') errprint('Invalid warning_threshold_max_psi value, not float\nExit')
exit(1) exit(1)
if psi_avg_warnings < 0 or psi_avg_warnings > 100: if warning_threshold_max_psi < 0 or warning_threshold_max_psi > 100:
errprint('psi_avg_warnings must be in the range [0; 100]\nExit') errprint('warning_threshold_max_psi must be in the range [0; 100]\nExit')
exit(1) exit(1)
else: else:
errprint('psi_avg_warnings not in config\nExit') errprint('warning_threshold_max_psi not in config\nExit')
exit(1) exit(1)
@ -2828,54 +2829,54 @@ else:
if 'min_time_between_warnings' in config_dict: if 'min_post_warning_delay' in config_dict:
min_time_between_warnings = string_to_float_convert_test( min_post_warning_delay = string_to_float_convert_test(
config_dict['min_time_between_warnings']) config_dict['min_post_warning_delay'])
if min_time_between_warnings is None: if min_post_warning_delay is None:
errprint('Invalid min_time_between_warnings value, not float\nExit') errprint('Invalid min_post_warning_delay value, not float\nExit')
exit(1) exit(1)
if min_time_between_warnings < 1 or min_time_between_warnings > 300: if min_post_warning_delay < 1 or min_post_warning_delay > 300:
errprint('min_time_between_warnings value out of range [1; 300]\nExit') errprint('min_post_warning_delay value out of range [1; 300]\nExit')
exit(1) exit(1)
else: else:
errprint('min_time_between_warnings not in config\nExit') errprint('min_post_warning_delay not in config\nExit')
exit(1) exit(1)
if 'swap_min_warnings' in config_dict: if 'warning_threshold_min_swap' in config_dict:
swap_min_warnings = config_dict['swap_min_warnings'] warning_threshold_min_swap = config_dict['warning_threshold_min_swap']
else: else:
errprint('swap_min_warnings not in config\nExit') errprint('warning_threshold_min_swap not in config\nExit')
exit(1) exit(1)
if 'max_ancestry_depth' in config_dict: if 'max_victim_ancestry_depth' in config_dict:
max_ancestry_depth = string_to_int_convert_test( max_victim_ancestry_depth = string_to_int_convert_test(
config_dict['max_ancestry_depth']) config_dict['max_victim_ancestry_depth'])
if min_badness is None: if min_badness is None:
errprint('Invalid max_ancestry_depth value, not integer\nExit') errprint('Invalid max_victim_ancestry_depth value, not integer\nExit')
exit(1) exit(1)
if max_ancestry_depth < 1: if max_victim_ancestry_depth < 1:
errprint('Invalud max_ancestry_depth value\nExit') errprint('Invalud max_victim_ancestry_depth value\nExit')
exit(1) exit(1)
else: else:
errprint('max_ancestry_depth is not in config\nExit') errprint('max_victim_ancestry_depth is not in config\nExit')
exit(1) exit(1)
if 'max_post_sigterm_victim_lifetime' in config_dict: if 'max_soft_exit_time' in config_dict:
max_post_sigterm_victim_lifetime = string_to_float_convert_test( max_soft_exit_time = string_to_float_convert_test(
config_dict['max_post_sigterm_victim_lifetime']) config_dict['max_soft_exit_time'])
if max_post_sigterm_victim_lifetime is None: if max_soft_exit_time is None:
errprint('Invalid max_post_sigterm_victim_lifetime val' errprint('Invalid max_soft_exit_time val'
'ue, not float\nExit') 'ue, not float\nExit')
exit(1) exit(1)
if max_post_sigterm_victim_lifetime < 0: if max_soft_exit_time < 0:
errprint('max_post_sigterm_victim_lifetime must be non-n' errprint('max_soft_exit_time must be non-n'
'egative number\nExit') 'egative number\nExit')
exit(1) exit(1)
else: else:
errprint('max_post_sigterm_victim_lifetime is not in config\nExit') errprint('max_soft_exit_time is not in config\nExit')
exit(1) exit(1)
@ -3073,34 +3074,34 @@ psi_support = os.path.exists(psi_path)
# Get KiB levels if it's possible. # Get KiB levels if it's possible.
swap_min_sigterm_tuple = get_swap_threshold_tuple(swap_min_sigterm) soft_threshold_min_swap_tuple = get_swap_threshold_tuple(soft_threshold_min_swap)
swap_min_sigkill_tuple = get_swap_threshold_tuple(swap_min_sigkill) hard_threshold_min_swap_tuple = get_swap_threshold_tuple(hard_threshold_min_swap)
swap_min_warnings_tuple = get_swap_threshold_tuple(swap_min_warnings) warning_threshold_min_swap_tuple = get_swap_threshold_tuple(warning_threshold_min_swap)
swap_kb_dict = dict() swap_kb_dict = dict()
swap_term_is_percent = swap_min_sigterm_tuple[1] swap_term_is_percent = soft_threshold_min_swap_tuple[1]
if swap_term_is_percent: if swap_term_is_percent:
swap_min_sigterm_percent = swap_min_sigterm_tuple[0] soft_threshold_min_swap_percent = soft_threshold_min_swap_tuple[0]
else: else:
swap_min_sigterm_kb = swap_min_sigterm_tuple[0] soft_threshold_min_swap_kb = soft_threshold_min_swap_tuple[0]
swap_kb_dict['swap_min_sigterm_kb'] = swap_min_sigterm_kb swap_kb_dict['soft_threshold_min_swap_kb'] = soft_threshold_min_swap_kb
swap_kill_is_percent = swap_min_sigkill_tuple[1] swap_kill_is_percent = hard_threshold_min_swap_tuple[1]
if swap_kill_is_percent: if swap_kill_is_percent:
swap_min_sigkill_percent = swap_min_sigkill_tuple[0] hard_threshold_min_swap_percent = hard_threshold_min_swap_tuple[0]
else: else:
swap_min_sigkill_kb = swap_min_sigkill_tuple[0] hard_threshold_min_swap_kb = hard_threshold_min_swap_tuple[0]
swap_kb_dict['swap_min_sigkill_kb'] = swap_min_sigkill_kb swap_kb_dict['hard_threshold_min_swap_kb'] = hard_threshold_min_swap_kb
swap_warn_is_percent = swap_min_warnings_tuple[1] swap_warn_is_percent = warning_threshold_min_swap_tuple[1]
if swap_warn_is_percent: if swap_warn_is_percent:
swap_min_warnings_percent = swap_min_warnings_tuple[0] warning_threshold_min_swap_percent = warning_threshold_min_swap_tuple[0]
else: else:
swap_min_warnings_kb = swap_min_warnings_tuple[0] warning_threshold_min_swap_kb = warning_threshold_min_swap_tuple[0]
swap_kb_dict['swap_min_warnings_kb'] = swap_min_warnings_kb swap_kb_dict['warning_threshold_min_swap_kb'] = warning_threshold_min_swap_kb
########################################################################## ##########################################################################
@ -3112,7 +3113,7 @@ else:
if print_config or check_config_flag: if print_config_at_startup or check_config_flag:
check_config() check_config()
@ -3130,15 +3131,15 @@ if print_config or check_config_flag:
# for calculating the column width when printing mem and zram # for calculating the column width when printing mem and zram
mem_len = len(str(round(mem_total / 1024.0))) mem_len = len(str(round(mem_total / 1024.0)))
if gui_notifications: if post_action_gui_notifications:
notify_sig_dict = {SIGKILL: 'Killing', notify_sig_dict = {SIGKILL: 'Killing',
SIGTERM: 'Terminating'} SIGTERM: 'Terminating'}
# convert rates from MiB/s to KiB/s # convert rates from MiB/s to KiB/s
rate_mem = rate_mem * 1024 fill_rate_mem = fill_rate_mem * 1024
rate_swap = rate_swap * 1024 fill_rate_swap = fill_rate_swap * 1024
rate_zram = rate_zram * 1024 fill_rate_zram = fill_rate_zram * 1024
warn_time_now = 0 warn_time_now = 0
@ -3213,8 +3214,8 @@ stdout.flush()
while True: while True:
(masf_threshold, masf_info, mem_available, swap_min_sigkill_kb, (masf_threshold, masf_info, mem_available, hard_threshold_min_swap_kb,
swap_min_sigterm_kb, swap_free, swap_total) = check_mem_swap_ex() soft_threshold_min_swap_kb, swap_free, swap_total) = check_mem_swap_ex()
if CHECK_ZRAM: if CHECK_ZRAM:
zram_threshold, zram_info, mem_used_zram = check_zram_ex() zram_threshold, zram_info, mem_used_zram = check_zram_ex()
@ -3350,7 +3351,7 @@ while True:
x0, psi_threshold, zram_threshold, zram_info, psi_info) x0, psi_threshold, zram_threshold, zram_info, psi_info)
continue continue
if gui_low_memory_warnings: if low_memory_warnings_enabled:
if (masf_threshold == 'WARN' or zram_threshold == 'WARN' or if (masf_threshold == 'WARN' or zram_threshold == 'WARN' or
psi_threshold == 'WARN'): psi_threshold == 'WARN'):
@ -3358,7 +3359,7 @@ while True:
warn_time_delta = time() - warn_time_now warn_time_delta = time() - warn_time_now
warn_time_now = time() warn_time_now = time()
warn_timer += warn_time_delta warn_timer += warn_time_delta
if warn_timer > min_time_between_warnings: if warn_timer > min_post_warning_delay:
send_notify_warn() send_notify_warn()

View File

@ -30,9 +30,9 @@
0. Common zram settings 0. Common zram settings
See https://www.kernel.org/doc/Documentation/blockdev/zram.txt See https://www.kernel.org/doc/Documentation/blockdev/zram.txt
You maybe need to set `ignore_zram = False` if you has a big zram disksize. You maybe need to set `zram_checking_enabled = True` if you has a big zram disksize.
ignore_zram = True zram_checking_enabled = False
############################################################################### ###############################################################################
@ -46,13 +46,13 @@ ignore_zram = True
MemAvailable levels. MemAvailable levels.
mem_min_sigterm = 10 % soft_threshold_min_mem = 10 %
mem_min_sigkill = 5 % hard_threshold_min_mem = 5 %
SwapFree levels. SwapFree levels.
swap_min_sigterm = 15 % soft_threshold_min_swap = 15 %
swap_min_sigkill = 5 % hard_threshold_min_swap = 5 %
Specifying the total share of zram in memory, if exceeded the Specifying the total share of zram in memory, if exceeded the
corresponding signals are sent. As the share of zram in memory corresponding signals are sent. As the share of zram in memory
@ -62,8 +62,9 @@ swap_min_sigkill = 5 %
Can be specified in % and M. Valid values are floating-point Can be specified in % and M. Valid values are floating-point
numbers from the range [0; 90] %. numbers from the range [0; 90] %.
zram_max_sigterm = 50 % soft_threshold_max_zram = 50 %
zram_max_sigkill = 60 % hard_threshold_max_zram = 60 %
############################################################################### ###############################################################################
@ -72,9 +73,9 @@ zram_max_sigkill = 60 %
About PSI: About PSI:
https://facebookmicrosites.github.io/psi/ https://facebookmicrosites.github.io/psi/
Disabled by default (ignore_psi = True). Disabled by default (psi_checking_enabled = False).
ignore_psi = True psi_checking_enabled = False
Choose a path to PSI file. Choose a path to PSI file.
By default it monitors system-wide file: /proc/pressure/memory By default it monitors system-wide file: /proc/pressure/memory
@ -103,8 +104,9 @@ psi_path = /proc/pressure/memory
psi_metrics = some_avg10 psi_metrics = some_avg10
sigterm_psi_threshold = 60 soft_threshold_max_psi = 60
sigkill_psi_threshold = 90
hard_threshold_max_psi = 90
>= 0, float >= 0, float
psi_excess_duration = 60 psi_excess_duration = 60
@ -132,9 +134,9 @@ psi_post_action_delay = 60
Valid values are positive floating-point numbers. Valid values are positive floating-point numbers.
rate_mem = 4000 fill_rate_mem = 4000
rate_swap = 1500 fill_rate_swap = 1500
rate_zram = 6000 fill_rate_zram = 6000
See also https://github.com/rfjakob/earlyoom/issues/61 See also https://github.com/rfjakob/earlyoom/issues/61
@ -156,7 +158,7 @@ min_badness = 20
Valid values are non-negative floating-point numbers. Valid values are non-negative floating-point numbers.
Min delay if a victim doesn't respond to SIGTERM in 10 ms. Min delay if a victim doesn't respond to SIGTERM in 10 ms.
min_delay_after_sigterm = 3 post_soft_action_delay = 3
post_zombie_delay = 0.1 post_zombie_delay = 0.1
@ -259,16 +261,14 @@ ignore_positive_oom_score_adj = False
############################################################################### ###############################################################################
7. GUI notifications: 7. GUI notifications & low memory warnings
- OOM prevention results and
- low memory warnings
gui_notifications = False post_action_gui_notifications = False
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.
gui_low_memory_warnings = False low_memory_warnings_enabled = False
Execute the command instead of sending GUI notifications if the value is Execute the command instead of sending GUI notifications if the value is
not empty line. For example: not empty line. For example:
@ -279,17 +279,17 @@ warning_exe =
Can be specified in % (percent) and M (MiB). Can be specified in % (percent) and M (MiB).
Valid values are floating-point numbers from the range [0; 100] %. Valid values are floating-point numbers from the range [0; 100] %.
mem_min_warnings = 25 % warning_threshold_min_mem = 25 %
swap_min_warnings = 35 % warning_threshold_min_swap = 35 %
zram_max_warnings = 40 % warning_threshold_max_zram = 40 %
psi_avg_warnings = 100 warning_threshold_max_psi = 100
Valid values are floating-point numbers from the range [1; 300]. Valid values are floating-point numbers from the range [1; 300].
min_time_between_warnings = 20 min_post_warning_delay = 20
Ampersands (&) will be replaced with asterisks (*) in process Ampersands (&) will be replaced with asterisks (*) in process
names and in commands. names and in commands.
@ -301,7 +301,7 @@ min_time_between_warnings = 20
Display the configuration when the program starts. Display the configuration when the program starts.
Valid values are True and False. Valid values are True and False.
print_config = False print_config_at_startup = False
Print memory check results. Print memory check results.
Valid values are True and False. Valid values are True and False.
@ -310,13 +310,6 @@ print_mem_check_results = False
min_mem_report_interval = 60 min_mem_report_interval = 60
Print sleep periods between memory checks.
Valid values are True and False.
print_sleep_periods = False
print_total_stat = True
print_proc_table = False print_proc_table = False
Valid values: Valid values:
@ -329,23 +322,30 @@ print_proc_table = False
extra_table_info = None extra_table_info = None
print_victim_info = True print_victim_status = True
max_victim_ancestry_depth = 3
print_victim_cmdline = False print_victim_cmdline = False
max_ancestry_depth = 3 print_statistics = True
Print sleep periods between memory checks.
Valid values are True and False.
debug_psi = False
debug_gui_notifications = False debug_gui_notifications = False
separate_log = False debug_sleep = False
psi_debug = False separate_log = False
############################################################################### ###############################################################################
9. Misc 9. Misc
max_post_sigterm_victim_lifetime = 10 max_soft_exit_time = 10
post_kill_exe = post_kill_exe =