Automatic WakeOnLan upon accessing MySql or FileShares

  Thread Rating:
  • 4 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
t4_ravenbird Offline
Member
Posts: 98
Joined: Mar 2012
Reputation: 2
Post: #1
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'
Code:
<onaccesswakeup>
    <netinittimeout>60</netinittimeout>
    <netsettletime>500</netsettletime>
    <wakeup>
        <host>10.0.0.6</host>
        <mac>11:11:F2:11:DF:1E</mac>
        <pingport>3306</pingport>
        <pingmode>1</pingmode>
        <timeout>600</timeout>
        <waitonline>38</waitonline>
        <waitonline2>40</waitonline2>
        <waitservices>0</waitservices>
    </wakeup>
</onaccesswakeup>

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
host
ipaddress (or network name) of machine you want to wake up
mac
macaddress
pingport
default 0 which will perform ordinary icmp ping. else a 'connect' attempt will be done to the specified port
pingmode
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
(This post was last modified: 2013-05-13 13:16 by t4_ravenbird.)
find quote
vexation Offline
Senior Member
Posts: 154
Joined: Jul 2009
Reputation: 1
Post: #2
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?
find quote
t4_ravenbird Offline
Member
Posts: 98
Joined: Mar 2012
Reputation: 2
Post: #3
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.
find quote
Vascular Offline
Junior Member
Posts: 24
Joined: Aug 2009
Reputation: 0
Post: #4
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?
find quote
t4_ravenbird Offline
Member
Posts: 98
Joined: Mar 2012
Reputation: 2
Post: #5
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.
find quote
regnets Offline
Senior Member
Posts: 155
Joined: Feb 2011
Reputation: 1
Post: #6
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!
find quote
Dam0 Offline
Fan
Posts: 321
Joined: Jun 2008
Reputation: 0
Post: #7
great concept

i look forward to using it in the future
find quote
zep123 Offline
Junior Member
Posts: 8
Joined: Jan 2011
Reputation: 0
Post: #8
Absolutely brilliant, I've been waiting for this feature for a long time!
find quote
DasMarx Offline
Junior Member
Posts: 28
Joined: May 2010
Reputation: 1
Post: #9
+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.
find quote
matpol Offline
Member
Posts: 81
Joined: May 2008
Reputation: 0
Location: bournemouth, uk
Post: #10
has this been implemented?
find quote
Post Reply