#!/bin/sh

#Set GPIO to the GPIO of the LED you wish to use. Default is 7 for DMZ LED on most routers..
GPIO=7
#Set the delay for how often the led should blink. default is 5 seconds.
DELAY=5
HIGHLOAD=400
MEDLOAD=300

while sleep $DELAY
do
   load=$(cat /proc/loadavg | cut -d " " -f1 | tr -d ".")
#load=$(cat /proc/loadavg)
    if [ "$load" -gt "$HIGHLOAD" ]
    then
       	gpio disable $GPIO
	usleep 125000
	gpio enable $GPIO
	usleep 125000
	gpio disable $GPIO
	usleep 125000
	gpio enable $GPIO
	usleep 125000
	gpio disable $GPIO
	usleep 125000
	gpio enable $GPIO
	usleep 125000
   echo $load

    elif [ "$load" -gt "$MEDLOAD" ]
    then
    	gpio disable $GPIO
	usleep 250000
	gpio enable $GPIO
	usleep 250000
	gpio disable $GPIO
	usleep 250000
	gpio enable $GPIO
	usleep 250000

    else 
    	gpio disable $GPIO
	usleep 500000
	gpio enable $GPIO
	usleep 500000
    fi
    
load=000
done 