Useful Scripts

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 13:38, 3 December 2005 (edit)
67.172.225.15 (Talk)

← Previous diff
Revision as of 13:43, 3 December 2005 (edit) (undo)
67.172.225.15 (Talk)
(ssh_users.sh)
Next diff →
Line 93: Line 93:
#!/bin/sh #!/bin/sh
-led=0 +led=2
 +on=0
interval=5 interval=5
-/sbin/gpio enable 2 +/sbin/gpio enable $led
while sleep $interval while sleep $interval
Line 104: Line 105:
if [ $users -gt 0 ]; then if [ $users -gt 0 ]; then
if [ $led -eq 0 ]; then if [ $led -eq 0 ]; then
- /sbin/gpio disable 2 + /sbin/gpio disable $led
- led=1 + on=1
fi fi
else else
if [ $led -eq 1 ]; then if [ $led -eq 1 ]; then
- /sbin/gpio enable 2 + /sbin/gpio enable $led
- led=0 + on=0
fi fi
fi fi

Revision as of 13:43, 3 December 2005

Contents

WRT Scripts

This page is intended to house useful scripts that help monitor or enhance the features of your linksys WRT.

See Startup Scripts to run scripts on router startup.

LED Scripts

GPIO Info

Pin	Direction	Name		Use
GPIO 0	Output		WLAN LED	(LED - Wireless)
GPIO 1	Output		POWER LED	(LED - Power)
GPIO 2	Output		ADM_EECS 	(LED - White, Cisco Button V3.0+)
GPIO 3	Output		ADM_EESK 	(LED - Amber, Cisco Button V3.0+)
GPIO 4	Input		ADM_EEDO 	(Button - Cisco Button V3.0+)
GPIO 5	Output		ADM_EEDI 	(Unknown)
GPIO 6	Input		RESET		(Button - Reset Button)
GPIO 7	Output		DMZ LED		(LED - DMZ)


load.sh

  • Uses Front Button LED to display current load on router.
#!/bin/sh
gpio="gpio"

amber=3
white=2

delay=3

meltdown=400
overload=100
highload=70
medload=30


while sleep $delay
do
   load=$(cat /proc/loadavg | cut -d " " -f1 | tr -d ".")

   if [ $load -gt $meltdown ]
   then
       $gpio disable $amber
       usleep 50000
       $gpio disable $white
       usleep 50000
       reboot
   elif [ $load -gt $overload ]
   then
      $gpio disable $amber
      usleep 50000
   elif [ $load -gt $highload ]
   then
      $gpio disable $amber
      usleep 12500
      $gpio enable $amber
      usleep 12500
      $gpio disable $amber
      usleep 12500
      $gpio enable $amber
      usleep 12500
      $gpio disable $amber
      usleep 12500
      $gpio enable $amber
      usleep 12500
   elif [ $load -gt $medload ]
   then
      $gpio enable $amber
      $gpio disable $white
      usleep 25000
      $gpio enable $white
      usleep 25000
      $gpio disable $white
      usleep 25000
      $gpio enable $white
      usleep 25000
   else
      $gpio disable $white
      usleep 50000
      $gpio enable $white
      usleep 50000
   fi
    load=000
done

ssh_users.sh

  • Displays when someone is connected using ssh.
#!/bin/sh 

led=2
on=0
interval=5 

/sbin/gpio enable $led 

while sleep $interval 
do 
   users=$(/bin/netstat -n | /bin/grep :22 | /usr/bin/wc -l) 

   if [ $users -gt 0 ]; then 
      if [ $led -eq 0 ]; then 
          /sbin/gpio disable $led
          on=1 
      fi 
   else 
      if [ $led -eq 1 ]; then 
          /sbin/gpio enable $led
          on=0 
      fi 
   fi 

done

Remarks

Links

Startup Scripts