Open nelson-liu opened 6 years ago
Hello there! users()
function already provides a started
field, which is basically the login time expressed in seconds since the epoch. What would "idle" time represent exactly?
Hi! Thanks for your response. I don't think the idle time is quite the same as login time since the epoch. Idle time would be quite low whenever a user is actively using the shell / remote session, but if they step away then it would start ticking. This link provides a good explanation of how the w command calculates idle time.
Mmmm I see. Judging from some google searches I've just tried it seems there is some demand for this (or something similar to this). I'm not entirely clear what we should return though. Are we looking at the cumulative idle time as in "for how long the user has been idle in total (secs)"?
...or should this be a "counter" instead which resets back to 0 once the user types something in the terminal?
In fact this poses questions on whether we should only consider the terminal or also the X session: https://askubuntu.com/questions/202136/how-can-a-script-detect-a-users-idle-time ...so whatever we end up implementing we must be clear on what exactly we're providing.
Good question! I think that it should be a counter, and that it should consider both terminals and X sessions (i believe the w
command does this as well).
Hi, It'd be great to add something to
psutil.users()
that would encode idle time, as one would get from the output of running thew
command.Thanks, this is a very useful library!