Skip to content

Instantly share code, notes, and snippets.

@tagroup
Created April 28, 2013 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tagroup/5475331 to your computer and use it in GitHub Desktop.
Save tagroup/5475331 to your computer and use it in GitHub Desktop.
#!/bin/bash
##I had greater hopes and dreams at the start
export red="gpio write 0 0"
export yellow="gpio write 1 0"
export green="gpio write 2 0"
#CLAR MEANS CLEAR!! CLAR MEANS CLEAR!! DIVE! DIVE!
export clar_red="gpio write 0 1"
export clar_yellow="gpio write 1 1"
export clar_green="gpio write 2 1"
#
#Initialize
#
log_file=/var/log/apache2/access.log
error_log_file=/var/log/apache2/error.log
((last_count=$(cat "$log_file" | wc -l) + $(cat "$error_log_file" | wc -l)))
echo ${last_count}
${green}
while true
do sleep 10
curl -s -o "/dev/null" "http://192.168.20.185"
up=$?
echo $up
if [ "$up" -eq 7 ]; then
${clar_yellow} && ${clar_green}
${red}
echo "Server Down"
else
((new_count=$(cat "$log_file" | wc -l) + $(cat "$error_log_file" | wc -l)))
echo "New:"
echo $new_count
((temp=$new_count - $last_count))
echo $temp
if [ $temp -ge 10 ] ; then
${clar_red} && ${clar_green} && ${yellow}
echo "High traffic"
else
${clar_red} && ${clar_yellow} && ${green}
echo "Clar Means Clear"
fi
last_count=$new_count
fi
done
#gpio mode 0 out && gpio mode 1 out && gpio mode 2 out
#${clar_red} && ${clar_yellow} && ${clar_green}
#
#Loop FOREVER
#
#while true
#do ${red}
#sleep 5
#${clar_red}
#${green}
#sleep 5
#${clar_green}
#${yellow}
#sleep 2
#${clar_yellow}
#done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment