Useful Scripts
From DD-WRT Wiki
Revision as of 17:10, 5 December 2005 by 82.176.178.79 (Talk)
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=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