Page 1 of 1

Send WOL when no response ping

Posted: Sun Sep 19, 2010 10:00 am
by joz
---UPDATE---
Nevermind what I thought up below I have looked a bit further into network receiver/sender and setup a solution dependent on that, seems to do the job well so far I've tested (which is not a lot yet). Did find that when I set a password for the sender/receiver I had an MD5 checksum error (password was 100% correct, both sides), no password works.
--------------



Hi all,

I'm totally unfamiliar with python, so excuse my noobishness :)
What I'm trying to accomplish is the following scenario;
I have a NAS (well, just a desktop) that goes to sleep. I run MediaPortal on my HTPC and it loads stuff of the NAS but ofcourse can't while it's asleep. Now to overcome some issues with MP I would like to be able to ping my NAS when I press play. If I do not get an answer I (in a second or so) I want eventghost to send a wol to the nas first, then wait a couple seconds (I think 10 would be fine) and then fire play to MP.
If it receive a response to the ping it can play immediatly.

I have found some script that pings and looks for the response, seemed like a nice start. Can't get it to go though cause it's chokin' on re.search, no clue why. This does nothing else yet, just trying something first, if I can't get this to go myself it's kinda hopeless :) Might have to dig into python a lot more.
Any help getting there would be awesome!

Code: Select all

import re
from subprocess import Popen, PIPE
from threading import Thread

print 'starting'
class Pinger(object):
    def __init__(self, hosts):
        for host in hosts:
            pa = PingAgent(host)
            pa.start()
        
class PingAgent(Thread):
    def __init__(self, host):
        Thread.__init__(self)        
        self.host = host

    def run(self):
        p = Popen('ping -n 1 ' + self.host, stdout=PIPE)
        m = re.search('Gemiddelde = (.*)ms', p.stdout.read())
        if m: print 'Round Trip Time: %s ms -', p.stdout.read(), self.host
        else: print  'Error: Invalid Response -', self.host
              
                             

hosts = [
    '192.168.1.30'
   ]
Pinger(hosts)
p.s.
I also though about not having the timeout for the NAS to wake but using the network sender/receiver, so the NAS will send an event to the HTPC when it's set to go.

Re: Send WOL when no response ping

Posted: Mon Oct 11, 2010 3:35 pm
by bskchaos
Interesting.

I created a very simple page and use EG to handle a WOL utility.
I will check your script to leech some ideas.

Re: Send WOL when no response ping

Posted: Thu Oct 21, 2010 9:32 am
by miljbee
I wrote a ping plugin :

You can get it here : http://www.eventghost.org/forum/viewtop ... f=9&t=2318

There is two different version.

I you just plan to ping on demand, I would recommand you to get the first realease.

Just have a look at the readme of the two versions to choose the one you need by yourself.

Regards,