Browse Source

Add select last folder

master
root 2 years ago
parent
commit
8e872f9224
  1. 28
      create_stats.sh

28
create_stats.sh

@ -38,16 +38,20 @@ fatal() { echo -e "${RED}[FATAL] $* ${NC}" | logger --tag "${SCRIPTNAME}" --
## Define variables ###################################
info "Define variables"
DATE=$(date '+%Y-%m-%d')
REPONAME="log_backup"
LOG_PATH="/mnt/${REPONAME}-${DATE} 01:00/var/log/nginx"
REPONAME="rp-1"
MOUNTPATH="/mnt"
TMP_LOG_PATH="/tmp/logs"
HTML_FILE="/var/www/stats/www"
TMP_LOG_PATH="/data/tmp/logs"
HTML_FILE="/var/www/stats_dryusdan_fr/www"
HTML_DAY_FILE="$HTML_FILE/$(date --date='1 day ago' '+%Y/daily/%B/%d')"
HTML_WEEK_FILE="$HTML_FILE/$(date --date='1 day ago' '+%Y/weekly/%V')"
HTML_MONTH_FILE="${HTML_FILE}/$(date --date='1 day ago' '+%Y/monthly/%B')"
HTML_YEAR_FILE="${HTML_FILE}/$(date --date='1 day ago' '+%Y/yearly')"
info "Mount backup"
/usr/bin/borg mount /data/borg/${REPONAME}/${REPONAME} ${MOUNTPATH}
LOG_PATH="$(ls -td /mnt/*/ | head -1)/var/log/archive-nginx"
info "Create temp folder if not exist"
mkdir -p "${TMP_LOG_PATH}"
@ -75,10 +79,11 @@ daily (){
do
info "Generate stat for ${file}"
domain=$(echo ${file} | sed "s/\.access\.log.*//g")
goaccess --output=${HTML_DAY_FILE}/${domain}-$(date --date='1 days ago' '+%Y-%m-%d').html --ignore-panel=HOSTS --exclude-ip 10.0.0.0/8 --std-geoip --anonymize-ip --ignore-crawlers --log-format=COMBINED ${file}
goaccess --output=${HTML_DAY_FILE}/${domain}-$(date --date='1 days ago' '+%Y-%m-%d').html --ignore-panel=HOSTS --exclude-ip 10.0.0.0/8 --anonymize-ip --ignore-crawlers --log-format=COMBINED ${file}
done
cd /
rm -rf ${TMP_LOG_PATH}
}
weekly (){
@ -94,7 +99,7 @@ weekly (){
do
info "Generate stat for ${file}"
if [ $(ls ${file}".access.log."* | wc -l ) -eq 7 ]; then
goaccess --output=${HTML_WEEK_FILE}/${file}.html --ignore-panel=HOSTS --exclude-ip 10.0.0.0/8 --std-geoip --anonymize-ip --ignore-crawlers --log-format=COMBINED ${file}".access.log."{1,2,3,4,5,6,7}
goaccess --output=${HTML_WEEK_FILE}/${file}.html --ignore-panel=HOSTS --exclude-ip 10.0.0.0/8 --anonymize-ip --ignore-crawlers --log-format=COMBINED ${file}".access.log."{1,2,3,4,5,6,7}
fi
done
cd /
@ -117,7 +122,7 @@ monthly () {
do
info "Generate stat for ${file}"
NUMBER_FILES=$(ls ${file}".access.log."* | wc -l )
eval goaccess --output=${HTML_MONTH_FILE}/${file}.html --ignore-panel=HOSTS --exclude-ip 10.0.0.0/8 --std-geoip --anonymize-ip --ignore-crawlers --log-format=COMBINED ${file}".access.log."{1..${NUMBER_FILES}}
eval goaccess --output=${HTML_MONTH_FILE}/${file}.html --ignore-panel=HOSTS --exclude-ip 10.0.0.0/8 --anonymize-ip --ignore-crawlers --log-format=COMBINED ${file}".access.log."{1..${NUMBER_FILES}}
done
cd /
rm -rf ${TMP_LOG_PATH}
@ -139,18 +144,12 @@ yearly () {
do
info "Generate stat for ${file}"
NUMBER_FILES=$(ls ${file}".access.log."* | wc -l )
eval goaccess --output=${HTML_YEAR_FILE}/${file}.html --ignore-panel=HOSTS --exclude-ip 10.0.0.0/8 --std-geoip --anonymize-ip --ignore-crawlers --log-format=COMBINED ${file}".access.log."{1..${NUMBER_FILES}}
eval goaccess --output=${HTML_YEAR_FILE}/${file}.html --ignore-panel=HOSTS --exclude-ip 10.0.0.0/8 --anonymize-ip --ignore-crawlers --log-format=COMBINED ${file}".access.log."{1..${NUMBER_FILES}}
done
cd /
rm -rf ${TMP_LOG_PATH}
}
info "Mount backup"
/usr/bin/borg mount /data/borg/${REPONAME}/${REPONAME} ${MOUNTPATH}
case "${1}" in
daily)
daily
@ -170,3 +169,4 @@ case "${1}" in
esac
info "umount backup"
/usr/bin/borg umount ${MOUNTPATH}

Loading…
Cancel
Save