Atoptool / atop

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

acctatop: reacquire acctfd for some reasonable cases #235

Closed ShirleyFei closed 1 year ago

ShirleyFei commented 1 year ago

In current code, the acctfd value in acctproc.c will not be updated once atop runs. This can cause 'nexit is zero' problem when atopacct.service restarts but atop not, in which case, the previous shadow file that atop read is being '(deleted)' and as acctfd does not change, atop will continue reading that obsolete file whose size will never grow, leading to get a wrong number of exited process, e.i. always be zero from now on until atop restarts.

Fix this by reacquiring the new shadow fd after atopacct.service restarts. By the way, only reacquire for atopacct case; as for other cases that directly read from acct() file, restarting service does not make the nexit a wrong value. Besides, if the atopacct or (p)acct service is stopped for a while, ignore this situation too, as we are not sure if the action is on purpose or not.

Signed-off-by: Fei Li lifei.shirley@bytedance.com

ShirleyFei commented 1 year ago

Close this as this is duplicated with https://github.com/Atoptool/atop/pull/244. And the corresponding solution is here: https://github.com/bytedance/atop/tree/recollect-nprocexit-by-reacquire-acctfd