Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New notification design #183

Closed
rfjakob opened this issue Mar 31, 2020 · 13 comments
Closed

New notification design #183

rfjakob opened this issue Mar 31, 2020 · 13 comments

Comments

@rfjakob
Copy link
Owner

rfjakob commented Mar 31, 2020

earlyoom will send a dbus message to the system bus, and there will be tiny notification daemon running as the user that listens for those messages and shows a notification.

earlyoom side is easy, it will just exec something like this:

dbus-send --system --type=signal / net.nuetzlich.SystemNotifications.Notify "string:hello world"

The notification daemon still needs to be written. Proof of concept that the signal can be received:

dbus-monitor --system
[...]
signal time=1583570854.999879 sender=:1.1278 -> destination=(null destination) serial=2 path=/; interface=net.nuetzlich.SystemNotifications; member=Notify
   string "hello world"

Same idea in Python (german only): https://wiki.debianforum.de/Desktop-Notification_von_Systemservice_mittels_dbus

@devurandom
Copy link

I really like and support this approach over hacks like #182. But is earlyoom really the first to implement a wall(1) over dbus / logind / libnotify? Shouldn't this be implemented in https://gitlab.gnome.org/GNOME/libnotify instead? Or if it is out of scope for them, in a separate project?

@rfjakob
Copy link
Owner Author

rfjakob commented Apr 2, 2020

That is really a good question. earlyoom is for sure not the first project to have this use case. But I could not find a single good existing solution.

@rfjakob
Copy link
Owner Author

rfjakob commented Apr 3, 2020

Notification daemon is done: https://github.com/rfjakob/systembus-notify

@devurandom
Copy link

Great! :)

I also filed an issue upstream: https://gitlab.gnome.org/GNOME/libnotify/-/issues/9

@hakavlad
Copy link
Contributor

hakavlad commented Apr 4, 2020

Can we use it right now with earlyoom? How to use it? Please update doc.

rfjakob added a commit that referenced this issue Apr 4, 2020
Gets rid of sudo hacks and system() calls.

#183
@rfjakob
Copy link
Owner Author

rfjakob commented Apr 4, 2020

Merged as 17b3d5e , yes please test!

Just run

earlyoom -n

and at the same time run an instance of https://github.com/rfjakob/systembus-notify .

@hakavlad
Copy link
Contributor

hakavlad commented Apr 5, 2020

root@debian:~# earlyoom -n
earlyoom v1.5-4-gab946ee
Notifying through D-Bus
mem total: 1615 MiB, swap total: 4845 MiB
sending SIGTERM when mem <= 10.00% and swap <= 10.00%,
        SIGKILL when mem <=  5.00% and swap <=  5.00%
