cockpit-project / cockpit

Cockpit is a web-based graphical interface for servers.
http://www.cockpit-project.org/
GNU Lesser General Public License v2.1
11.24k stars 1.11k forks source link

Wake on lan offline hosts #15855

Open SillieWous opened 3 years ago

SillieWous commented 3 years ago

Page: Hosts

It would be nice to send a wake on lan packet to hosts that are offline. Not al my servers are running all the time, but I still like to manage them via a centralised cockpit instance. If I can WOL from the cockpit hosts menu and quickly check something on an offline host that would be great.

marusak commented 3 years ago

This indeed would be interesting to have in cockpit. However, the main issue I see with this is how would we recognize if given host supports WOL. We surely don't want to add this button to every host while I believe that majority of users would not have support for this. Since I am not very familiar with this functionality, @SillieWous do you know if it is possible to figure this out somehow? (Assuming the host we want to wake is currently down)

SillieWous commented 3 years ago

Not sure how it works behind the scenes, but with ethtools you can check if an interface supports wake-on-lan. (see also https://wiki.debian.org/WakeOnLan)

When connecting to a host it shouldn't be to much trouble to check if the interface used for connecting supports it. We'd need to get the MAC address (and save it somewhere like /etc/machines.d/99-webui.json). Once it is there, a button could be added if the MAC address is present for example.

martinpitt commented 3 years ago

how would we recognize if given host supports WOL

You can't -- if a machine is powered off, there is no way to tell. You can just try and see if it works.

with ethtools you can check if an interface supports wake-on-lan

Sure, but that applies to a local interface. This request is about waking up a remote machine.

SillieWous commented 3 years ago

@martinpitt The first time you connect to a machine it has to be online. At that time it can be checked if WOL is supported.

If it does, you can extract the MAC address and save locally the same way the IP is saved. Next time, when the remote system is powered off, the presence of a MAC address will indicate support for WOL on that an interface.

martinpitt commented 3 years ago

@SillieWous : That makes sense, yes. This should then become part of the "login failed" dialog.