2

I'm looking for a way (programmatically or otherwise) to determine if my machine was woken up by WOL or not (let's say, a Ubuntu Server box).

This is sort of a two-fold question, where I want to know if I can:

a) Hook something that'll hear about being woken up when the machine comes out of sleep and

b) Can then determine somehow whether the wake was due to WOL or not

I'm not too concerned by what mechanism (if any) this is achieved, but am interested really in whether it's even possible.

Maybe if there was some file that logged wake up/sleep times, I could write a small program that looped and occasionally checked the file for changes, but don't know what i'd need to do to figure out of it was WOL or not (or if such a file exists).

Thanks

5
  • What is your use case? What other events cause your computer to wake?
    – depquid
    Apr 20, 2013 at 15:11
  • 1
    @depquid imagine a scenario where someone physically might wake the machine up, in which case you want to let them proceed, but someone on the network might wake the machine up, in which case you want to follow certain procedures to verify the intent of the wake up, and on failure of that sleep the machine again.
    – Rhys
    Apr 20, 2013 at 15:39
  • I'm not sure what you mean by "intent". The implied intent of a WOL packet is to wake the computer up. Or is this a security issue where you are concerned about other users of the network issuing WOLs to your computer? Perhaps you could wait 5 minutes after boot for a user to log in, locally or remotely, and then sleep again if no one does.
    – depquid
    Apr 20, 2013 at 15:44
  • If I'm not mistaken, WOL is provided by the BIOS. So unless the BIOS exposes something on how the PC was powered up, I don't think you can get that information.
    – Bobby
    Apr 20, 2013 at 19:14
  • How about physical switches – is there any loggable event on those? (In my case, I care about discerning WOL vs physical switch for returning from suspend – in the WOL case, and only then, I want to run a script and then suspend.)
    – unhammer
    Apr 26, 2018 at 12:36

2 Answers 2

1

To determine if your machine has woken up, you can test if you can reach it, as you would with any other machine to see if it's there:

  • ping
  • telnet some port of a service bound to the startup of of the machine
  • use snmp if configured

As whether you can be able to know if your machine has been started by WOL or not, that is not possible, as all the communication between the elements involved in WOL. that is, the magic packet, the ethernet card and the BIOS, occurs before the operating system is even booted.

0

You would need another always on device to constantly monitor the wire for the WOL packet. Such a device would have to be relatively smart. Another computer running a tool in promiscuous mode setup to search for the WOL packet should in theory be able to catch it.

The device would have to be always on and scanning the network connection. There is a possibility the sensor could miss it, but it should work. In short, basically another PC. While there might be some network device out there that could do I don't know about it. I have never used one, but there exists at least the possibility that a switch loaded with a linux firmware might be able to do it.

linux router/switch firmware product device support page

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .