w idle time issue

"Craig Small" <[email protected]> ("csmall") Wed, 4 Dec 2024 21:38:25 +1100
Newsgroups gmane.linux.procps.devel
Message-ID <CALy8Cw5xozPTjMjpByP+vtbe0R4cr+816vexfd5fozUk2rw45w@mail.gmail.com>
--000000000000652c0606286f620b
Content-Type: text/plain; charset="UTF-8"

Hello All,
  I've recently become aware that w is not reporting the idle time of users
on X or Wayland sessions correctly. Looking back at it, it looks like this
has been the way it has been since the days of kernel 4.19 at least.

Idle time is found by stat()ing the relevant /dev/ttyX file and looking at
the access time of the file. When a user is active, this time increments,
when idle it no longer updates.

For ssh and VTY sessions, this still occurs and the idle times track the
actual active user times (within 8 seconds). So if a ssh user is idle for 5
minutes, the atime for the file will be five minutes ago and w will say
they are idle for 5 minutes.

For X/Wayland this is not the case. The atime for the file is roughly when
the X/Wayland server starts; probably when the uid of the file changes.

So, two things:
Has anyone got a system out there where the idle time is correct for their
X/Wayland users and if so what is it?
Anyone got any idea how to get the idle time for these types of users?

 - Craig


-- 

Craig Small             https://dropbear.xyz/  csmall at : dropbear.xyz
Debian GNU/Linux        https://www.debian.org/
<http://www.debian.org/>  csmall at : debian.org
GPG fingerprint:     5D2F B320 B825 D939 04D2  0519 3938 F96B DF50 FEA5

--000000000000652c0606286f620b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hello All,</div><div>=C2=A0 I&#39;ve recently become =
aware that w is not reporting the idle time of users on X or Wayland sessio=
ns correctly. Looking back at it, it looks like this has been the way it ha=
s been since the days of kernel 4.19 at least.</div><div><br></div><div>Idl=
e time is found by stat()ing the relevant /dev/ttyX file and looking at the=
 access time of the file. When a user is active, this time increments, when=
 idle it no longer updates.</div><div><br></div><div>For ssh and VTY sessio=
ns, this still occurs and the idle times track the actual active user times=
 (within 8 seconds). So if a ssh user is idle for 5 minutes, the atime for =
the file will be five minutes ago and w will say they are idle for 5 minute=
s.</div><div><br></div><div>For X/Wayland this is not the case. The atime f=
or the file is roughly when the X/Wayland server starts; probably when the =
uid of the file changes.</div><div><br></div><div>So, two things:</div><div=
>Has anyone got a system out there where the idle time is correct for their=
 X/Wayland users and if so what is it?</div><div>Anyone got any idea how to=
 get the idle time for these types of users?</div><div><br></div><div>=C2=
=A0- Craig</div><div><br clear=3D"all"></div><br><span class=3D"gmail_signa=
ture_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signature" data-=
smartmail=3D"gmail_signature"><div dir=3D"ltr"><pre>Craig Small            =
 <a href=3D"https://dropbear.xyz" target=3D"_blank">https://dropbear.xyz/</=
a>  csmall at : <a href=3D"http://dropbear.xyz" target=3D"_blank">dropbear.=
xyz</a>
Debian GNU/Linux        <a href=3D"http://www.debian.org/" target=3D"_blank=
">https://www.debian.org/</a>  csmall at : <a href=3D"http://debian.org" ta=
rget=3D"_blank">debian.org</a>
GPG fingerprint:     5D2F B320 B825 D939 04D2  0519 3938 F96B DF50 FEA5</pr=
e></div></div></div>

--000000000000652c0606286f620b--