15
0
Fork 0
Browse Source

date formats are different for error and access

master
tykayn 2 years ago committed by Baptiste Lemoine
parent
commit
5de0869ed6
  1. 28
      rapport_activite/rapport_activite.sh

28
rapport_activite/rapport_activite.sh

@ -56,26 +56,27 @@ generateHTTPReport()
local monthEnglish="$1"
local year="$2"
local yearMonth="$3"
local dateLogYearMonth="$2/$4"
local errorLogFormatDate="$2/$4"
local accessLogFormatDate="$1/$2"
echo "=§= Rapport d'activité HTTP"
echo
local httpRequestCount=$(zgrep "$dateLogYearMonth" $LOG_PREFIX-access.log*|grep $year|wc -l)
local httpRequestCount=$(zgrep "$accessLogFormatDate" $LOG_PREFIX-access.log*|grep $year|wc -l)
echo "Nombre total de requêtes http = $httpRequestCount"
local trueHttpRequestCount=$(zgrep "$dateLogYearMonth" $LOG_PREFIX-access.log*|grep $year|grep -vi bot|grep -v check_http|wc -l)
local trueHttpRequestCount=$(zgrep "$accessLogFormatDate" $LOG_PREFIX-access.log*|grep $year|grep -vi bot|grep -v check_http|wc -l)
echo "Nombre de vraies requêtes http = $trueHttpRequestCount"
local botRequestCount=$(zgrep "$dateLogYearMonth" $LOG_PREFIX-access.log*|grep "$year"|grep -i bot|grep -c -v check_http)
local botRequestCount=$(zgrep "$accessLogFormatDate" $LOG_PREFIX-access.log*|grep "$year"|grep -i bot|grep -c -v check_http)
echo "Nombre de requêtes bot = $botRequestCount"
local errorRequestCount=$(zgrep "$dateLogYearMonth" $LOG_PREFIX-error.log*|grep -c "$year")
local errorRequestCount=$(zgrep "$errorLogFormatDate" $LOG_PREFIX-error.log*|grep -c "$year")
echo "Nombre de requêtes http en erreur = $errorRequestCount"
local ipv4VisitorCount=$(zgrep -h "$dateLogYearMonth" $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 "$accessLogFormatDate" $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"
local ipv6VisitorCount=$(zgrep -h "$dateLogYearMonth" $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 "$accessLogFormatDate" $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 total d'ip ayant visité le service = $((ipv4VisitorCount+ipv6VisitorCount))"
@ -100,21 +101,26 @@ generateSpecificReport()
local year="$2"
local yearMonth="$3"
local numMonth="$4"
local dateLogYearMonth="$2/$4"
local errorLogFormatDate="$2/$4"
local accessLogFormatDate="$1/$2"
# nginx shows logs like this:
# error log format:
# 2020/11/19
# 2020/11/19 20:31:05 [error] 1720#1720: *40 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.93, server: mobilizon.chapril.org, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:4000/", host: "mobilizon.chapril.org"
# access log, format :
# 26/Nov/2020
# 192.168.1.93 - - [26/Nov/2020:18:06:05 +0100] "GET / HTTP/1.1" 200 2731 "-" "check_http/v2.2 (monitoring-plugins 2.2)"
# 7d01:4f8:14b:c41::12 - - [26/Nov/2020:18:07:06 +0100] "POST /api/ HTTP/1.1" 200 238 "-" "curl/7.64.0"
echo "=§= Rapport d'activité spécifique"
echo
errorsCount=$(zgrep -h "$dateLogYearMonth" $LOG_PREFIX-error.log*|wc -l )
errorsCount=$(zgrep -h "$errorLogFormatDate" $LOG_PREFIX-error.log*|wc -l )
ipv4UserCount=$(zgrep -h "$dateLogYearMonth" $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 "$accessLogFormatDate" $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"
ipv6UserCount=$(zgrep -h "$dateLogYearMonth" $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 "$accessLogFormatDate" $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 total d'ip utilisatrices du service = $((ipv4UserCount+ipv6UserCount))"

Loading…
Cancel
Save