Jump to content

Mkiv Led Connectivity Indicator


kmyths
 Share

Recommended Posts

Hey All,

This is just a simple script I wrote to help troubleshoot, maybe someone will find it useful.

It pings two IP addresses, then turns on or off the unused LAN/WAN LEDs based on the result.

This code runs an infinite loop, DO NOT add directly to rc.local.

#!/bin/sh
# Turn LEDs on/off based on network connectivity
# $LAN_HOST controls Lan LED, $WAN_HOST controls Wan LED 
#
WAN_HOST="8.8.8.8"   # Wan host to ping
LAN_HOST="172.16.42.42"   # Lan host to ping
################
WAN_LED="/sys/devices/platform/leds-gpio/leds/alfa:blue:wan/brightness"
LAN_LED="/sys/devices/platform/leds-gpio/leds/alfa:blue:lan/brightness"
while : ; do
	LAN_CHK=`ping -c 1 -w 4 $LAN_HOST | grep received | cut -d ' ' -f4`
	WAN_CHK=`ping -c 1 -w 4 $WAN_HOST | grep received | cut -d ' ' -f4`
	WAN_LED_CHK=`cat $WAN_LED`
	LAN_LED_CHK=`cat $LAN_LED`

	# Check Wan Connection
	if [ $WAN_CHK == 0 ] ; then
		if [ $WAN_LED_CHK == 1 ]; then
			echo 0 > $WAN_LED
		fi
	else
		if [ $WAN_LED_CHK == 0 ]; then
			echo 1 > $WAN_LED
		fi
	fi
	# Check Lan Connection
	if [ $LAN_CHK == 0 ] ; then
		if [ $LAN_LED_CHK == 1 ]; then
			echo 0 > $LAN_LED
		fi
	else
		if [ $LAN_LED_CHK == 0 ]; then
			echo 1 > $LAN_LED
		fi
	fi
	sleep 2
done

Link to comment
Share on other sites

Neat little script, thanks! this will be handy for squeezing all the juice we can out our pineapples :D, would be cool if this could also be a module with auto start, lets face it we dont really need to see and of the leds when we are, "pen testing" lol

- Anton.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...