A poor man Intrusion Prevention System

this script and block bad IPs even know I use modeavsive to block more then X concurrent connections from one IP my site keeps going down!

The script check if my site is down if so add the bad guy IP to my iptables and e-mail me
I adapted this script for monitoring my local site running lighttpd

Here is the script: