in reply to
Net::OpenSSH fastest way to reconnect to a rebooted machine?
How to do this without polling, and with an unmodified target machine?
This might be very complicated to do Perl (there is hope, Net::Pcap exists), but listen on the ethernet port (sniffing, pcap, etc) for the broadcasted DHCP packet that the rebooting machine will put out on the ethernet wire. What about SNMP against the DHCP server?
If you can modify the target machine, have the target machine do a wget on boot on a dynamic dns address, that happens to be your machine, you can run a small perl webserver based off HTTP::Daemon on your side, the server on boot connects to your perl mini-server and the perl script on your side wakes up and continues with the rest of the SSH commands. Remember to consider timeouts and retrys by wget, you can deadlock if wget can't wake up your Perl SSH script for some reason. The keywords "watchdog" or "heartbeat" are relevant. Also remember if you make a miniserver off HTTP::Daemon, what happens if 2 servers try to connect to the miniserver at once (assuming you dont serialize the SSH command execution and rebooting, you probably do)? In my experience, the OS just queues the 2nd attempt, if you dont call another accept() fast enough, the remote side will time out.
On some networks you might get an ICMP unavailable packet if the ethernet port of the server is down, rather than a plain old timeout. Might wanna somehow separate in code a plain timeout from an ICMP unavailable.