From 0b614d02a8921ac2bb62f46c1d5f6967219ea5bc Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 22 Jan 2023 21:23:34 +0100 Subject: [PATCH] get info per week --- roles/deploy-web/files/getinfo_week.sh | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 roles/deploy-web/files/getinfo_week.sh diff --git a/roles/deploy-web/files/getinfo_week.sh b/roles/deploy-web/files/getinfo_week.sh new file mode 100755 index 0000000..ad22593 --- /dev/null +++ b/roles/deploy-web/files/getinfo_week.sh @@ -0,0 +1,36 @@ +#!/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) + 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 + echo "nombre erreur 400 par IP : " >> ${MAIL} + cat $log_access | awk -F "|" '{ if($2 == "400") print $1}' |sort |uniq -c >> ${MAIL} + echo "--------" >> ${MAIL} + echo "nombre erreur 404 par IP : " >> ${MAIL} + cat $log_access | awk -F "|" '{ if($2 == "404") print $1}' |sort |uniq -c >> ${MAIL} + cat ${MAIL} |mail -s "Rapport reverse proxy $DATE" valczebackup@gmail.com + #rm $directory_host/* +done