fix GUI notifications

This commit is contained in:
Alexey Avramov 2018-08-05 11:12:51 +09:00
parent c9db115908
commit 345123f307

24
nohang
View File

@ -205,19 +205,16 @@ def pid_to_name(pid):
def send_notify_warn(): def send_notify_warn():
title = 'LOW MEMORY' title = 'LOW MEMORY'
if mem_used_zram > 0: if mem_used_zram > 0:
body = '<i>Mem Available:</i> <b>{} MiB</b>\n<i>Swap Fre' \ body = '<b>Mem Available: {} %\nSwap Free: {} %\nMem Used Zram: {} %</b>'.format(
'e:</i> <b>{} MiB</b>\n<i>MemUsedZram:</i> <b>{} MiB</b>'.format( round(mem_available / mem_total * 100),
kib_to_mib(mem_available), round(swap_free / (swap_total + 0.1) * 100),
kib_to_mib(swap_free), round(mem_used_zram / mem_total * 100))
kib_to_mib(mem_used_zram))
elif swap_free > 0: elif swap_free > 0:
body = '<i>Mem Available:</i> <b>{} MiB</b>\n<i>Swap Free:</i>' \ body = '<b>Mem Available: {} %\nSwap Free: {} %</b>'.format(
' <b>{} MiB</b>'.format( round(mem_available / mem_total * 100),
kib_to_mib(mem_available), round(swap_free / (swap_total + 0.1) * 100))
kib_to_mib(swap_free))
else: else:
body = '<b>Mem Available: {} %</b>'.format( body = '<b>Mem Available: {} %</b>'.format(
#kib_to_mib(mem_available),
round(mem_available / mem_total * 100)) round(mem_available / mem_total * 100))
if root: if root:
# отправляем уведомление всем залогиненным пользователям # отправляем уведомление всем залогиненным пользователям
@ -234,7 +231,7 @@ def send_notify_warn():
def send_notify(signal, name, pid, oom_score, vm_rss, vm_swap): def send_notify(signal, name, pid, oom_score, vm_rss, vm_swap):
title = 'Nohang TRIGGERED' title = 'NOHANG TRIGGERED'
body = '<u>Nohang</u> sent <u>{}</u> \nto the process <b>{}</b> \n<i>P' \ body = '<u>Nohang</u> sent <u>{}</u> \nto the process <b>{}</b> \n<i>P' \
'id:</i> <b>{}</b> \n<i>Badness:</i> <b>{}</b> \n<i>VmRSS:</i> <b' \ 'id:</i> <b>{}</b> \n<i>Badness:</i> <b>{}</b> \n<i>VmRSS:</i> <b' \
'>{} MiB</b> \n<i>VmSwap:</i> <b>{} MiB</b>'.format( '>{} MiB</b> \n<i>VmSwap:</i> <b>{} MiB</b>'.format(
@ -395,6 +392,8 @@ def find_victim_and_send_signal(signal):
print(badness_is_too_small) print(badness_is_too_small)
stdout.flush()
sleep_after_send_signal(signal) sleep_after_send_signal(signal)
@ -1230,9 +1229,6 @@ if print_config:
print('\nVI. DESKTOP NOTIFICATIONS') print('\nVI. DESKTOP NOTIFICATIONS')
print('gui_notifications: {}'.format(gui_notifications)) print('gui_notifications: {}'.format(gui_notifications))
if gui_notifications:
print('notify_options: {}'.format(notify_options))
print('root_display: {}'.format(root_display))
print('\nVII. AVOID AND PREFER VICTIM NAMES VIA REGEX') print('\nVII. AVOID AND PREFER VICTIM NAMES VIA REGEX')
print('regex_matching: {}'.format(regex_matching)) print('regex_matching: {}'.format(regex_matching))