Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add logrotate for librenms log files #339

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN apk --update --no-cache add \
imagemagick \
ipmitool \
iputils \
logrotate \
libcap-utils \
mariadb-client \
monitoring-plugins \
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
19 changes: 19 additions & 0 deletions rootfs/etc/cont-init.d/03-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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