[PLUGIN] WOL for Services


Recommended Posts

This was a function being developed for the next release but was decided best to be a plugin to start with to allow better interations for changes. Currently this is a beta release.

 

the is an existing plugin called virtwold this expands on it to include dockers and LXC.

 

I am in the process to complete changes to make it work fully under 6.12 but currently the search function and help text don't work or don't exist.

 

Two pages are created, first is the settings.

 

image.png

 

Within the settings you can specify which servers are enabled. The interface name needs to be a physical NIC. By default shutdown actions are disabled.

 

The second page is in tools. It allows you to specify the actions allowed. To be able to start dockers you need to have a user defined mac address as one is not assigned until the docker starts and changes.

 

Values for the enabled field are image.png

 

image.png

 

 

  • Like 5
Link to comment
2 hours ago, Wizard_ said:

Will this plugin replace "Virtual Machine Wake On Lan" ? Which is quite old and lack necessary support.

It should provide similar functions but I have not used this plugin so cannot say if it is like for like.

Link to comment

OMG, thank you so much 😀 Yesterday i was looking for a solution to send a WOL signal to my VM via Home Assistant and didn't get it working with the previous plugins. Today i find yours and its working great, so cool 😁

 

Thank you, Michael

Link to comment

question, is there any more logging possible ? i have enabled suspend, but actually the vm doesnt use suspend, wol triggered, wol arrived, no suspend triggered ...

 

image.thumb.png.c9963803799dc5895ee2935fd5af998f.png

 

i assume as i use hibernate in the VM and disabled suspend (to ram) ... you only implemented suspend to ram i assume

 

this is how i hibernate my VM as sample

 

virsh dompmsuspend AlsPC --target disk"

 

and i guess you prefered regular ...

 

root@AlsServer:~# virsh dompmsuspend --help
  NAME
    dompmsuspend - suspend a domain gracefully using power management functions

  SYNOPSIS
    dompmsuspend <domain> <target> [--duration <number>]

  DESCRIPTION
    Suspends a running domain using guest OS's power management. (Note: This requires a guest agent configured and running in the guest OS).

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--target] <string>  mem(Suspend-to-RAM), disk(Suspend-to-Disk), hybrid(Hybrid-Suspend)
    --duration <number>  duration in seconds


root@AlsServer:~# 

 

so i assume, yes, you trigger it, but as its disabled here (hibernate) it has no effect, correct ?

Link to comment
10 hours ago, alturismo said:

so i assume, yes, you trigger it, but as its disabled here (hibernate) it has no effect, correct ?

Unraid uses the php api. I can look at managed save as a option which is hibernate to disk

 

libvirt_domain_suspend

libvirt_domain_suspend($res)

[Since version 0.4.1(-1)]

Function is used to suspend the domain identified by it's resource.

@res [resource]:libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()

Returns:: TRUE for success, FALSE on error

libvirt_domain_managedsave

libvirt_domain_managedsave($res)

[Since version 0.4.1(-1)]

Function is used to managed save the domain (domain was unloaded from memory and it state saved to disk) identified by it's resource.

@res [resource]:libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()

Returns:: TRUE for success, FALSE on error

  • Thanks 1
Link to comment

Hi,

yesterday i tried to boot a VM with a WOL signal and Unraid got stuck and was very very slow. It wasn't possible to navigate through the GUI. Some VM's which were running at the moment were very slow also. I had to switch off the computer and to restart everything. 

I don't know if it happened because of this plugin. Can you help me?

 

Thank you, Michael

tower-diagnostics-20240321-0745.zip

Link to comment
  • 3 weeks later...
On 3/10/2024 at 7:32 PM, Mika said:

OMG, thank you so much 😀 Yesterday i was looking for a solution to send a WOL signal to my VM via Home Assistant and didn't get it working with the previous plugins. Today i find yours and its working great, so cool 😁

 

Thank you, Michael

Could you share your settings? Mine doesn't work:

switch:
  - platform: wake_on_lan
    mac: 52:xx:00:xx:2c:xx
    broadcast_address: 10.0.1.xx
    broadcast_port: 9
    host: 10.0.1.xxx
    name: 2023-xxxx-gaming

 

Link to comment
2 hours ago, Soulplayer said:

Could you share your settings? Mine doesn't work:

switch:
  - platform: wake_on_lan
    mac: 52:xx:00:xx:2c:xx
    broadcast_address: 10.0.1.xx
    broadcast_port: 9
    host: 10.0.1.xxx
    name: 2023-xxxx-gaming

 

Hi I did a quick test on my test server. I dont use HA except for testing this is what i have added to my yaml.

 

wake_on_lan:

switch:
  - platform: wake_on_lan
    mac: 52:54:00:DA:18:68
    name: Debian2LXC

 

 

And button added to UI. image.png

Apr  7 09:56:16 computenode Unraidwold[26103]: 2024/04/07 09:56:16 Found 52:54:00:da:18:68 LXC DebianLXC2

 

My settings.

 

image.pngimage.png

Link to comment
On 3/21/2024 at 7:15 AM, Mika said:

Hi,

yesterday i tried to boot a VM with a WOL signal and Unraid got stuck and was very very slow. It wasn't possible to navigate through the GUI. Some VM's which were running at the moment were very slow also. I had to switch off the computer and to restart everything. 

I don't know if it happened because of this plugin. Can you help me?

 

Thank you, Michael

tower-diagnostics-20240321-0745.zip 200 kB · 1 download

Sorry for the late reply just looked at the Diags but they seem to be after a reboot so cannot see any errors.

Link to comment

First create a simple button. 

After that create an automation, that looks like this:

alias: WOL_KinoVM
description: ""
trigger:
  - platform: state
    entity_id:
      - input_button.kinovm_boot
condition: []
action:
  - service: wake_on_lan.send_magic_packet
    metadata: {}
    data:
      broadcast_port: 9
      mac: 52:54:00:7v:2k:q7
mode: single

 

after that you can add your button, which you have created in the first step, to your dashboard.

 

 

Regarding my problem. No problem, it happend only once and never again

Screenshot 2024-04-07 142956.png

Screenshot 2024-04-07 143526.png

  • Like 1
Link to comment
On 4/14/2024 at 6:37 PM, alturismo said:

may i ask if you had a chance to look at it ? ;)

Give 2024.04.16 a try.

Suspend command is the virsh option either suspend or dompmsuspend(Power Management) and mode of mem or disk.

image.png

Link to comment
On 4/16/2024 at 8:54 PM, SimonF said:

Suspend command is the virsh option either suspend or dompmsuspend(Power Management) and mode of mem or disk.

 

ok, tested here, no result at all on suspend, shutdown is working

 

here the syslog, triggered at 7.38 suspend, only info is "found ..." at 7.41 its triggered with shutdown and working as expected"

 

Apr 18 07:38:30 AlsServer Unraidwold[26302]: 2024/04/18 07:38:30 Found 52:54:00:1a:60:97 VM AlsPC
### this was with suspend, nothing else came into the syslog ...
###
Apr 18 07:41:04 AlsServer Unraidwold[26302]: 2024/04/18 07:41:04 Found 52:54:00:1a:60:97 VM AlsPC
Apr 18 07:41:15 AlsServer kernel: usb 1-12: reset full-speed USB device number 10 using xhci_hcd
Apr 18 07:41:15 AlsServer kernel: input: Logitech USB Receiver as /devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.0/0003:046D:C52B.00BD/input/input304
Apr 18 07:41:15 AlsServer kernel: hid-generic 0003:046D:C52B.00BD: input,hidraw1: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-0000:00:14.0-12/input0
Apr 18 07:41:15 AlsServer kernel: input: Logitech USB Receiver Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.1/0003:046D:C52B.00BE/input/input305
Apr 18 07:41:15 AlsServer kernel: input: Logitech USB Receiver Consumer Control as /devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.1/0003:046D:C52B.00BE/input/input306
Apr 18 07:41:15 AlsServer kernel: input: Logitech USB Receiver System Control as /devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.1/0003:046D:C52B.00BE/input/input307
Apr 18 07:41:15 AlsServer kernel: hid-generic 0003:046D:C52B.00BE: input,hiddev96,hidraw2: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-0000:00:14.0-12/input1
Apr 18 07:41:15 AlsServer kernel: hid-generic 0003:046D:C52B.00BF: hiddev97,hidraw3: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:00:14.0-12/input2
Apr 18 07:41:16 AlsServer usb_manager: Info: rc.usb_manager  vm_action AlsPC stopped end -
Apr 18 07:41:16 AlsServer usb_manager: Info: rc.usb_manager VM Shutdown 001/010 vm: AlsPC 
Apr 18 07:41:16 AlsServer kernel: vfio-pci 0000:05:00.0: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=io+mem:owns=none
Apr 18 07:41:16 AlsServer kernel: nvidia 0000:05:00.0: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=none:owns=none
Apr 18 07:41:41 AlsServer ool www[18465]: Successful logout user root from 192.168.1.130
Apr 18 07:41:49 AlsServer monitor_nchan: Stop running nchan processes

 

Link to comment
28 minutes ago, alturismo said:

ok, tested here, no result at all on suspend, shutdown is working

 

here the syslog, triggered at 7.38 suspend, only info is "found ..." at 7.41 its triggered with shutdown and working as expected"

 

Apr 18 07:38:30 AlsServer Unraidwold[26302]: 2024/04/18 07:38:30 Found 52:54:00:1a:60:97 VM AlsPC
### this was with suspend, nothing else came into the syslog ...
###
Apr 18 07:41:04 AlsServer Unraidwold[26302]: 2024/04/18 07:41:04 Found 52:54:00:1a:60:97 VM AlsPC
Apr 18 07:41:15 AlsServer kernel: usb 1-12: reset full-speed USB device number 10 using xhci_hcd
Apr 18 07:41:15 AlsServer kernel: input: Logitech USB Receiver as /devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.0/0003:046D:C52B.00BD/input/input304
Apr 18 07:41:15 AlsServer kernel: hid-generic 0003:046D:C52B.00BD: input,hidraw1: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-0000:00:14.0-12/input0
Apr 18 07:41:15 AlsServer kernel: input: Logitech USB Receiver Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.1/0003:046D:C52B.00BE/input/input305
Apr 18 07:41:15 AlsServer kernel: input: Logitech USB Receiver Consumer Control as /devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.1/0003:046D:C52B.00BE/input/input306
Apr 18 07:41:15 AlsServer kernel: input: Logitech USB Receiver System Control as /devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.1/0003:046D:C52B.00BE/input/input307
Apr 18 07:41:15 AlsServer kernel: hid-generic 0003:046D:C52B.00BE: input,hiddev96,hidraw2: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-0000:00:14.0-12/input1
Apr 18 07:41:15 AlsServer kernel: hid-generic 0003:046D:C52B.00BF: hiddev97,hidraw3: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:00:14.0-12/input2
Apr 18 07:41:16 AlsServer usb_manager: Info: rc.usb_manager  vm_action AlsPC stopped end -
Apr 18 07:41:16 AlsServer usb_manager: Info: rc.usb_manager VM Shutdown 001/010 vm: AlsPC 
Apr 18 07:41:16 AlsServer kernel: vfio-pci 0000:05:00.0: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=io+mem:owns=none
Apr 18 07:41:16 AlsServer kernel: nvidia 0000:05:00.0: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=none:owns=none
Apr 18 07:41:41 AlsServer ool www[18465]: Successful logout user root from 192.168.1.130
Apr 18 07:41:49 AlsServer monitor_nchan: Stop running nchan processes

 

Did you change the option in settings to use Power Management Suspend? defaults to Pause. i.e. Suspend.

 

You can use this run manually. arg is the MAC if power suspend is enabled you should get the message below.

 

root@computenode:/tmp/lynis# /usr/local/emhttp/plugins/WOL4Services/include/WOLrun.php "XX:XX:XX:XX:XX:XX:XX"
Found XX:XX:XX:XX:XX:XX:XX VM Debian Suspend disk Domain 'Debian' successfully suspended

Link to comment
1 hour ago, SimonF said:

You can use this run manually. arg is the MAC if power suspend is enabled you should get the message below.

ok, current state on the VM Mashine is

 

image.thumb.png.0ea86b7d160a56123dfa8bb95bcd1168.png

 

image.thumb.png.4174848183f2ac6c77b38904fd963f36.png

 

image.thumb.png.4ac1b492eda12f88ef743da5b3081501.png

 

root@AlsServer:~# /usr/local/emhttp/plugins/WOL4Services/include/WOLrun.php "52:54:00:1a:60:97"
Found 52:54:00:1a:60:97 VM AlsPC Suspend disk Domain 'AlsPC' successfully suspended
root@AlsServer:~# 

 

so this worked out as it should ;)

 

now i try to send a wol ...

 

i started the VM again, and send a wol request, my expectation, it should also suspend now, but after this log message ... nothing happens

 

image.thumb.png.e3742a52cdc0e1563036a38a2d2aeb3b.png

 

so, manually triggereing the php call works, but triggered by wol it doesnt

Link to comment
1 hour ago, alturismo said:

ok, current state on the VM Mashine is

 

image.thumb.png.0ea86b7d160a56123dfa8bb95bcd1168.png

 

image.thumb.png.4174848183f2ac6c77b38904fd963f36.png

 

image.thumb.png.4ac1b492eda12f88ef743da5b3081501.png

 

root@AlsServer:~# /usr/local/emhttp/plugins/WOL4Services/include/WOLrun.php "52:54:00:1a:60:97"
Found 52:54:00:1a:60:97 VM AlsPC Suspend disk Domain 'AlsPC' successfully suspended
root@AlsServer:~# 

 

so this worked out as it should ;)

 

now i try to send a wol ...

 

i started the VM again, and send a wol request, my expectation, it should also suspend now, but after this log message ... nothing happens

 

image.thumb.png.e3742a52cdc0e1563036a38a2d2aeb3b.png

 

so, manually triggereing the php call works, but triggered by wol it doesnt

Have you tried disabling and then re enable service

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.