LED indication status of the internet connection

Check ping on the gateway, DNS servers and an IP address on the Internet.
The status is indicated by the colour of the led WAN, LAN and PCI (wifi) .
WAN led is turned continuously when the error condition, if the connection is OK, the led blinks in auto -mode. (The color settings of the normal State agrees with by setting the LED colors in LuCI Rainbow.)

It is certainly possible to indicate a network error only with the LED colour of the wan. The function of each State, you can check the temporary removal of the character the negation of “!”.

Logical flowchart

Similarly, the schema of LED color warning

/etc/cron.d/leds-control

# zmena intensity svetla den - noc 
15 07 * * * root rainbow intensity 6
00 10 * * * root rainbow intensity 15
30 15 * * * root rainbow intensity 6
30 17 * * * root rainbow intensity 1
# check every minute
#*  *  * * * root /root/connCheck.sh > /dev/null 2>&1
# check every 3 minute
*/3  *  * * * root /root/connCheck.sh > /dev/null 2>&1 

/root/connCheck.sh - EDITED 1.2.2017 … fixed a bug in the IF - condition … has been added in parenthesis in the negated condition (former if !ping xxxx … is BAD)

#!/bin/sh
# check the connection to the Internet

rainbow pwr disable
sleep 1

# --- indications of activity ---
rainbow pwr D000F0 enable
sleep 0.5
rainbow pwr disable
sleep 0.5

rainbow pwr D000F0 enable
sleep 0.5
rainbow pwr disable
sleep 0.5

rainbow pwr D000F0 enable
sleep 0.5
rainbow pwr disable
sleep 0.5

rainbow pwr D000F0 enable
sleep 0.5
rainbow pwr disable
sleep 0.5

rainbow pwr D000F0 enable
sleep 0.5
rainbow pwr disable
sleep 1

rainbow pwr 4d0000 enable

# --- check connection gateway, dns, internet ---

# check gateway  - wan, lan, pci - red b50000 
if !(ping -c 1 10.109.54.193)
then
    rainbow wan b50000 enable
    rainbow lan b50000 enable
    rainbow pci2 b50000 enable
    rainbow pci3 b50000 enable;

# check DNS - wan, lan -  orange db4e00
elif !(ping -c 1 10.108.10.108) && !(ping -c 1 8.8.8.8)
then
    rainbow wan db4e00 enable
    rainbow lan db4e00 enable
    rainbow pci2 216300 auto
    rainbow pci3 216300 auto;

# check internet - wan, pci - purple d000f0
elif !(ping -c 1 213.192.1.145)
    then
    rainbow wan d000f0 enable
    rainbow lan 4e4d0e auto
    rainbow pci2 d000f0 enable
    rainbow pci3 d000f0 enable;

# if all ready - standard color
else
    rainbow wan 0118e4 auto
    rainbow lan 4e4d0e auto
    rainbow pci2 216300 auto
    rainbow pci3 216300 auto;
fi
6 Likes

Does anybody adjusted this scrips for Turris Omnia? or if it should work for TO, is there anybody with working script?

I don’t know where you see a problem, could you be more specific? The code above is working and tested.

The problem is that cron is sensitive to spaces, tabs and symbols for newlines et cetera. File is best in the SSH environment needs to be created - for example Midnight commander or other text editor. Files created in Windows do not work.

I tried to copy/paste your code in ubuntu, but no success. Would you be so kind and share your working files? (I will then just replace my GW and DNS IPs directly in Omnia using vi editor). Many thanks in advance.

Yes - send email via private message