From 29a1e48f5daed977cf801002873170c8aea07f75 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Mon, 18 Jun 2018 17:13:41 +0900 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B2=D0=B8=D0=B4=D0=B0=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nohang | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/nohang b/nohang index b50d8e2..9aba64a 100755 --- a/nohang +++ b/nohang @@ -16,6 +16,10 @@ from argparse import ArgumentParser # задание констант +#notify_options = '-t "60000"' +#notify_options = '-u "critical"' +notify_options = '' + version = 'unknown' sig_dict = {9: 'SIGKILL', 15: 'SIGTERM'} @@ -194,8 +198,7 @@ def find_victim_and_send_signal(signal): if desktop_notifications: - info = '"The {} signal has been sent to {}, Pid: {}, oom_score: {}, VmRSS {} MiB, VmSwap {} MiB" &'.format( - sig_dict[signal], name, pid, oom_score, vm_rss, vm_swap) + info = '"Nohang sent {} to the process \nName: {} \nPid: {} \noom_score: {} \nVmRSS: {} MiB \nVmSwap: {} MiB" &'.format(sig_dict[signal], name, pid, oom_score, vm_rss, vm_swap) if root: # получаем множество залогиненных юзеров из вывода команды @@ -206,12 +209,11 @@ def find_victim_and_send_signal(signal): )[2:-1].split(' ')) # отправляем уведомление всем залогиненным юзерам for i in users_set: - root_notify_command = 'DISPLAY=:0 sudo -u {} notify-send "Nohang tried to prevent OOM" '.format( - i) + root_notify_command = 'DISPLAY=:0 sudo -u {} notify-send {} "Preventing OOM" '.format( + i, notify_options) os.system(root_notify_command + info) else: - user_notify_command = ( - 'notify-send "Nohang tried to prevent OOM" ') + user_notify_command = 'notify-send {} "Preventing OOM" '.format(notify_options) os.system(user_notify_command + info) except ProcessLookupError: