• 1(current)
  • 2
  • 3
  • 4
  • 5
  • 38
  • Next 
Thread Rating:
  • 4 Vote(s) - 5 Average
Automatic WakeOnLan upon accessing MySql or FileShares
Hi all!

I have sent in a patch today (Ticket #12739) that adds a feature to XBMC :
XBMC will automatically issue a 'wake-on-lan' packet to MySql or FileShare Server right before it needs to contact them (if so configured).

There are different ways of doing this (plugins or os-specific scripts) but non of them have quite solved my needs, therefore this patch.
Hoping it will get accepted for a future build!
Edit : The patch has been merged and should become available from XBMC 13 (Gotham) Alpha 4 (May 2013)


Description (updated)

Feature is enabled under "system/settings/system/power saving/try to wake remote servers on access"

When feature gets enabled or shares gets added an autoscan will be done for any servers specified, either in shares or in MySQL settings.
The autoscan will if necessary create a file called 'wakeonlan.xml' and will add entries for these servers including macaddress which should be picked up in the scan.

Sample 'wakeonlan.xml'

netinittimeout [secs]
time xbmc will wait for network to (re)connect when booting or after resuming from suspend-mode
netsettletime [milli secs]
time to wait for network to be consistently connected before progressing
ipaddress (or network name) of machine you want to wake up
default 0 which will perform ordinary icmp ping. else a 'connect' attempt will be done to the specified port
only applicable if pingport!=0, if 1 will not only connect to pingport but also wait until data is actually read back
timeout [secs]
specifies how long time (default 600) of inactivity must pass before a new 'wake-on-lan' check is performed. a good choice is to use same value as server's idle-timeout before entering sleep-mode
waitonline [secs]
time to wait for machine to wake up (advise is to set this to servers actual anticipated startup time)
waitonline2 [secs]
time to perform extended wait for machine to wake up
waitservices [secs]
additional time to wait after ping response, to allow server daemons to startup

useful pingport/pingmode combinations ;
pingport = 445 / pingmode = 0 - port 445 is used by samba (windows file sharing) and can be used for 'ping-probing' (but only pingmode = 0)
pingport = 3306 / pingmode = 1 - port 3306 is default MySQL port and useful if your server is the MySQL host
port 21 (ftp), 22 (ssl), 23 (telnet) are also likely to work OK if your server has that service installed

when using pingport = 0 (normal icmp ping) it is recommended to use waitservices = (ca) 5 to allow services on server to startup after server responds to ping. if using a different pingport it is normally not nessesary to add additional wait time
I can't comment on the coding or whether it's suitable for inclusion but it's a nice idea anyway! I just wanted to make a suggestion (or see what other people think)..

Being able to wake the server is great but in my situation it can take 10-20 seconds for my makeshift server to properly resume from S3 after which XBMC has generally already timed out regardless. With that in mind I currently just have the hard-drives configured to go into power-saving mode instead. As they're all different sizes I haven't bothered with any RAID config so they need waking individually depending on the source accessed. These only take 5-10 seconds-ish to power up but it can still cause a delay and in some cases skipping for the first few seconds of a movie.

I'm just curious what you (and others) would think of including an option to also 'touch' or wake each of the media sources / drives in sources.xml so all the drives power up and are ready for access whenever XBMC is opened?
My server uses equally long time to start and XBMC would freeze ; that is no longer the case with the additions I made. It will stay black for those 10-20 seconds, but as soon as the server gets online XBMC continues and is good to go.
It would be even better if a message could be displayed while waiting, but that is probably not so easy because it is during skin-initialization that the MySql server is contacted..

To 'touch' your drives I would recommend an Addon- script. It should be relatively easy to put together. See http://wiki.xbmc.org/index.php?title=HOW...g_services
That way you can keep-alive the drives you like for as long as XBMC is running, not just on startup. And it should resume after a standby of your XBMC if that is how you run it.
This is great!! Would be perfect for my setup. Is there a way for me to add your code to my installation? What files do I need to change?
Thanks! To apply it yourself you would need to fetch the modifications from the ticket and then make a build by yourself (after also fetching the entire source for xbmc and merging my changes into it). It is quite a bit of work (I have only done it for the Windows-edition myself because I miss too much of the environments required for the other builds)

Best you can do is what you just did : state your interest for it ! That way we increase the chance that the team will accept the patch so we get official builds with the feature included.
This is insanely great!

It's a little odd that at first the sql server is queried and than the wakeonlan plugin is launching.

I hope anyone of the development team is reading this.

In my opinion it is a must have feature...

It is the only way to power down your sql server and let it restart from your xbmc clients!
great concept

i look forward to using it in the future
Absolutely brilliant, I've been waiting for this feature for a long time!
+1 on my side. you could easily make a workaround on windows pcs, but something like a raspberry pi or apple tv3 could be a problem without this patch.
has this been implemented?
We are after "Eden" -> implement it!
PC: Kubuntu 16.10 and Win7/10 --- Wetek Play: LibreELEC 7.95.x --- RPi3: 7.95.x --- NAS: OMV 2.x
I find this patch very intriguing. This si something I have been wanting for a very long time. I plan make a build with this patch today and see how it performs.

Can you explain the <tmout>700</tmout> option a bit more? Why would we need to constantly send wake-up packets to the server?
Read this before using these builds.
(2012-04-12, 19:33)kricker Wrote: I find this patch very intriguing. This si something I have been wanting for a very long time. I plan make a build with this patch today and see how it performs.

Can you explain the <tmout>700</tmout> option a bit more? Why would we need to constantly send wake-up packets to the server?

The 'timeout' specified does not mean that a new wake-up is done at this interval.
Instead is defines the time (in seconds) of inactivity that should pass before a new wake-up is sent.
So, for as long as files are beeing accessed on the server there will not (ever) be re-sent a wake-up, the wake-up will be done after activity stops and has been idle for the time set in 'tmout'

The idea is that if you have a server that is set to go into suspend-mode after e.g 30 minutes of inactivity then you can setup XBMC to send a new wake-up if XBMC detects that no access has been done towards that server for more than e.g 25 minutes (to make sure we wake it up again)
This new wake-up will not be done just because the timer expires, instead it will be done 'just-in-time' when a file-access is done after the timer has expired.

Hope that makes it clearer?
I think so.

I have such a server. After 20 minutes of the all disks being idle, the server goes to sleep.

With this setting then, if the timer expires, the new wake event will be sent when I try to access files from the server again. If I don't access that server again the packet will not be sent.
Read this before using these builds.
So with t4_ravenbird's modified files I created a patch for the current master branch. With my preliminary testing things are looking good. I am not using mySQL, just the default XBMC databases. I let my server fall asleep, then tried to play a file from it. The server woke up and then played back perfectly fine.
Read this before using these builds.
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 38
  • Next 

Automatic WakeOnLan upon accessing MySql or FileShares54