diff --git a/README.md b/README.md index ceceaa8..f76e1da 100644 --- a/README.md +++ b/README.md @@ -59,26 +59,18 @@ To use `PSI` (pressure stall information): ## Memory and CPU usage -- VmRSS is 10 — 11 MiB depending on the settings +- VmRSS is about 10 MiB - 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 the user via the config) ## Download, install, uninstall -**Please use the latest [release version](https://github.com/hakavlad/nohang/releases).** -Current version may be more unstable. +Please use the latest [release version](https://github.com/hakavlad/nohang/releases). Current version may unstable. ```bash $ git clone https://github.com/hakavlad/nohang.git $ cd nohang ``` -Run without installing (low memory warnings may not work; note that processes with UID != your UID will not receive signals if nohang is started as a regular user): - -``` -$ ./nohang -``` - - To install: ```bash $ sudo make install @@ -97,19 +89,6 @@ $ sudo make uninstall For Arch Linux, there's an [AUR package](https://aur.archlinux.org/packages/nohang-git/). Use your favorite [AUR helper](https://wiki.archlinux.org/index.php/AUR_helpers). -## Command line options - -``` -./nohang -h -usage: nohang [-h] [-c CONFIG] - -optional arguments: - -h, --help show this help message and exit - -c CONFIG, --config CONFIG - path to the config file, default values: - ./nohang.conf, /etc/nohang/nohang.conf -``` - ## How to configure nohang The program can be configured by editing the [config file](https://github.com/hakavlad/nohang/blob/master/nohang.conf). The configuration includes the following sections: @@ -205,6 +184,7 @@ Please create [issues](https://github.com/hakavlad/nohang/issues). Use cases, fe - Add `oom-trigger` - Adoption of the [code of conduct](https://github.com/hakavlad/nohang/blob/master/CODE_OF_CONDUCT.md) - Redesign of the config + - Remove CLI options - Remove self-defense options from config, use systemd unit scheduling instead - Add the ability to send any signal instead of SIGTERM for processes with certain names diff --git a/nohang b/nohang index 4c0e90c..fd2ce12 100755 --- a/nohang +++ b/nohang @@ -2,13 +2,18 @@ """A daemon that prevents OOM in Linux systems.""" from time import sleep, time -start_time = 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, SIGSTOP, SIGCONT @@ -26,8 +31,8 @@ else: wait_time = 14 -max_sleep_time = 1 -min_sleep_time = 0.02 +max_sleep_time = 2 +min_sleep_time = 0.1 notify_helper_path = '/usr/bin/nohang_notify_helper' @@ -37,7 +42,7 @@ psi_support = os.path.exists(psi_path) debug = False -stop_cont = True +stop_cont = False print_states_debug = False @@ -1035,7 +1040,7 @@ except ValueError: ########################################################################## - +''' # Configurations @@ -1088,9 +1093,11 @@ else: print("File {} doesn't exists{}".format( arg_config, conf_err_mess)) exit() +''' +config = '/etc/nohang/nohang.conf' -print('The path to the config:', config) +print('Config:', config) ########################################################################## diff --git a/nohang.1 b/nohang.1 index 0a83360..c3546ef 100644 --- a/nohang.1 +++ b/nohang.1 @@ -7,16 +7,16 @@ nohang \- no hang daemon .RB [ OPTION ]... .SH DESCRIPTION -Nohang is a highly configurable daemon for Linux which is able to correctly prevent out of memory (OOM) and keep system responsiveness in low memory conditions. See https://github.com/hakavlad/nohang +Nohang is a highly configurable daemon for Linux which is able to correctly prevent out of memory (OOM) and keep system responsiveness in low memory conditions. + + + +.SH HOW TO CONFIGURE + +Just edit config /etc/nohang/nohang.conf and restart the daemon. + +.SH SEE ALSO + +https://github.com/hakavlad/nohang + -.SH OPTIONS -.TP -.BI \-c " CONFIG", -.BI \-\-config " CONFIG" -path to the config file, default values: -.I ./nohang.conf, -.I /etc/nohang/nohang.conf -.TP -.BI \-h, -.BI \-\-help -show help message and exit