[Piuparts-commits] [piuparts] 14/14: new script to rotate and compress master logs
Holger Levsen
holger at layer-acht.org
Mon Aug 21 14:33:06 UTC 2017
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch develop
in repository piuparts.
commit 51e7ff5f8e314d3327fb4b1e388338d477ada6f3
Author: Andreas Beckmann <anbe at debian.org>
Date: Wed Aug 16 04:42:42 2017 +0200
new script to rotate and compress master logs
Signed-off-by: Andreas Beckmann <anbe at debian.org>
Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
conf/crontab-master.in | 1 +
debian/changelog | 2 ++
master-bin/rotate_master_logs.in | 50 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+)
diff --git a/conf/crontab-master.in b/conf/crontab-master.in
index 64c2b7c..0ad5d6f 100644
--- a/conf/crontab-master.in
+++ b/conf/crontab-master.in
@@ -35,6 +35,7 @@ PATH=@sharedir@/piuparts/master:/usr/bin:/bin
#
0 2 * * * prepare_backup
55 23 * * * gather_bts_stats
+42 23 * * * rotate_master_logs
#
# data export for manpages.d.o
diff --git a/debian/changelog b/debian/changelog
index 889149c..b6707a8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -42,6 +42,8 @@ piuparts (0.79) UNRELEASED; urgency=medium
* master-bin/reschedule_oldest_logs: Expiration age values starting with "+"
are relative to the rescheduling age.
* master-bin/detect_network_issues: Detect appstream metadata errors.
+ * master-bin/rotate_master_logs: New daily cronjob to rotate and compress
+ (with one day of delay) master logfiles larger than 1 MB.
* slave_run: Ensure screen is run with SHELL=/bin/bash.
* Makefile: Split build and install targets between master and slave.
* Bump debsums dependency to (>= 2.2.2~) for --ignore-obsolete.
diff --git a/master-bin/rotate_master_logs.in b/master-bin/rotate_master_logs.in
new file mode 100644
index 0000000..f474252
--- /dev/null
+++ b/master-bin/rotate_master_logs.in
@@ -0,0 +1,50 @@
+#!/bin/sh
+set -e
+
+# Copyright © 2017 Andreas Beckmann (anbe at debian.org)
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <https://www.gnu.org/licenses/>
+
+#
+# * rotate master logfiles greater than 1 MB
+# * (delayed) compress rotated master logs
+#
+
+
+. @sharedir@/piuparts/lib/read_config.sh
+
+get_config_value SECTIONS global sections
+get_config_value MASTER global master-directory
+
+
+today=$(date +%Y%m%d)
+
+cd $MASTER
+for SECTION in $SECTIONS ; do
+ mlog=$SECTION/master.log
+ rlog=$SECTION/master.$today.log
+
+ # rotate master.log larger than 1 MB
+ if [ -f $mlog ] && [ ! -L $mlog ] && [ $(stat -c %s $mlog) -gt 1048576 ] && [ ! -e $rlog ]; then
+ mv -v $mlog $rlog
+ fi
+
+ # delayed compression of old master.log
+ for log in $SECTION/master.*.log
+ do
+ if [ -f "$log" ] && [ "$log" != "$rlog" ]; then
+ xz -v9 $log
+ fi
+ done
+done
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git
More information about the Piuparts-commits
mailing list