NAME
Monitoring::Sneck::Checks::fail2ban - checks fail2ban's jails are up, and how many are banned
VERSION
Version 0.0.1
SYNOPSIS
fail2ban|perl:fail2ban
fail2ban_mail|perl:fail2ban -j sshd -j postfix -j dovecot
fail2ban_attack|perl:fail2ban -j sshd -w 500 -c 2000
DESCRIPTION
Checks fail2ban is answering, the jails it has, and how many addresses each has banned now, through fail2ban-client status, and status for each jail.
- CRITICAL :: fail2ban not answering. A jail given with --jail not running. The banned over --critical.
- WARNING :: No jails running. The banned over --warning.
- UNKNOWN :: fail2ban-client not being there, or not being allowed to talk to fail2ban, as when not run as root.
The status line has the banned now for each jail. --warning and --critical are for those added up, as a lot banned at once can be a attack. The total failed and banned since fail2ban started are in the perfdata as well.
OPTIONS
- -j, --jail :: A jail that must be running. May be given more than once.
- -w, --warning :: Range for the banned now, of all jails.
- -c, --critical :: Range for the banned now, of all jails.
METHODS
check
Does the check.
client_status
Runs fail2ban-client with the args given, finishing the check if it fails.
- client :: The path to fail2ban-client.
- args :: The args, such as 'status' or 'status', 'sshd'.
Returns a hash ref of output, what it printed, if it worked, or of code, what finish returned, if it did not. Not being allowed to talk to fail2ban is UNKNOWN, as it is a problem with how the check is run, and anything else is CRITICAL, as fail2ban is not answering.
my $status = $check->client_status( '/usr/bin/fail2ban-client', 'status' );
return $status->{code} if defined( $status->{code} );
# $status->{output} is "Status\n|- Number of jail:\t2\n`- Jail list:\tsshd, postfix\n"