mem avail:   346 of  1615 MiB (21.44%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   346 of  1615 MiB (21.44%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   346 of  1615 MiB (21.43%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   346 of  1615 MiB (21.42%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   344 of  1615 MiB (21.34%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   344 of  1615 MiB (21.34%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   344 of  1615 MiB (21.34%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   343 of  1615 MiB (21.29%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   343 of  1615 MiB (21.29%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   343 of  1615 MiB (21.29%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   343 of  1615 MiB (21.29%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   343 of  1615 MiB (21.29%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   343 of  1615 MiB (21.29%), swap free: 4680 of 4845 MiB (96.59%)
mem avail:   341 of  1615 MiB (21.12%), swap free:    0 of  160 MiB ( 0.00%)
mem avail:   334 of  1615 MiB (20.68%), swap free:    0 of  150 MiB ( 0.00%)
mem avail:   321 of  1615 MiB (19.91%), swap free:    0 of  134 MiB ( 0.00%)
mem avail:   308 of  1615 MiB (19.08%), swap free:    0 of  115 MiB ( 0.00%)
mem avail:   264 of  1615 MiB (16.38%), swap free:    0 of   55 MiB ( 0.00%)
mem avail:   247 of  1615 MiB (15.33%), swap free:    0 of   29 MiB ( 0.00%)
mem avail:   230 of  1615 MiB (14.28%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   231 of  1615 MiB (14.31%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   231 of  1615 MiB (14.32%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   231 of  1615 MiB (14.32%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   231 of  1615 MiB (14.32%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   231 of  1615 MiB (14.32%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   231 of  1615 MiB (14.34%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   231 of  1615 MiB (14.34%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   231 of  1615 MiB (14.34%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:    89 of  1615 MiB ( 5.53%), swap free:    0 of    0 MiB ( 0.00%)
low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
sending SIGTERM to process 3395 uid 1000 "firefox-esr": badness 163, VmRSS 263 MiB
escalating to SIGKILL after 0.1 seconds
process exited after 0.4 seconds
mem avail:   468 of  1615 MiB (29.01%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   700 of  1615 MiB (43.40%), swap free:    0 of    0 MiB ( 0.00%)

No notification provided.

@hakavlad
Copy link
Contributor

hakavlad commented Apr 5, 2020

$ oom-sort
oom_score oom_score_adj   UID   PID Name            VmRSS   VmSwap   cmdline
--------- ------------- ----- ----- --------------- ------- -------- -------
        0             0  1000  1150 ssh-agent           0 M      0 M /usr/bin/ssh-agent mate-session
        0             0  1000  1244 systembus-notif     1 M      0 M systembus-notify
        0             0  1000  1420 earlyoom            1 M      0 M earlyoom -n

systembus-notify and earlyoom -n started as user, no notification provided.

$ earlyoom -n
earlyoom v1.5-4-gab946ee
Notifying through D-Bus
mem total: 3946 MiB, swap total:    0 MiB
sending SIGTERM when mem <= 10.00% and swap <= 10.00%,
        SIGKILL when mem <=  5.00% and swap <=  5.00%
mem avail:  2917 of  3946 MiB (73.92%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2917 of  3946 MiB (73.92%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2917 of  3946 MiB (73.92%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2917 of  3946 MiB (73.92%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2916 of  3946 MiB (73.90%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2916 of  3946 MiB (73.90%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2916 of  3946 MiB (73.89%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2916 of  3946 MiB (73.89%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2916 of  3946 MiB (73.89%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2916 of  3946 MiB (73.89%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2785 of  3946 MiB (70.58%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  1232 of  3946 MiB (31.23%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:   344 of  3946 MiB ( 8.73%), swap free:    0 of    0 MiB ( 0.00%)
low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
sending SIGTERM to process 1434 uid 1000 "tail": badness 652, VmRSS 2570 MiB
process exited after 0.1 seconds
mem avail:  2916 of  3946 MiB (73.89%), swap free:    0 of    0 MiB ( 0.00%)
mem avail:  2916 of  3946 MiB (73.89%), swap free:    0 of    0 MiB ( 0.00%)

@hakavlad
Copy link
Contributor

Works well on Xubuntu 19.10:

апр 15 00:08:52 user-pc earlyoom[1166]: Failed to open connection to "system" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security 
апр 15 00:08:31 user-pc dbus-daemon[1186]: [system] Connection has not authenticated soon enough, closing it (auth_timeout=30000ms, elapsed: 138441ms)
апр 15 00:08:58 user-pc earlyoom[1166]: Failed to open connection to "system" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security 
апр 15 00:08:31 user-pc dbus-daemon[1186]: [system] Connection has not authenticated soon enough, closing it (auth_timeout=30000ms, elapsed: 121316ms)
апр 15 00:09:07 user-pc earlyoom[1166]: mem avail:     0 of  1643 MiB ( 0.00%), swap free:  130 of 1312 MiB ( 9.96%)
апр 15 00:09:07 user-pc earlyoom[1166]: low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
апр 15 00:09:07 user-pc earlyoom[1166]: sending SIGTERM to process 3461 uid 1000 "tail": badness 739, VmRSS 1340 MiB
апр 15 00:09:09 user-pc earlyoom[1166]: process exited after 0.9 seconds
апр 15 00:09:12 user-pc dbus-daemon[1186]: [system] Connection has not authenticated soon enough, closing it (auth_timeout=30000ms, elapsed: 40601ms)
апр 15 00:09:18 user-pc earlyoom[1166]: Failed to open connection to "system" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security 
апр 15 00:09:40 user-pc earlyoom[1166]: mem avail:     0 of  1643 MiB ( 0.00%), swap free:  127 of 1312 MiB ( 9.72%)
апр 15 00:09:40 user-pc earlyoom[1166]: low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
апр 15 00:09:41 user-pc earlyoom[1166]: sending SIGTERM to process 3685 uid 1000 "tail": badness 748, VmRSS 1361 MiB
апр 15 00:09:41 user-pc earlyoom[1166]: process exited after 0.1 seconds
апр 15 00:09:43 user-pc dbus-daemon[1186]: [system] Connection has not authenticated soon enough, closing it (auth_timeout=30000ms, elapsed: 31090ms)
апр 15 00:09:43 user-pc dbus-daemon[1186]: [system] Connection has not authenticated soon enough, closing it (auth_timeout=30000ms, elapsed: 30524ms)
апр 15 00:09:44 user-pc earlyoom[1166]: Failed to open connection to "system" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security 
апр 15 00:09:43 user-pc dbus-daemon[1186]: [system] Connection has not authenticated soon enough, closing it (auth_timeout=30000ms, elapsed: 30524ms)
апр 15 00:09:44 user-pc earlyoom[1166]: Failed to open connection to "system" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security 
апр 15 00:09:44 user-pc earlyoom[1166]: Failed to open connection to "system" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security 

@rfjakob
Copy link
Owner Author

rfjakob commented Apr 14, 2020

In other words, it does not work at all?

@hakavlad
Copy link
Contributor

It works at all.

апр 15 00:09:18 user-pc earlyoom[1166]: Failed to open connection to "system" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security 

-- it happens under heavy swapping, it is OK.

@rfjakob
Copy link
Owner Author

rfjakob commented Apr 14, 2020

I see, ok

@rfjakob
Copy link
Owner Author

rfjakob commented Apr 19, 2020

Thanks for the feedback. v1.6 has been released with the new notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants