Useful Scripts
From DD-WRT Wiki
(Difference between revisions)
Revision as of 15:00, 19 November 2005 (edit) 67.172.225.15 (Talk) ← Previous diff |
Revision as of 13:08, 3 December 2005 (edit) (undo) 67.172.225.15 (Talk) Next diff → |
||
Line 1: | Line 1: | ||
- | + | =WRT Scripts= | |
This page is intended to house useful scripts that help monitor or enhance the features of your linksys WRT. | 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. | |
- | == | + | ==load.sh== |
+ | * Uses Front Button LED to display current load on router. | ||
+ | |||
+ | <pre> | ||
+ | #!/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 | ||
+ | </pre> | ||
+ | |||
+ | =Remarks= | ||
+ | |||
+ | |||
+ | =Links= | ||
+ | [[Startup Scripts]] |
Revision as of 13:08, 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.
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