开发者

Getting notifications regarding internet connection is gone in linux?

开发者 https://www.devze.com 2023-02-06 03:07 出处:网络
In linux , is it possible to get notification when netwo开发者_如何学Gork connection is down ? Is the any OS service for which I have to register for such notifications ?

In linux , is it possible to get notification when netwo开发者_如何学Gork connection is down ?

Is the any OS service for which I have to register for such notifications ?

OR is there any DBus Service of it ?


If you're using NetworkManager, it's possible to get status from it (which is, if I remember correctly, done over dbus).

But beware that a lot of Linux machines don't use NetworkManager, so you'll have to handle that. And some machines have more than one network connection, etc.

Further "network connection is down" may not be the most useful thing for you. E.g., it's possible to have a network connection, but the router has lost its Internet connection, so you've only got connectivity to local machines. Or sometimes you'll see partial Internet reachability. Depending on what you need this for, you may need to take other approaches.

Lastly, sometimes network connections die and come back quickly, especially with wireless. These transient changes are probably best ignored (unless the IP address changes).


See this forum thread (linuxquestions.org). Basically you'd need to modify the kernel for pushed notifications. Networkmanager indeed has a DBUS API, but polling periodically is a more general solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消