Atoptool / atop

System and process monitor for Linux
GNU General Public License v2.0
789 stars 110 forks source link

atopacct systemd service conflicts with acct in Ubuntu #227

Closed nradchenko closed 1 year ago

nradchenko commented 1 year ago
  1. Currently atopacct.service conflicts with psacct.service, which is not how accounting service is named in Debian and Ubuntu - its name is acct.service.
  2. atopacct.service doesn't check for already working accounting regardless of the actual service name like we have in old startup scripts https://github.com/Atoptool/atop/blob/d8d97f93f2425be97e4aca6df5c91fd18913ac16/atopacct.rc.openrc#L11-L22 https://github.com/Atoptool/atop/blob/d8d97f93f2425be97e4aca6df5c91fd18913ac16/atopacct.init#L30-L45

Given the above, acct service is not deactivated when atopacct is enabled and vice versa, which means that they are allowed to be run simultaneously causing problems like described in https://bugs.launchpad.net/ubuntu/+source/atop/+bug/1937097. This means that atop/acct are broken in out of the box Ubuntu install.

Please consider configuring proper Conflicts for atopacct (like Conflicts=acct.service), or implementing old-fashioned yet functional checks like ExecStartPre=sh -c "PACCTFILE=/var/log/account/pacct; BEFORSIZE=$(stat -c %s "${PACCTFILE}"); AFTERSIZE=$(stat -c %s "${PACCTFILE}"); if [ ${BEFORSIZE} -lt ${AFTERSIZE} ] ; then echo Process accounting already used by psacct; exit 1; fi" or similar. The solution depends on whether we want systemd prefer atopacct service over acct, or to exit silently and to not interfere with acct when it's already started.

After fixing this we can probably ask package maintainers for an update.

Thanks.

Atoptool commented 1 year ago

TheConflicts= has been replaced by ExecStartPre to avoid that the atopacctd daemon will be started when either psacct.service or acct.service (depending on the bistro) is already active.