From f5058ac0192bebd86b8a5bc366e787e06cd8f88d Mon Sep 17 00:00:00 2001 From: Anthony Howe Date: Sun, 18 Jul 2021 04:59:32 -0400 Subject: [PATCH] update cachewarmer syslog configuration including rotate (#1288) --- .../bootstrap.cachewarmer-manager.sh | 21 +++++++++++++++++++ .../bootstrap/bootstrap.cachewarmer-worker.sh | 20 ++++++++++++++++++ .../rsyslog/35-cachewarmer-manager.conf | 2 +- .../rsyslog/36-cachewarmer-worker.conf | 2 +- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/bootstrap.cachewarmer-manager.sh b/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/bootstrap.cachewarmer-manager.sh index 58196643..226be090 100644 --- a/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/bootstrap.cachewarmer-manager.sh +++ b/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/bootstrap.cachewarmer-manager.sh @@ -79,6 +79,27 @@ function configure_rsyslog() { # enable listen on port 514/TCP sed -i 's/^#module(load="imtcp")/module(load="imtcp")/g' /etc/rsyslog.conf sed -i 's/^#input(type="imtcp" port="514")/input(type="imtcp" port="514")/g' /etc/rsyslog.conf + + # ensure the logs are rotating + if grep -F --quiet "/var/log/cachewarmer-manager.log" /etc/logrotate.d/rsyslog; then + echo "not updating /etc/logrotate.d/rsyslog, already there" + else + /bin/cat <>/etc/logrotate.d/rsyslog +/var/log/cachewarmer-manager.log +{ + rotate 2 + daily + missingok + notifempty + compress + postrotate + /usr/lib/rsyslog/rsyslog-rotate + endscript +} +EOM + fi + + # restart syslog systemctl restart rsyslog } diff --git a/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/bootstrap.cachewarmer-worker.sh b/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/bootstrap.cachewarmer-worker.sh index 198ec12b..2ca5b984 100644 --- a/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/bootstrap.cachewarmer-worker.sh +++ b/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/bootstrap.cachewarmer-worker.sh @@ -48,6 +48,26 @@ function configure_rsyslog() { # enable listen on port 514/TCP sed -i 's/^#module(load="imtcp")/module(load="imtcp")/g' /etc/rsyslog.conf sed -i 's/^#input(type="imtcp" port="514")/input(type="imtcp" port="514")/g' /etc/rsyslog.conf + + # ensure the logs are rotating + if grep -F --quiet "/var/log/cachewarmer-worker.log" /etc/logrotate.d/rsyslog; then + echo "not updating /etc/logrotate.d/rsyslog, already there" + else + /bin/cat <>/etc/logrotate.d/rsyslog +/var/log/cachewarmer-worker.log +{ + rotate 2 + daily + missingok + notifempty + compress + postrotate + /usr/lib/rsyslog/rsyslog-rotate + endscript +} +EOM + fi + systemctl restart rsyslog } diff --git a/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/rsyslog/35-cachewarmer-manager.conf b/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/rsyslog/35-cachewarmer-manager.conf index 90dd7a60..a8d518b7 100644 --- a/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/rsyslog/35-cachewarmer-manager.conf +++ b/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/rsyslog/35-cachewarmer-manager.conf @@ -1,2 +1,2 @@ -if $programname == 'cachewarmer-manager' or $syslogtag == 'cachewarmer-manager' then /var/log/cachewarmer/manager.log +if $programname == 'cachewarmer-manager' or $syslogtag == 'cachewarmer-manager' then /var/log/cachewarmer-manager.log & stop \ No newline at end of file diff --git a/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/rsyslog/36-cachewarmer-worker.conf b/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/rsyslog/36-cachewarmer-worker.conf index bc237f43..57684954 100644 --- a/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/rsyslog/36-cachewarmer-worker.conf +++ b/src/go/cmd/cachewarmer/deploymentartifacts/bootstrap/rsyslog/36-cachewarmer-worker.conf @@ -1,2 +1,2 @@ -if $programname == 'cachewarmer-worker' or $syslogtag == 'cachewarmer-worker' then /var/log/cachewarmer/worker.log +if $programname == 'cachewarmer-worker' or $syslogtag == 'cachewarmer-worker' then /var/log/cachewarmer-worker.log & stop \ No newline at end of file