Blocking Brute Force Hacking attacks on your FreePBX machine

Then you have fail2ban misconfigured.

fail2ban literally does exactly what your script is doing.

Show us your fail2ban settings.

If you want to block known attackers, use APIBAN, it works great.