Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Created April 24, 2017 03:38
Show Gist options
  • Select an option

  • Save ahmadawais/840098791653a4973a84e27b8451469e to your computer and use it in GitHub Desktop.

Select an option

Save ahmadawais/840098791653a4973a84e27b8451469e to your computer and use it in GitHub Desktop.
Print status for all fail2ban jails.
# Print status for all fail2ban jails.
function f2bstall() {
JAILS=($(fail2ban-client status | grep "Jail list" | sed -E 's/^[^:]+:[ \t]+//' | sed 's/,//g'))
for JAIL in ${JAILS[@]}
do
echo "--------------- ๐Ÿ‘€ JAIL STATUS: $JAIL ... ---------------"
fail2ban-client status $JAIL
echo "--------------- ... ---------------"
done
}
@keinwort
Copy link

nice on. loving the eyes ;-)

@RobinEd
Copy link

RobinEd commented Nov 28, 2025

Just added a tiny bit more detail :)

#!/bin/bash

# Print status for all fail2ban jails.
  JAILS=($(fail2ban-client status | grep "Jail list" | sed -E 's/^[^:]+:[ \t]+//' | sed 's/,//g'))
  for JAIL in ${JAILS[@]}
  do
    echo "--------------- ๐Ÿ‘€  JAIL STATUS: $JAIL ... ---------------"
    fail2ban-client status $JAIL
    echo "bantime: "`fail2ban-client get $JAIL bantime`
    echo "findtime: "`fail2ban-client get $JAIL findtime`
    echo "maxretry: "`fail2ban-client get $JAIL maxretry`

    echo "--------------- ... ---------------"
  done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment