1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

tomato scheduler custom script

Discussion in 'Tomato Firmware' started by rs232, Jul 10, 2009.

  1. rs232

    rs232 Network Guru Member

    Hello everybody!
    I'm trying to run this 4 lines every 30 minutes using the custom scripts under administration/scheduler

    ping -c 3 www.google.com
    if [[ $? -ne 0 ]]; then
    reboot
    fi

    (reboor the box if google is not reachable)

    It does work if I copy and paste on the console (ssh) but doesn't seem to be working automatically... nor I get anything in the log file.
    Do I need to add/remove anything?

    Cheers
    rs232
     
  2. Planiwa

    Planiwa LI Guru Member

    ping -c3 google.com >/dev/null || reboot
     
  3. fyellin

    fyellin LI Guru Member

    This may be slightly off topic, but why do you want to reboot if you can't reach google. If my experience is any guide, it's more likely that either Comcast is down (again) or else their DNS server. The number of times that rebooting my router fixed the problem is close to 0.

    Is there something about your setup such that you expect a reboot to fix an upstream problem?
     
  4. Planiwa

    Planiwa LI Guru Member

    Came close to saying this myself. I can think of several possible reasons for not being able to ping google:

    1. phone line problem
    2. DSL line problem
    3. DSL modem problem
    4. AC problem
    5. PPP server side problem
    6. Routing problem
    7. DNS problem
    8. Contention/Congestion problem
    9. Ping-denial problem (perhaps in response to DOS attack,etc.)
    10. router is stuck in a state where it still runs scheduled commands, but won't run renew PPP or whatever. (?)
    . . .

    Still, there is the purely technical side of the question -- one should be able to test with less drastic command than reboot:

    ping -c3 google.com >/dev/null || logger not really reboot
     
  5. anik

    anik Addicted to LI Member

    Well, I don't know about the OP, but what I'd like to be able to do is this (note I'm using the OpenVPN client, NOT the server, on the Tomato router): At five minute intervals, ping the OpenVPN SERVER (through the tunnel) to make sure there is still a connection to the server. If the ping fails, then sleep for a period of time (probably half an hour) to see if the problem will resolve itself (in case it's a momentary network failure, or we had to restart the server or something). Try pinging the server again (after the interval). If that fails, it's probably time to try rebooting the router, so do that. Repeat until the server comes back (although ideally there should probably be a limit on the number of retries - you don't want the router to keep rebooting from now until infinity. In fact, ideally I'd lengthen the reboot interval after each failed attempt - e.g. after the first reboot, wait an hour and try again, then wait three hours and try again, then six hours, then 12 hours, then a full day, and after that just give up and wait until someone does a manual reboot after the server problem is fixed). But I cannot for the life of me understand why anyone would reboot based on whether Google can be pinged!
     
  6. Planiwa

    Planiwa LI Guru Member

    In my experience --

    the probability that "failure to ping X" indicates a problem that a router reboot fixes, for:

    [1] X == google: 0%
    [2] X == a (wifi) connected LAN host: 100%

    I have used a "canping" script that does this, including waiting 1/2 hour to see if it persists, syslogging and alerting admin (over the Net), before taking action.

    We should be carefull that such scripts don't bite us while we are in the process making deliberate changes . . . :)
     
  7. rs232

    rs232 Network Guru Member

    I've finally identified the problem. Actually I don't want to reboot the tomato (which I'm using as a wireless client right now), but I'd like to use wget to call the reboot page of the main access point which get stuck randomly. To do so I'll ping the local Lan (192.168.1.1) address of the ADSL modem. NOTE int this case ADSL and Access point (192.168.1.5) are different devices.What do you think of this:

    cd /tmp/home/root/ ; rm reboot.htm ; ping -c3 192.168.1.1 >/dev/null || wget http://admin:admin@192.168.1.5/reboot.htm

    Used from the shell it works. BTW I have to remove the reboot.htm as this it's saved locally so the second time you run the script wget would otherwhise complains that the destination page already exists.

    How can I verify if it works from the gui too? Will anything be written on the tomato log?
     
  8. andlil

    andlil Addicted to LI Member

    Use

    Code:
    wget -O /dev/null [url]http://admin:admin@192.168.1.5/reboot.htm[/url]
    and you won't have to delete the reboot.htm every time....

    If it works the device intended will reboot :)

    //A
     
  9. rs232

    rs232 Network Guru Member

    Excellent this is my final scripts I'm testing it pinging an address in internet from my laptop at the same time I'm running this on tomato. If I change the following script trying to ping the LAN address 192.168.1.8 (which doesn't exsists) I can see the ping going to internet failing for 30 seconds (time to reboot the access point)

    Code:
    ping -c3 192.168.1.1 >>/dev/null || wget -O - [url]http://admin:admin@192.168.1.5/reboot.htm[/url] >>/dev/null

    Thanks!
     

Share This Page