Codebase list atop / 1296109
have logrotate files handle acct absence Marc Haber 3 years ago
1 changed file(s) with 7 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
4747 4.
4848 --- a/psaccs_atop
4949 +++ b/psaccs_atop
50 @@ -10,11 +10,18 @@
50 @@ -10,11 +10,12 @@
5151 postrotate
5252 # check if process accounting is installed
5353 #
5454 - if [ -e /etc/logrotate.d/psacct ]
55 + if [ -e /etc/logrotate.d/psacct ] || grep -q 'savelog' /etc/cron.daily/acct
56 then
55 - then
56 + if grep -q 'savelog' /etc/cron.daily/acct 2>/dev/null; then
5757 # check if process accounting is actually in use
5858 #
5959 - ACCTFILE=`awk '$2 == "{" {print $1}' /etc/logrotate.d/psacct`
60 + if [ -e /etc/logrotate.d/psacct ]
61 + then
62 + ACCTFILE=`awk '$2 == "{" {print $1}' /etc/logrotate.d/psacct`
63 + fi
64 + if grep -q 'savelog' /etc/cron.daily/acct
65 + then
66 + ACCTFILE=`sed -n "/savelog[^\/]\+\(\/[[:alnum:]\/]\+\).*/{s//\1/;p;q;}" /etc/cron.daily/acct`
67 + fi
60 + # this is a heuristic that will fail once acct's cron.daily job changes
61 + # please file a bug report against atop if you encounter this
62 + ACCTFILE=$(sed -n "/savelog[^\/]\+\(\/[[:alnum:]\/]\+\).*/{s//\1/;p;q;}" /etc/cron.daily/acct)
6863
6964 if [ -f "$ACCTFILE" ]
7065 then
7570 create 0600 root root
7671 postrotate
7772 - if [ -e /etc/logrotate.d/psacct ]
78 + if [ -e /etc/logrotate.d/psacct ] || grep -q 'savelog.*/var/log/account/pacct' /etc/cron.daily/acct
73 + if grep -q 'savelog.*/var/log/account/pacct' /etc/cron.daily/acct 2>/dev/null
7974 then
8075 # if the atop daemon does not run, restart it after
8176 # accounting file is rotated