5 linux boot ethernet wake-on-lan
是否有任何(可靠的)方法来确定 PC 是否因为 LAN 唤醒数据包而不是按下电源按钮而启动?我想自动检查 WOL 是否配置正确。
我知道ethtool
的 WOL 输出,但这只是告诉我 WOL 是否打开,而不是 PC 是如何启动的,对吗?
etherwake
我认为你可以使用像 之类的工具来测试它etherwake
。根据发行版的不同,它etherwake
在 Ubuntu/Debian、ether-wake
RHEL/CentOS/Fedora 上被称为。我已经在 Fedora 上默认安装了它,它是 net-tools 包的一部分。
使用方法:
# Redhat
$ ether-wake 00:11:22:33:44:55
# Debian/Ubuntu
$ etherwake 00:11:22:33:44:55
Run Code Online (Sandbox Code Playgroud)
要确认服务器支持 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
Run Code Online (Sandbox Code Playgroud)
“Supports Wake-on: g”和“Wake-on: g”告诉您该卡已配置为支持 WOL。如果缺少,您可以将其添加到ifcfg-eth0
配置中。像这样的文件:
ETHTOOL_OPTS="wol g"
Run Code Online (Sandbox Code Playgroud)
hwinfo
我注意到,如果您仔细查看,hwinfo
就会发现有关系统如何退出省电模式的消息。还有与以太网设备相关的消息即将出现。例如:
<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
Run Code Online (Sandbox Code Playgroud)
稍后还有一些其他消息:
<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
Run Code Online (Sandbox Code Playgroud)
这个想法是,这里可能有一些与系统如何启动(WOL 或电源开关)相关的消息。您可以添加一个作为 udev 事件的一部分运行的脚本,该脚本可以通过 hwinfo 输出进行 grep 以查看是否存在 WOL 与电源开关的消息。目前只是一个想法。