add correct log prefix

This commit is contained in:
tykayn 2020-11-20 09:10:14 +01:00 committed by Baptiste Lemoine
parent ac4e6cfcef
commit 090af318f5

View File

@ -18,11 +18,12 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# # access_log /var/log/nginx/mobilizon.chapril.org/mobilizon.chapril.org-access.log
# error_log /var/log/nginx/mobilizon.chapril.org/mobilizon.chapril.org-error.log
# ============================================ # ============================================
LOG_PREFIX="/var/log/apache2/mobilizon.chapril.org/mobilizon.chapril.org" LOG_PREFIX="/var/log/nginx/mobilizon.chapril.org/mobilizon.chapril.org"
SERVICE_NAME="mobilizon.chapril.org" SERVICE_NAME="mobilizon.chapril.org"
source "/etc/mobilizon.chapril.org/mobilizonchaprilorg.conf" source "/etc/mobilizon.chapril.org/mobilizonchaprilorg.conf"
@ -48,7 +49,7 @@ generateHTTPReport()
echo "=§= Rapport d'activité HTTP" echo "=§= Rapport d'activité HTTP"
echo echo
local httpRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep $year|wc -l) local httpRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep $year|wc -l)
echo "Nombre total de requêtes http = $httpRequestCount" echo "Nombre total de requêtes http = $httpRequestCount"
@ -63,7 +64,7 @@ generateHTTPReport()
local ipv4VisitorCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV4_PATTERN "|cut -d' ' -f1|sort|uniq|wc -l ) local ipv4VisitorCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV4_PATTERN "|cut -d' ' -f1|sort|uniq|wc -l )
echo "Nombre d'ipv4 ayant visité le service = $ipv4VisitorCount" echo "Nombre d'ipv4 ayant visité le service = $ipv4VisitorCount"
local ipv6VisitorCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV6_PATTERN "|cut -d' ' -f1|sort|uniq|wc -l ) local ipv6VisitorCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV6_PATTERN "|cut -d' ' -f1|sort|uniq|wc -l )
echo "Nombre d'ipv6 ayant visité le service = $ipv6VisitorCount" echo "Nombre d'ipv6 ayant visité le service = $ipv6VisitorCount"
@ -84,12 +85,12 @@ generateSpecificReport()
ipv4UserCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV4_PATTERN " | cut -d' ' -f 1|sort|uniq|wc -l ) ipv4UserCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV4_PATTERN " | cut -d' ' -f 1|sort|uniq|wc -l )
echo "Nombre d'ipv4 utilisatrices du service = $ipv4UserCount" echo "Nombre d'ipv4 utilisatrices du service = $ipv4UserCount"
ipv6UserCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|gre\p -v check_http|egrep "^$IPV6_PATTERN " | cut -d' ' -f 1|sort|uniq|wc -l ) ipv6UserCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|gre\p -v check_http|egrep "^$IPV6_PATTERN " | cut -d' ' -f 1|sort|uniq|wc -l )
echo "Nombre d'ipv6 utilisatrices du service = $ipv6UserCount" echo "Nombre d'ipv6 utilisatrices du service = $ipv6UserCount"
echo "Nombre total d'ip utilisatrices du service = $((ipv4UserCount+ipv6UserCount))" echo "Nombre total d'ip utilisatrices du service = $((ipv4UserCount+ipv6UserCount))"
echo echo
echo echo
} }
@ -136,7 +137,7 @@ elif [ "$#" -eq 2 ]; then
elif ! (let "$2") 2>/dev/null; then elif ! (let "$2") 2>/dev/null; then
echo -e "L'année doit être numérique." echo -e "L'année doit être numérique."
help help
elif [ "$2" -lt 2018 ] || [ "$2" -gt "$(date +%Y)" ]; then elif [ "$2" -lt 2018 ] || [ "$2" -gt "$(date +%Y)" ]; then
echo -e "Année non valable $2." echo -e "Année non valable $2."
help help
elif [ "$2" -le 2017 ] || [ "$2" -ge $(($(date +%Y)+1)) ] ; then elif [ "$2" -le 2017 ] || [ "$2" -ge $(($(date +%Y)+1)) ] ; then
@ -147,7 +148,7 @@ elif [ "$#" -eq 2 ]; then
yearMonth="$2-0$1" yearMonth="$2-0$1"
else else
yearMonth="$2-$1" yearMonth="$2-$1"
fi fi
monthEnglish=$(LANG=en_EN.UTF-8;date -d "$2-$1-01" +%b) monthEnglish=$(LANG=en_EN.UTF-8;date -d "$2-$1-01" +%b)
year="$2" year="$2"
generateReport "$monthEnglish" "$year" "$yearMonth" generateReport "$monthEnglish" "$year" "$yearMonth"