Useful Scripts

From DD-WRT Wiki

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

← Previous diff
Revision as of 13:15, 3 December 2005 (edit) (undo)
67.172.225.15 (Talk)

Next diff →
Line 4: Line 4:
See [[Startup Scripts]] to run scripts on router startup. See [[Startup Scripts]] to run scripts on router startup.
- +==LED Scripts==
-==load.sh==+===load.sh===
* Uses Front Button LED to display current load on router. * Uses Front Button LED to display current load on router.
Line 73: Line 73:
</pre> </pre>
-==ssh_users.sh==+===ssh_users.sh===
* Displays when someone is connected using ssh. * Displays when someone is connected using ssh.
<pre> <pre>

Revision as of 13:15, 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

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=0 
interval=5 

/sbin/gpio enable 2 

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 2 
          led=1 
      fi 
   else 
      if [ $led -eq 1 ]; then 
          /sbin/gpio enable 2 
          led=0 
      fi 
   fi 

done

Remarks

Links

Startup Scripts