-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from d-Rickyy-b/fail2ban_status
feat: implement full fail2ban overview
- Loading branch information
Showing
7 changed files
with
49 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
# fail2ban-client status to get all jails, takes about ~70ms | ||
jails=($(fail2ban-client status | grep "Jail list:" | sed "s/ //g" | awk '{split($2,a,",");for(i in a) print a[i]}')) | ||
|
||
out="jail,failed,total,banned,total\n" | ||
|
||
for jail in "${jails[@]}"; do | ||
# slow because fail2ban-client has to be called for every jail (~70ms per jail) | ||
status=$(fail2ban-client status "${jail}") | ||
failed=$(echo "$status" | grep -ioP '(?<=Currently failed:\t)[[:digit:]]+') | ||
totalfailed=$(echo "$status" | grep -ioP '(?<=Total failed:\t)[[:digit:]]+') | ||
banned=$(echo "$status" | grep -ioP '(?<=Currently banned:\t)[[:digit:]]+') | ||
totalbanned=$(echo "$status" | grep -ioP '(?<=Total banned:\t)[[:digit:]]+') | ||
out+="$jail,$failed,$totalfailed,$banned,$totalbanned\n" | ||
done | ||
|
||
printf "\nfail2ban status:\n" | ||
printf $out | column -ts $',' | sed -e 's/^/ /' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters