From 1af3f397220539059348dad3c155992a249b7f93 Mon Sep 17 00:00:00 2001 From: paspo Date: Fri, 1 Aug 2025 14:30:08 +0200 Subject: [PATCH] hourly stats --- README.md | 1 + rootfs/app/entrypoint.sh | 2 ++ rootfs/app/entrypoint.sh.d/90_stats_hourly.sh | 14 ++++++++++++++ rootfs/app/stats_hourly.sh | 15 +++++++++++++++ 4 files changed, 32 insertions(+) create mode 100755 rootfs/app/entrypoint.sh.d/90_stats_hourly.sh create mode 100755 rootfs/app/stats_hourly.sh diff --git a/README.md b/README.md index 6e96fe0..a3c966e 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ services: DISABLE_WEBROOT_CHOWN: 1 # default: 0 DISABLE_SFTP: 1 # default: 0 DISABLE_STATS: 1 # default: 0 + DISABLE_STATS_HOURLY: 1 # default: 0 DISABLE_WEBDAV: 1 # default: 0 ``` diff --git a/rootfs/app/entrypoint.sh b/rootfs/app/entrypoint.sh index 26c740c..f0f8160 100755 --- a/rootfs/app/entrypoint.sh +++ b/rootfs/app/entrypoint.sh @@ -26,6 +26,7 @@ FPM_MAX_SPARE_SERVERS=${FPM_MAX_SPARE_SERVERS:-3} DISABLE_WEBROOT_CHOWN=${DISABLE_WEBROOT_CHOWN:-0} DISABLE_SFTP=${DISABLE_SFTP:-0} DISABLE_STATS=${DISABLE_STATS:-0} +DISABLE_STATS_HOURLY=${DISABLE_STATS_HOURLY:-0} DISABLE_WEBDAV=${DISABLE_WEBDAV:-0} export USERNAME @@ -52,6 +53,7 @@ export FPM_MAX_SPARE_SERVERS export DISABLE_WEBROOT_CHOWN export DISABLE_SFTP export DISABLE_STATS +export DISABLE_STATS_HOURLY export DISABLE_WEBDAV # run all scripts in order diff --git a/rootfs/app/entrypoint.sh.d/90_stats_hourly.sh b/rootfs/app/entrypoint.sh.d/90_stats_hourly.sh new file mode 100755 index 0000000..26ef077 --- /dev/null +++ b/rootfs/app/entrypoint.sh.d/90_stats_hourly.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ ${DISABLE_STATS} -eq 1 ] ; then + exit 0 +fi + +if [ ${DISABLE_STATS_HOURLY} -eq 1 ] ; then + exit 0 +fi + +echo "# Configuring hourly stats" + +# stats endpoint +ln -s /app/stats_hourly.sh /etc/periodic/hourly/stats diff --git a/rootfs/app/stats_hourly.sh b/rootfs/app/stats_hourly.sh new file mode 100755 index 0000000..49bebec --- /dev/null +++ b/rootfs/app/stats_hourly.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +if [ "${DISABLE_STATS:-0}" -eq 1 ] ; then + exit 0 +fi + +PATH_BASE=/data +PATH_STATS=${PATH_BASE}/stats +PATH_STATSDB=${PATH_BASE}/stats.db +PATH_LOGS=${PATH_BASE}/logs + +/usr/bin/goaccess "${PATH_LOGS}/nginx-access.log" \ + --agent-list --anonymize-ip --real-os --exclude-ip 127.0.0.1 \ + --output "${PATH_STATS}/index.html" --log-format COMBINED \ + --tz="${TZ}" "--db-path=${PATH_STATSDB}" --persist --restore