see fail2ban status code example
Example: how to list banned IP ubuntu
#list all currently blocked ips:
fail2ban-client status | grep "Jail list:" | sed "s/ //g" | awk '{split($2,a,",");for(i in a) system("fail2ban-client status " a[i])}' | grep "Status\|IP list"
#unban an ip:
fail2ban-client set postfix-mail unbanip 111.222.333.444