2023-01-22 21:23:34 +01:00
|
|
|
#!/bin/bash
|
|
|
|
MAIL=/tmp/mail_week
|
|
|
|
DIRECTORY=/home/valentin/mail
|
|
|
|
SERVER_LOG=/var/log/nginx
|
|
|
|
TOKEN=af920d2f7dbe97
|
|
|
|
DATE=$(date +%Y%m%d-%H%M%S)
|
|
|
|
HOST=($(cat /etc/sentinel/virtualhost))
|
|
|
|
WEEK=$(date +%V)
|
|
|
|
DAY=$(date +%u)
|
|
|
|
if [ ${DAY} -eq 1 ]; then
|
|
|
|
if [ ${WEEK} -ne "01" ]; then
|
|
|
|
WEEK=$(echo "$WEEK-1" |bc)
|
2023-01-23 23:45:51 +01:00
|
|
|
if [ ${#WEEK} -eq 1 ]; then
|
|
|
|
WEEK="0${WEEK}"
|
|
|
|
fi
|
2023-01-22 21:23:34 +01:00
|
|
|
else
|
|
|
|
WEEK="53"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
for i in ${HOST[@]}
|
|
|
|
do
|
|
|
|
directory_host=$DIRECTORY/$i/$WEEK
|
|
|
|
echo "nombre de visite : $(wc -l $directory_host/list_* |tail -n1 | awk '{print $1}')" > ${MAIL}
|
|
|
|
echo "nombre de visite par pays, par region et par ville : " >> ${MAIL}
|
|
|
|
LIST=("country" "region" "city")
|
|
|
|
for j in ${LIST[@]}
|
|
|
|
do
|
|
|
|
echo "----${j}------" >> ${MAIL}
|
|
|
|
cat $directory_host/output_*.txt |grep "${j}" |sort |uniq -c >> ${MAIL}
|
|
|
|
echo "--------------" >> ${MAIL}
|
|
|
|
done
|
2023-01-22 21:28:39 +01:00
|
|
|
ERROR=("400" "404")
|
|
|
|
for j in ${ERROR[@]}
|
|
|
|
do
|
|
|
|
echo "nombre erreur ${j} par IP :" >> ${MAIL}
|
|
|
|
cat $directory_host/${j}_* |sort |uniq -c >> ${MAIL}
|
|
|
|
echo "----------------" >> ${MAIL}
|
|
|
|
done
|
2023-02-02 23:35:06 +01:00
|
|
|
cat ${MAIL} |mail -s "Rapport hebdomadaire reverse proxy ${i} $DATE" valczebackup@gmail.com
|
2023-01-22 21:23:34 +01:00
|
|
|
#rm $directory_host/*
|
|
|
|
done
|