5

Is there any (reliable) way to find out if the PC booted because of a Wake-on-LAN Packet instead of pressing the power button? I want automatically check if WOL is correctly configured.

I know about ethtool's WOL output, but this just tells me if WOL is turned on, not how the PC booted, right?

1

Manually testing using etherwake

I think you can test it using a tool like etherwake. Depending on the distro it's called etherwake on Ubuntu/Debian, ether-wake on RHEL/CentOS/Fedora. I had it installed already by default on Fedora, it's part of the net-tools package.

To use it:

# Redhat
$ ether-wake 00:11:22:33:44:55

# Debian/Ubuntu
$ etherwake 00:11:22:33:44:55

To confirm that a server support WOL:

$ ethtool eth0

Settings for eth0:
    Supported ports: [ ]
    Supported link modes:
    Supports auto-negotiation: No
    Advertised link modes:  Not reported
    Advertised auto-negotiation: No
    Speed: 100Mb/s
    Duplex: Full
    Port: MII
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: off
        Supports Wake-on: g
       Wake-on: g
    Link detected: yes

The "Supports Wake-on: g" and "Wake-on: g" tell you that the card is configured for WOL support. If it's missing you can add it to the ifcfg-eth0 config. file like so:

ETHTOOL_OPTS="wol g"

Using hwinfo

I noticed that if you look through the hwinfo there are messages regarding how the system came out of power save mode. Also there are messages related to the ethernet device coming up. For example:

  <6>[721194.499752] e1000e 0000:00:19.0: wake-up capability disabled by ACPI
  <7>[721194.499757] e1000e 0000:00:19.0: PME# disabled
  <7>[721194.499831] e1000e 0000:00:19.0: irq 46 for MSI/MSI-X
  <6>[721194.574306] ehci_hcd 0000:00:1a.0: power state changed by ACPI to D0
  <6>[721194.576330] ehci_hcd 0000:00:1a.0: power state changed by ACPI to D0

Here are some other messages a little while later:

  <6>[721197.226679] PM: resume of devices complete after 3162.340 msecs
  <7>[721197.226861] PM: Finishing wakeup.
  <4>[721197.226862] Restarting tasks ... done.
  <6>[721197.228541] video LNXVIDEO:00: Restoring backlight state

The idea would be that maybe there are some messages here related to how the system came up (WOL or power switch). You could add a script that runs as part of a udev event that could grep through the hwinfo output to see if messages are present for WOL vs. powerswitch. Just a idea at this point.

References

  • 2
    This just tells if the card is configured for WOL but not if the system was booted via WOL – Ulrich Dangel Jun 5 '13 at 13:59
  • Correct, the 2nd part of my answer explains that. The first part shows how you could use ether-wake to manually make a server go up/down to confirm that the WOL is working. This was ultimately what the OP was trying to do by looking at the status. – slm Jun 5 '13 at 14:08
  • To the downvoter, care to elaborate what's wrong? – slm Jun 5 '13 at 22:28
3

Unless your network hardware preserves some state based on the WOL wakeup, that you can read after the initialisation during the boot process, you cannot determine this.

I have not looked at WOL in detail since 2000, but the network cards I worked with at that time certainly did not have such a feature.

0

Disable the power-button.

If you do not have an iLO/RAC or something like that, which can watch the machine while it is off AFAIK no chance.

I did not hear it, but perhaps there is some vendor-specific tool that can read from your network card some kind of log.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy