Skip to content

Instantly share code, notes, and snippets.

@droM4X
Created March 11, 2019 16:39
Show Gist options
  • Save droM4X/f65f6f0cb5d2f1dc8177a74600ded352 to your computer and use it in GitHub Desktop.
Save droM4X/f65f6f0cb5d2f1dc8177a74600ded352 to your computer and use it in GitHub Desktop.
Collectd - fail2ban ban stats
#!/bin/bash
HOSTNAME=${COLLECTD_HOSTNAME:-localhost};
INTERVAL=${COLLECTD_INTERVAL:-60};
while sleep "$INTERVAL"
do
for q in dovecot postfix roundcube-auth sasl ssh
do
count=$(sudo fail2ban-client status $q | grep 'Currently banned' | awk '{print $(NF)}')
echo "PUTVAL \"$HOSTNAME/exec-fail2ban/gauge-fail2ban_$q\" interval=$INTERVAL N:$count"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment