From 8e2211e365e8b62b68a5d229fa8473b6c5484ac3 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 23 Jan 2023 23:56:58 +0100 Subject: [PATCH] add month stat --- roles/deploy-web/files/getinfo_month.sh | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 roles/deploy-web/files/getinfo_month.sh diff --git a/roles/deploy-web/files/getinfo_month.sh b/roles/deploy-web/files/getinfo_month.sh new file mode 100755 index 0000000..f8c0f0f --- /dev/null +++ b/roles/deploy-web/files/getinfo_month.sh @@ -0,0 +1,28 @@ +#!/bin/bash +MAIL=/tmp/mail_week +DIRECTORY=/home/valentin/mail +SERVER_LOG=/var/log/nginx +DATE=$(date +%Y%m%d-%H%M%S) +HOST=($(cat /etc/sentinel/virtualhost)) +for i in ${HOST[@]} +do + directory_host=$DIRECTORY/$i/* + 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 + 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 + cat ${MAIL} |mail -s "Rapport hebdomadaire reverse proxy $DATE" valczebackup@gmail.com + rm -rf $directory_host +done