improve output

This commit is contained in:
Alexey Avramov 2020-04-05 04:06:55 +09:00
parent 8ae58248d0
commit 5e67ec9ec3

View File

@ -1904,7 +1904,7 @@ def check_mem_swap_ex():
kib_to_mib(mem_available), kib_to_mib(mem_available),
percent(mem_available / mem_total), percent(mem_available / mem_total),
kib_to_mib(hard_threshold_min_mem_kb), kib_to_mib(hard_threshold_min_mem_kb),
percent(hard_threshold_min_mem_kb / mem_total), round(hard_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(hard_threshold_min_swap_kb), kib_to_mib(hard_threshold_min_swap_kb),
@ -1967,10 +1967,14 @@ def check_zram_ex():
if (mem_used_zram >= hard_threshold_max_zram_kb and if (mem_used_zram >= hard_threshold_max_zram_kb and
ma_hard_threshold_exceded): ma_hard_threshold_exceded):
mem_info = 'Memory status that requires corrective actions:\n Mem' \ mem_info = 'Memory status that requires corrective actions:\n MemAv' \
'UsedZram [{} MiB, {} %] >= hard_threshold_max_zram [{} MiB' \ 'ailable [{} MiB, {} %] <= hard_threshold_min_mem [{} MiB' \
', {} %]'.format( ', {} %]\n MemUsedZram [{} MiB, {} %] >= hard_threshold_' \
'max_zram [{} MiB, {} %]'.format(
kib_to_mib(mem_available),
percent(mem_available / mem_total),
kib_to_mib(hard_threshold_min_mem_kb),
round(hard_threshold_min_mem_percent, 1),
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(hard_threshold_max_zram_kb), kib_to_mib(hard_threshold_max_zram_kb),
@ -1981,9 +1985,14 @@ def check_zram_ex():
if (mem_used_zram >= soft_threshold_max_zram_kb and if (mem_used_zram >= soft_threshold_max_zram_kb and
ma_soft_threshold_exceded): ma_soft_threshold_exceded):
mem_info = 'Memory status that requires corrective actions:\n ' \ mem_info = 'Memory status that requires corrective actions:\n MemA' \
'MemUsedZram [{} MiB, {} %] >= soft_threshold_max_zram [{}' \ 'vailable [{} MiB, {} %] <= soft_threshold_min_mem [{} M' \
' M, {} %]'.format( 'iB, {} %]\n MemUsedZram [{} MiB, {} %] >= soft_thresho' \
'ld_max_zram [{} M, {} %]'.format(
kib_to_mib(mem_available),
percent(mem_available / mem_total),
kib_to_mib(soft_threshold_min_mem_kb),
round(soft_threshold_min_mem_percent, 1),
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(soft_threshold_max_zram_kb), kib_to_mib(soft_threshold_max_zram_kb),
@ -2060,9 +2069,15 @@ def check_psi_ex(psi_t0, psi_kill_exceeded_timer, psi_term_exceeded_timer, x0,
psi_excess_duration and psi_post_action_delay_exceeded and psi_excess_duration and psi_post_action_delay_exceeded and
ma_hard_threshold_exceded): ma_hard_threshold_exceded):
mem_info = 'PSI avg ({}) >= hard_threshold_max_psi ({})\n' \ mem_info = 'Memory status that requires corrective actions:\n MemAv' \
'PSI avg exceeded psi_excess_duration (value' \ 'ailable [{} MiB, {} %] <= hard_threshold_min_mem [{} MiB' \
' = {} sec) for {} seconds'.format( ', {} %]\n PSI avg ({}) >= hard_threshold_max_psi ({})\n' \
' PSI avg exceeded psi_excess_duration (value = {} sec) ' \
'for {} seconds'.format(
kib_to_mib(mem_available),
percent(mem_available / mem_total),
kib_to_mib(hard_threshold_min_mem_kb),
round(hard_threshold_min_mem_percent, 1),
psi_avg_value, psi_avg_value,
hard_threshold_max_psi, hard_threshold_max_psi,
psi_excess_duration, psi_excess_duration,
@ -2092,9 +2107,15 @@ def check_psi_ex(psi_t0, psi_kill_exceeded_timer, psi_term_exceeded_timer, x0,
psi_excess_duration and psi_post_action_delay_exceeded and psi_excess_duration and psi_post_action_delay_exceeded and
ma_soft_threshold_exceded): ma_soft_threshold_exceded):
mem_info = 'PSI avg ({}) >= soft_threshold_max_psi ({})\n' \ mem_info = 'Memory status that requires corrective actions:\n MemA' \
'PSI avg exceeded psi_excess_duration (value' \ 'vailable [{} MiB, {} %] <= soft_threshold_min_mem [{} M' \
' = {} sec) for {} seconds'.format( 'iB, {} %]\n PSI avg ({}) >= soft_threshold_max_psi ({})' \
'\n PSI avg exceeded psi_excess_duration (value = {} se' \
'c) for {} seconds'.format(
kib_to_mib(mem_available),
percent(mem_available / mem_total),
kib_to_mib(soft_threshold_min_mem_kb),
round(soft_threshold_min_mem_percent, 1),
psi_avg_value, psi_avg_value,
soft_threshold_max_psi, soft_threshold_max_psi,
psi_excess_duration, psi_excess_duration,
@ -2300,8 +2321,9 @@ def implement_corrective_action(
if victim_id in v_dict: if victim_id in v_dict:
dt = monotonic() - v_dict[victim_id]['time'] dt = monotonic() - v_dict[victim_id]['time']
if dt > max_soft_exit_time: if dt > max_soft_exit_time:
log('max_soft_exit_time is exceeded: the ' log('max_soft_exit_time (value={}s) is exceeded the victim:'
'victim will get SIGKILL') ' it will get SIGKILL'.format(
max_soft_exit_time))
threshold = SIGKILL threshold = SIGKILL
else: else:
log('max_soft_exit_time is not exceeded (' log('max_soft_exit_time is not exceeded ('