#!/bin/bash ERRORFILE='/tmp/flowers_apache2.log' rm -f ${ERRORFILE} touch ${ERRORFILE} NOW=$(date +"%s") grep 'Flowers - authorization failed' /var/log/apache2/error.log | while read -r LINE; do RDT="${LINE:1:31}" DT=$(date --date="${RDT}" +"%s") (( SECS = NOW - DT )) # echo "$RDT, $DT, $NOW, $SECS" if [[ ${SECS} -lt 601 ]] ; then echo $LINE >>${ERRORFILE} IP=$(echo ${LINE} | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") addEvent.sh "BLOCK,${IP},5,5,Unauthorized authorization attempt in Flowers" fi done cat ${ERRORFILE} | wc -l