diff --git a/Dockerfile b/Dockerfile index c5a2b06e..34d8b69c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ RUN apk --update --no-cache add \ imagemagick \ ipmitool \ iputils \ + logrotate \ libcap-utils \ mariadb-client \ monitoring-plugins \ diff --git a/README.md b/README.md index a411c18a..cf2ab29a 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,18 @@ Image: librenms/librenms:latest * `DISPATCHER_NODE_ID`: Unique node ID for your dispatcher service * `DISPATCHER_ARGS`: Additional args to pass to the [dispatcher service](https://github.com/librenms/librenms/blob/master/librenms-service.py) +### Logrotate + +> **Note** +> +> Logrotate could be enabled to avoid large log files. + +> **Warning** +> +> When activated, logs exceeding the specified retention period will be deleted. + +* `LOGROTATE_ENABLED`: Set to `true` to enable logrotate for LibreNMS logs (default `false`) + ### Syslog-ng > **Warning** diff --git a/rootfs/etc/cont-init.d/03-config.sh b/rootfs/etc/cont-init.d/03-config.sh index 18402aa5..d5dbb634 100644 --- a/rootfs/etc/cont-init.d/03-config.sh +++ b/rootfs/etc/cont-init.d/03-config.sh @@ -257,3 +257,22 @@ for template in ${templates}; do echo " Adding ${template} alert template" ln -sf /data/alert-templates/${template} ${LIBRENMS_PATH}/resources/views/alerts/templates/${template} done + +# Configure logrotate if enabled except for syslogng and snmptrapd sidecars +if [ ${LOGROTATE_ENABLED:-false} = true ] && [ "$SIDECAR_SYSLOGNG" != "1" ] && [ "$SIDECAR_SNMPTRAPD" != "1" ]; +then + cat <<'EOF' > /etc/logrotate.d/librenms + ${LIBRENMS_PATH}/logs/*.log { + su librenms librenms + create 664 librenms librenms + weekly + rotate 6 + compress + delaycompress + missingok + notifempty + copytruncate + } +EOF + +fi