This commit is contained in:
Alexey Avramov 2019-03-21 19:17:53 +09:00
parent d97338a8eb
commit 6ca23b4bfe
9 changed files with 18 additions and 31 deletions

View File

@ -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

View File

@ -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:

34
nohang
View File

@ -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

View File

@ -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

View File

@ -1,3 +0,0 @@
.TH oom-trigger 1
.SH NAME
oom-trigger \- interactive OOM trigger