add psi_pat to config; fix poll rates

This commit is contained in:
Alexey Avramov 2019-03-16 01:24:38 +09:00
parent 34b35bf7ef
commit babbe6acfe
2 changed files with 30 additions and 10 deletions

26
nohang
View File

@ -42,8 +42,6 @@ wait_time = 10
notify_helper_path = '/usr/sbin/nohang_notify_helper'
psi_path = '/proc/pressure/memory'
psi_support = os.path.exists(psi_path)
HR = ''
@ -63,6 +61,7 @@ stat_dict = dict()
def print_version():
# сначала пытаться получ версию прямо из гита - вариант для неустановленых
try:
v = rline1('/etc/nohang/version')
except FileNotFoundError:
@ -146,7 +145,7 @@ def pid_to_starttime(pid):
2].split(' ')[20]
except UnicodeDecodeError:
print('LOL')
# print('LOL')
with open('/proc/' + pid + '/stat', 'rb') as f:
starttime = f.read().decode('utf-8', 'ignore').rpartition(
')')[2].split(' ')[20]
@ -1655,6 +1654,19 @@ else:
exit(1)
if 'psi_path' in config_dict:
psi_path = config_dict['psi_path']
else:
errprint('psi_path is not in config\nExit')
exit(1)
print_total_stat = conf_parse_bool('print_total_stat')
print_proc_table = conf_parse_bool('print_proc_table')
@ -1861,9 +1873,9 @@ if gui_notifications or gui_low_memory_warnings:
SIGTERM: 'Terminating'}
rate_mem = rate_mem * 1048576
rate_swap = rate_swap * 1048576
rate_zram = rate_zram * 1048576
rate_mem = rate_mem * 1024
rate_swap = rate_swap * 1024
rate_zram = rate_zram * 1024
# print(rate_mem, rate_swap, rate_zram)
@ -1983,7 +1995,7 @@ while True:
if mem_report:
speed = delta / 1024.0 / report_delta
speed_info = ' | ΔMem: {} M/s'.format(
speed_info = ' | dMem: {} M/s'.format(
str(round(speed)).rjust(5)
)

View File

@ -67,6 +67,14 @@ zram_max_sigkill = 55 %
ignore_psi = True
Choose path to PSI file.
psi_path = /sys/fs/cgroup/unified/user.slice/memory.pressure
psi_path = /sys/fs/cgroup/unified/system.slice/memory.pressure
psi_path = /sys/fs/cgroup/unified/system.slice/foo.service/memory.pressure
psi_path = /proc/pressure/memory
sigterm_psi_avg10 = 60
sigkill_psi_avg10 = 90
@ -93,9 +101,9 @@ psi_avg10_sleep_time = 60
Valid values are positive floating-point numbers.
rate_mem = 3
rate_swap = 1.5
rate_zram = 0.5
rate_mem = 4000
rate_swap = 1500
rate_zram = 500
See also https://github.com/rfjakob/earlyoom/issues/61