15
0
Fork 0
Browse Source

add correct log prefix

master
tykayn 2 years ago committed by Baptiste Lemoine
parent
commit
090af318f5
  1. 17
      rapport_activite/rapport_activite.sh

17
rapport_activite/rapport_activite.sh

@ -18,11 +18,12 @@
#
# 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/>.
#
# 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"
source "/etc/mobilizon.chapril.org/mobilizonchaprilorg.conf"
@ -48,7 +49,7 @@ generateHTTPReport()
echo "=§= Rapport d'activité HTTP"
echo
local httpRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep $year|wc -l)
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 )
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 )
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 )
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 )
echo "Nombre d'ipv6 utilisatrices du service = $ipv6UserCount"
echo "Nombre total d'ip utilisatrices du service = $((ipv4UserCount+ipv6UserCount))"
echo
echo
echo
}
@ -136,7 +137,7 @@ elif [ "$#" -eq 2 ]; then
elif ! (let "$2") 2>/dev/null; then
echo -e "L'année doit être numérique."
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."
help
elif [ "$2" -le 2017 ] || [ "$2" -ge $(($(date +%Y)+1)) ] ; then
@ -147,7 +148,7 @@ elif [ "$#" -eq 2 ]; then
yearMonth="$2-0$1"
else
yearMonth="$2-$1"
fi
fi
monthEnglish=$(LANG=en_EN.UTF-8;date -d "$2-$1-01" +%b)
year="$2"
generateReport "$monthEnglish" "$year" "$yearMonth"

Loading…
Cancel
Save