variable files blacklist
This commit is contained in:
parent
8a5746cb13
commit
28fba64c55
@ -2,8 +2,9 @@
|
|||||||
MAIL=/tmp/mail
|
MAIL=/tmp/mail
|
||||||
SERVER_LOG=/var/log/nginx
|
SERVER_LOG=/var/log/nginx
|
||||||
HOST=($(cat /etc/sentinel/virtualhost))
|
HOST=($(cat /etc/sentinel/virtualhost))
|
||||||
if [ ! -f /tmp/blacklist ]; then
|
BLACKLIST=/etc/sentinel/blacklist
|
||||||
touch /tmp/blacklist
|
if [ ! -f ${BLACKLIST} ]; then
|
||||||
|
touch ${BLACKLIST}
|
||||||
fi
|
fi
|
||||||
for i in ${HOST[@]}
|
for i in ${HOST[@]}
|
||||||
do
|
do
|
||||||
@ -12,11 +13,13 @@ do
|
|||||||
tail -n 50 $log_access | awk -F "|" '{ if($2 == "400") print $1}' > /tmp/400_$i
|
tail -n 50 $log_access | awk -F "|" '{ if($2 == "400") print $1}' > /tmp/400_$i
|
||||||
cat /tmp/404_$i | sort | uniq -c | awk '{ if($1 >= 5) print $2}' > /tmp/blacklist_404
|
cat /tmp/404_$i | sort | uniq -c | awk '{ if($1 >= 5) print $2}' > /tmp/blacklist_404
|
||||||
cat /tmp/400_$i |sort | uniq -c |awk '{ if($1 >= 5) print $2}' > /tmp/blacklist_400
|
cat /tmp/400_$i |sort | uniq -c |awk '{ if($1 >= 5) print $2}' > /tmp/blacklist_400
|
||||||
count=$(cat /tmp/blacklist_404 /tmp/blacklist_400 |grep -f /tmp/blacklist -v |sort |uniq |wc -l)
|
count=$(cat /tmp/blacklist_404 /tmp/blacklist_400 |grep -f ${BLACKLIST} -v |sort |uniq |wc -l)
|
||||||
if [ ${count} -ne 0 ]; then
|
if [ ${count} -ne 0 ]; then
|
||||||
cat /tmp/blacklist_400 /tmp/blacklist_404 |grep -f /tmp/blacklist -v |sort |uniq >> /tmp/blacklist
|
echo "Nouvelle IP blacklisté" > ${MAIL}
|
||||||
echo "IP blacklisté : " > ${MAIL}
|
cat /tmp/blacklist_400 /tmp/blacklist_404 |grep -f ${BLACKLIST} -v |sort |uniq >> ${MAIL}
|
||||||
cat /tmp/blacklist >> ${MAIL}
|
echo "IP dejà blacklisté : " >> ${MAIL}
|
||||||
|
cat /tmp/blacklist_400 /tmp/blacklist_404 |grep -f ${BLACKLIST} -v |sort |uniq >> /tmp/blacklist
|
||||||
|
cat ${BLACKLIST} >> ${MAIL}
|
||||||
cat ${MAIL} |mail -s "Blacklist IP ${i}" valczebackup@gmail.com
|
cat ${MAIL} |mail -s "Blacklist IP ${i}" valczebackup@gmail.com
|
||||||
fi
|
fi
|
||||||
#rm $directory_host/*
|
#rm $directory_host/*
|
||||||
|
@ -23,6 +23,6 @@ do
|
|||||||
cat $directory_host/${j}_* |sort |uniq -c >> ${MAIL}
|
cat $directory_host/${j}_* |sort |uniq -c >> ${MAIL}
|
||||||
echo "----------------" >> ${MAIL}
|
echo "----------------" >> ${MAIL}
|
||||||
done
|
done
|
||||||
cat ${MAIL} |mail -s "Rapport hebdomadaire reverse proxy $DATE" valczebackup@gmail.com
|
cat ${MAIL} |mail -s "Rapport mensuel reverse proxy ${i} $DATE" valczebackup@gmail.com
|
||||||
rm -rf $directory_host
|
rm -rf $directory_host
|
||||||
done
|
done
|
||||||
|
@ -36,6 +36,6 @@ do
|
|||||||
cat $directory_host/${j}_* |sort |uniq -c >> ${MAIL}
|
cat $directory_host/${j}_* |sort |uniq -c >> ${MAIL}
|
||||||
echo "----------------" >> ${MAIL}
|
echo "----------------" >> ${MAIL}
|
||||||
done
|
done
|
||||||
cat ${MAIL} |mail -s "Rapport hebdomadaire reverse proxy $DATE" valczebackup@gmail.com
|
cat ${MAIL} |mail -s "Rapport hebdomadaire reverse proxy ${i} $DATE" valczebackup@gmail.com
|
||||||
#rm $directory_host/*
|
#rm $directory_host/*
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user