From 058f6be1237b120af1f6f5ba05eb5c0ffc035769 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Tue, 19 Jun 2018 21:22:17 +0900 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D1=83?= =?UTF-8?q?=D0=B2=D0=B5=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 | 8 ++++++-- nohang.conf | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/nohang b/nohang index 5a6d1f5..ce6400e 100755 --- a/nohang +++ b/nohang @@ -155,9 +155,12 @@ def send_notify(signal, name, pid, oom_score, vm_rss, vm_swap): sig_dict[signal], name, pid, oom_score, vm_rss, vm_swap) if root: + + # отправляем уведомление всем залогиненным пользователям for uid in os.listdir('/run/user'): - root_notify_command = 'DISPLAY=:0 sudo -u {} notify-send {} "Pr' \ - 'eventing OOM" '.format(users_dict[uid], notify_options) + + root_notify_command = 'DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/{}/bus XAUTHORITY=/home/{}/.Xauthority sudo -u {} notify-send {} "Preventing OOM" '.format(uid, users_dict[uid], users_dict[uid], notify_options) + os.system(root_notify_command + info) else: @@ -165,6 +168,7 @@ def send_notify(signal, name, pid, oom_score, vm_rss, vm_swap): # отправляем уведомление пользователю, который запустил nohang user_notify_command = 'notify-send {} "Preventing OOM" '.format( notify_options) + os.system(user_notify_command + info) diff --git a/nohang.conf b/nohang.conf index 88ae065..71d4c67 100644 --- a/nohang.conf +++ b/nohang.conf @@ -12,19 +12,19 @@ Печатать параметров конфига при запуске программы. Допустимые значения: True и False -print_config = False +print_config = True Печатать ли результаты измерения доступной памяти. Допустимые значения: True и False -print_mem_check_results = False +print_mem_check_results = True Печатать ли время сна между проверками памяти и после отправки сигналов. Можно установить в значение True для дебага. Допустимые значения: True и False (В этой ветке по дефолту True) -print_sleep_periods = False +print_sleep_periods = True ##################################################################### @@ -136,11 +136,11 @@ min_delay_after_sigkill = 3 Требует root прав. -decrease_oom_score_adj = False +decrease_oom_score_adj = True Допустимые значения - целые числа из диапазона [0; 1000] -oom_score_adj_max = 50 +oom_score_adj_max = 20 ##################################################################### @@ -163,5 +163,5 @@ desktop_notifications = True notify_options = -u "critical" notify_options = -t "20000" -i "dialog-warning" -notify_options = -u "normal" +notify_options =