diff --git a/Makefile b/Makefile index 42fd530..ea76e69 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ install: install -d $(DESTDIR)/$(PREFIX)/usr/bin install -m0755 ./oom-sort $(DESTDIR)/$(PREFIX)/usr/bin/oom-sort - install -m0755 ./oom-trigger $(DESTDIR)/$(PREFIX)/usr/bin/oom-trigger install -d $(DESTDIR)/$(PREFIX)/etc/nohang install -m0644 ./nohang.conf $(DESTDIR)/$(PREFIX)/etc/nohang/$(VERSION) @@ -22,7 +21,6 @@ install: install -d $(DESTDIR)/$(PREFIX)/usr/share/man/man1 gzip -k -c nohang.1 > $(DESTDIR)/$(PREFIX)/usr/share/man/man1/nohang.1.gz gzip -k -c oom-sort.1 > $(DESTDIR)/$(PREFIX)/usr/share/man/man1/oom-sort.1.gz - gzip -k -c oom-trigger.1 > $(DESTDIR)/$(PREFIX)/usr/share/man/man1/oom-trigger.1.gz install -d $(DESTDIR)/$(PREFIX)/lib/systemd/system install -m0644 ./nohang.service $(DESTDIR)/$(PREFIX)/lib/systemd/system/nohang.service @@ -33,10 +31,8 @@ uninstall: rm -fv $(PREFIX)/usr/sbin/nohang rm -fv $(PREFIX)/usr/sbin/nohang_notify_helper rm -fv $(PREFIX)/usr/bin/oom-sort - rm -fv $(PREFIX)/usr/bin/oom-trigger rm -fv $(PREFIX)/usr/share/man/man1/nohang.1.gz rm -fv $(PREFIX)/usr/share/man/man1/oom-sort.1.gz - rm -fv $(PREFIX)/usr/share/man/man1/oom-trigger.1.gz rm -fv $(PREFIX)/lib/systemd/system/nohang.service rm -fvr $(PREFIX)/etc/nohang/ rm -fvr $(PREFIX)/etc/logrotate.d/nohang diff --git a/README.md b/README.md index 95f1ee5..83c1357 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ Please create [issues](https://github.com/hakavlad/nohang/issues). Use cases, fe - [x] Improved GUI warnings: - [x] Reduced the idle time of the daemon in the process of launching a notification - [x] All notify-send calls are made using the `nohang_notify_helper` script, in which all timeouts are handled - - [x] Native python implementation of `env` search without running `ps` to notify users if nohang started with UID=0. + - [x] Native python implementation of `env` search without running `ps` to notify all users if nohang started with UID=0. - [x] Messages are sent to the helper via a temporary file in `/dev/shm` - [ ] Deduplication of frequently repeated identical notifications (for example, if the victim does not respond to SIGTERM) - [x] Improved modifing badness via matching with regular expressions: diff --git a/nohang_new.conf b/misc/nohang_new.conf similarity index 100% rename from nohang_new.conf rename to misc/nohang_new.conf diff --git a/oom-trigger b/misc/oom-trigger similarity index 100% rename from oom-trigger rename to misc/oom-trigger diff --git a/psi-monitor b/misc/psi-monitor similarity index 100% rename from psi-monitor rename to misc/psi-monitor diff --git a/psi_dummy b/misc/psi_dummy similarity index 100% rename from psi_dummy rename to misc/psi_dummy diff --git a/nohang b/nohang index 39d611a..c3fbe95 100755 --- a/nohang +++ b/nohang @@ -74,6 +74,8 @@ def log(*msg): """ print(*msg) if separate_log: + # need fix: TypeError: not all arguments converted during string + # formatting info(*msg) @@ -674,7 +676,6 @@ def send_notify_etc(pid, name, command): command.replace('&', '*') ) - # write() -> wrinte_notify(title, body) write('{}\x00{}'.format(title, body)) @@ -1062,8 +1063,6 @@ def implement_corrective_action(signal): notif = True - - log(mem_info) pid, victim_badness, name = find_victim(print_proc_table) @@ -1156,17 +1155,20 @@ def implement_corrective_action(signal): sig_dict[signal], name) if signal is SIGKILL and post_kill_exe != '': - os.system( - post_kill_exe.replace( - '$PID', pid).replace( - '$NAME', pid_to_name(pid) - ) - ) + + cmd = post_kill_exe.replace('$PID', pid).replace( + '$NAME', pid_to_name(pid)) + + print('exe:', cmd) + err = os.system(cmd) + + print('post_kill_exe exit status:', err) if gui_notifications: # min delay after same notification - # все не так. От этого вообще пол дедупликация . терминация один раз покажется при любом раскладе. + # все не так. От этого вообще пол дедупликация . терминация + # один раз покажется при любом раскладе. delay_after_same_notify = 1 x = dick['v'] @@ -1186,18 +1188,9 @@ def implement_corrective_action(signal): if dt < delay_after_same_notify: notif = False - if notif: send_notify(signal, name, pid) - - - - - - - - except FileNotFoundError: response_time = time() - time0 send_result = 'no such process; response time: {} ms'.format( @@ -2335,7 +2328,8 @@ while True: if warn_timer > min_time_between_warnings: t0 = time() send_notify_warn() - log(time() - t0, 'send notify warning time') + # caused log err + log(str(time() - t0) + ' | send notify warning time') warn_timer = 0 # SLEEP BETWEEN MEM CHECKS diff --git a/nohang.service b/nohang.service index d3cda34..d33ead9 100644 --- a/nohang.service +++ b/nohang.service @@ -7,9 +7,9 @@ Documentation=man:nohang(1) https://github.com/hakavlad/nohang ExecStart=/usr/sbin/nohang --config /etc/nohang/nohang.conf Slice=nohang.slice Restart=always -MemoryMax=100M -TasksMax=100 -OOMScoreAdjust=-10 +MemoryMax=20M +TasksMax=10 +OOMScoreAdjust=-5 Nice=-20 IOSchedulingClass=1 IOSchedulingPriority=0 diff --git a/oom-trigger.1 b/oom-trigger.1 deleted file mode 100644 index 9028b4c..0000000 --- a/oom-trigger.1 +++ /dev/null @@ -1,3 +0,0 @@ -.TH oom-trigger 1 -.SH NAME -oom-trigger \- interactive OOM trigger