Check internet connectivity and automatic router power-cycle

Posted on
Wed Jul 09, 2014 6:16 pm
jheddings offline
User avatar
Posts: 111
Joined: Dec 01, 2013
Location: Denver, CO

Check internet connectivity and automatic router power-cycle

Just wanted to post a quick script I'm using to check my internet connection. I have my router on an ApplianceLinc and when the "online" variable hits "false", Indigo happily turns power to the router off then on after 10 seconds. The script runs on a schedule every 5 minutes, along with a crude locking mechanism on a status variable. I'd welcome any feedback on this solution!

Schedule:
- every 5 minutes

Conditions:
- variable "check_internet_status" is not equal to "running..."

Actions:
- set "check_internet_status" to "running..."
- execute external script "check_internet.py"

Note: the script will set "check_internet_status" to something else when it is complete, thus "unlocking" the condition.
Attachments
check_internet.py.txt
Python script to check internet connection.
(1.37 KiB) Downloaded 191 times

Posted on
Wed Jul 09, 2014 6:58 pm
kw123 offline
User avatar
Posts: 6583
Joined: May 12, 2013
Location: Dallas, TX

Re: Check internet connectivity and automatic router power-c

I would add first the router itself and then the cable modem or alike. The cable modem very likely has the ip number 192.168.1.00

Posted on
Wed Jul 09, 2014 7:03 pm
jay (support) offline
Site Admin
User avatar
Posts: 15690
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Check internet connectivity and automatic router power-c

Nice! Thanks for the contribution.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 09, 2014 7:41 pm
berkinet offline
User avatar
Posts: 3359
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Check internet connectivity and automatic router power-c

kw123 wrote:
I would add first the router itself and then the cable modem or alike. The cable modem very likely has the ip number 192.168.1.00

Actually, for a Netmask of 255.255.255.0, 192.168.1.00 would be the network number and not the address of a device on the network. Typically the router address would be .1 or .254. Ex. 192.168.1.1, 92.168.1.254, 10.0,0.1, etc.

Posted on
Wed Jul 09, 2014 11:45 pm
kw123 offline
User avatar
Posts: 6583
Joined: May 12, 2013
Location: Dallas, TX

Re: Check internet connectivity and automatic router power-c

correction: the modem address is 192.168.100.1 (ip number B)... that is not the external ip number the internet sees!

cable -- [ ipnumberA modem IP numberB] --- [router] --- your network 192.168.1.x

if you like to ping the modem from the inside use the 192.168.100.1 address
that actually works.

at least with charter and you can see the modem setup, noise and signal levels etc.

Karl

Posted on
Thu Jul 10, 2014 3:02 am
FlyingDiver offline
Posts: 3464
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Check internet connectivity and automatic router power-c

kw123 wrote:
correction: the modem address is 192.168.100.1 (ip number B)... that is not the external ip number the internet sees!

cable -- [ ipnumberA modem IP numberB] --- [router] --- your network 192.168.1.x

if you like to ping the modem from the inside use the 192.168.100.1 address
that actually works.

at least with charter and you can see the modem setup, noise and signal levels etc.

Karl


That's not a standard numbering system, it's unique to your ISP at your location. I'm on Charter in Michigan right now, and that's not the modem IP for me. I've only had one other ISP that used that network numbering system, and it was a satellite internet setup.

It's usually pretty easy to find the IP address of your modem if you look at the web admin pages of your router. But that number can usually change every time the router or modem reboots.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Jul 10, 2014 9:58 am
jheddings offline
User avatar
Posts: 111
Joined: Dec 01, 2013
Location: Denver, CO

Re: Check internet connectivity and automatic router power-c

Thanks for the feedback on this... I did consider checking the router first with a simple ping, however going to the web directly solves all the problems of specific IP configurations, multiple routers / modems on the network, etc. This script is really looking for internet access, so that keeps things simple.

I could definitely see use for another script (or combined with this one) to check that internal systems are also up and running. I'll keep that in mind and update here if I make any changes.

Posted on
Thu Jul 10, 2014 10:41 am
berkinet offline
User avatar
Posts: 3359
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Check internet connectivity and automatic router power-c

jheddings wrote:
Thanks for the feedback on this... ...This script is really looking for internet access, so that keeps things simple...

Just a thought... Since your goal is just to check Internet access, could you simplify the test to just ping something on your ISP's network? For example, if I do a trace route from my Mac to some arbitrary location I get something like...
Code: Select all
rdp$ trace route google.com
traceroute to google.com (173.194.40.137), 64 hops max, 52 byte packets
 1  192.168.5.1 (192.168.5.1)  0.745 ms  0.379 ms  0.384 ms
 2  82.246.6.254 (82.246.6.254)  24.990 ms  24.657 ms  23.578 ms
 3  78.254.8.254 (78.254.8.254)  24.254 ms  25.036 ms  25.708 ms
 4  marseille-6k-1-v806.intf.routers.proxad.net (212.27.59.170)  28.827 ms  27.704 ms  27.815 ms
...
The second hop, 82.246.6.254, is on my ISP's side of my ADSL line. So, as long as I can reach that I am, at least, good on my side - any problems are on my ISP's side.

Then this simple ` line shell command will return 0 if at least one of the 10 ping attempts gets through:
Code: Select all
ping -qc 10 82.246.6.254 >/dev/null 2>&1;RC=$?;echo $RC
and non-zero if all 10 fail.

Posted on
Sun Oct 06, 2019 5:57 pm
thomasw offline
Posts: 129
Joined: Feb 13, 2011

Re: Check internet connectivity and automatic router power-c

Hi, I am trying to do the same thing.
In my case, the Verizon DSL modem disconnects for no known reason from time to time. I have to unplug it for a minute or two, then plug it back in, and it restores the internet.
I'm going on a trip, and I can't access anything with Indigo on my phone if there is no internet connection at home.
I want to just add a python script that will check either the online status somehow or check if Reflector is connected, and if internet is not connected, just have the script tell indigo to turn off/ and then back on a Leviton Z-wave appliance linc I have the modem plugged into. I would like this to have a delay of about 2 min before turning the appliance linc back on.
I have no idea how to write this and add it.
Please help! -Thanks
Oh, I'm still running Indigo Pro 6.1.8 because I haven't moved Indigo over to my newer imac yet.

Posted on
Sun Oct 06, 2019 6:06 pm
FlyingDiver offline
Posts: 3464
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Check internet connectivity and automatic router power-c

thomasw wrote:
Hi, I am trying to do the same thing.
In my case, the Verizon DSL modem disconnects for no known reason from time to time. I have to unplug it for a minute or two, then plug it back in, and it restores the internet.
I'm going on a trip, and I can't access anything with Indigo on my phone if there is no internet connection at home.
I want to just add a python script that will check either the online status somehow or check if Reflector is connected, and if internet is not connected, just have the script tell indigo to turn off/ and then back on a Leviton Z-wave appliance linc I have the modem plugged into. I would like this to have a delay of about 2 min before turning the appliance linc back on.
I have no idea how to write this and add it.
Please help! -Thanks
Oh, I'm still running Indigo Pro 6.1.8 because I haven't moved Indigo over to my newer imac yet.


See if this plugin does what you need: http://www.indigodomo.com/pluginstore/90/

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest