-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
base: master
Are you sure you want to change the base?
Conversation
FYI, I don't think this makes any sense to be user configurable. Just enable it with sensible defaults. |
@murrant Following your advice, I have removed config variables. I just kept the env variable to enable/disable logrotate. |
# shellcheck shell=bash | ||
set -e | ||
|
||
if [ ${LOGROTATE_ENABLED:-false} = true ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only set logrotate for the main service and not sidecar containers:
if [ ${LOGROTATE_ENABLED:-false} = true ] | |
if [ "$SIDECAR_DISPATCHER" = "1" ] || [ "$SIDECAR_SYSLOGNG" = "1" ] || [ "$SIDECAR_SNMPTRAPD" = "1" ]; then | |
exit 0 | |
fi | |
if [ ${LOGROTATE_ENABLED:-false} = true ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure for this because if we consider a main service on a host using a sidecar dispatcher on a remote host, the dispatcher will generate a lot of logs contrary to the main service.
I have tested this case, I have installed only a sidecar dispatcher on a remote host and it generates a lot of logs locally.
Do you agree that we have to keep the logrotate configuration on the sidecar_dispatcher ?
Hello @charlyforot, Thanks for this PR; it seems much needed. Do you still plan to fix the remaining elements, as highlighted by @crazy-max? Cheers, |
Hello @JamesMenetrey Sorry for the response time, I'm going to fix this ASAP Cheers |
Co-authored-by: CrazyMax <[email protected]>
This makes me wonder. Isn't it common to log to stdout for docker containers? Shouldn't we be logging there instead of to a file? |
@murrant Admittedly, logging into stdout is more canonical for logging using Docker, but I have to say I would be happy to have a log rotate option rather than nothing :) |
Yes, it's right ! I tried to redirect some logs from librenms.log to stdout, however it's not easy because there are differents ways to log into LibreNMS code :
I can't redirect some PHP logs to stdout because of code design, if someone has an idea ? Otherwise, we could disable some logs which are duplicated between librenms.log and stdout container output by adding these lines into rootfs/etc/cont-init.d/03-config.sh :
This would remove the large part of the annoying logs from librenms.log. Other logs in librenms.log come from poll-billing.php and discovery.php |
LibreNMS log files can become very large: #310
The goal of this PR is to configure and activate logrotate with the environment variables provided in the README.
Working great from my side with
LOGROTATE_ENABLED=true
after have built the docker image.The logrotate configuration file named
librenms
is correctly created.We can see that the crons runs.
logrotate cron will be called every day.
We can try to force the logrotate to test this feature :
All done.