diff --git a/README.md b/README.md index 839ceeb..77477da 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ See also `man journalctl`. - Awful documentation - Slowly starting, slowly looking for a victim, especially when using swapspace +- It is written in an interpreted language and is actually a prototype ## Contribution diff --git a/nohang b/nohang index 11d7441..501b4f3 100755 --- a/nohang +++ b/nohang @@ -2,13 +2,16 @@ """A daemon that prevents OOM in Linux systems.""" from time import sleep, time start_time = time() + import os from operator import itemgetter + +# this is most slow import from argparse import ArgumentParser + from sys import stdout from signal import SIGKILL, SIGTERM - sig_dict = {SIGKILL: 'SIGKILL', SIGTERM: 'SIGTERM'} ''' @@ -16,8 +19,6 @@ nm = 30 nc = nm + 1 ''' -stat_dict = dict() - ########################################################################## @@ -770,22 +771,24 @@ print('The path to the config:', config) # conf_parameters_dict # conf_restart_dict +# dictionary with config options +config_dict = dict() + +processname_re_list = [] +cmdline_re_list = [] +uid_re_list = [] + +# dictionary with names and commands for the parameter +# execute_the_command +# тут тоже список нужен, а не словарь +etc_dict = dict() + +# will store corrective actions stat +stat_dict = dict() + try: with open(config) as f: - # dictionary with config options - config_dict = dict() - - processname_re_list = [] - cmdline_re_list = [] - uid_re_list = [] - - - # dictionary with names and commands for the parameter - # execute_the_command - # тут тоже список нужен, а не словарь - etc_dict = dict() - for line in f: a = line.startswith('#') @@ -823,7 +826,6 @@ try: a = line.partition('@UID_RE')[2].strip(' \n').partition('///') uid_re_list.append((a[0].strip(' '), a[2].strip(' '))) - except PermissionError: print('PermissionError', conf_err_mess) exit() @@ -1400,7 +1402,7 @@ while True: else: # СТОИТ ПЕЧАТАТЬ СВОП ТОЛЬКО ПРИ SwapTotal > 0 - # нет, печатать так: SwapTotal = 0 KiB, ignore swapspace + # нет, печатать так: SwapTotal = 0, ignore swapspace swap_sigterm_pc = '-' # Limits overdrafting checks