#!/usr/bin/env bash # # Get list of fail2ban jails and print status of each # # SPDX-License-Identifier: MIT # fail2ban-client requires root if [[ $(id -u) -ne 0 ]]; then echo "Must run as root user" exit 1 fi ## there's a tab after "list:" ## fail2ban-client status -> # Status # |- Number of jail: 3 # `- Jail list: nginx-4xx, nginx-limit-req, sshd JAILS=$(fail2ban-client status | \ awk -F: '/list/{gsub(/, /," ",$2);gsub(/^[ \t]+/,"",$2);print $2}' ) for jail in ${JAILS}; do fail2ban-client status "${jail}" done