log retention time period should not be hardcoded

Bug #1716186 reported by Mason Schmitt on 2017-09-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
atop (Ubuntu)
Undecided
Unassigned

Bug Description

I'm presently running 16.04LTS. On that version atop's init script has the log retention period hardcoded to 28 days.

It would be better if the log retention period was set using a variable which could be modified in the /etc/default/atop file.

Here are two proposed patches that would resolve the issue:

--- /etc/init.d/atop.orig 2017-09-09 17:02:09.289551900 -0700
+++ /etc/init.d/atop 2017-09-09 17:00:36.972505450 -0700
@@ -26,6 +26,7 @@
 WRAPPER=/usr/share/atop/atop.wrapper
 INTERVAL=600 # interval 10 minutes
 LOGPATH="/var/log/atop"
+RETENTION=28
 OUTFILE=$LOGPATH/daily.log
 PIDFILE=/var/run/$NAME.pid
 SCRIPTNAME=/etc/init.d/$NAME
@@ -111,7 +112,7 @@
                 do_start
                 case "$?" in
                         0) [ "$VERBOSE" != no ] && log_end_msg 0
- [ "$1" = "_cron" ] && sleep 3 && find $LOGPATH -name 'atop_*' -mtime +28 -exec rm {} \;
+ [ "$1" = "_cron" ] && sleep 3 && find $LOGPATH -name 'atop_*' -mtime +$RETENTION -exec rm {} \;
              ;;
                         1) [ "$VERBOSE" != no ] && log_end_msg 1 ;; # Old process is still running
                         *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; # Failed to start

--- /etc/default/atop.orig 2017-09-09 17:01:39.077209432 -0700
+++ /etc/default/atop 2017-09-09 17:03:03.202163022 -0700
@@ -3,3 +3,4 @@
 INTERVAL=600
 LOGPATH="/var/log/atop"
 OUTFILE="$LOGPATH/daily.log"
+RETENTION=28

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers