0

I'm a server admin for a university, and we have 4 CentOS servers that students can use for their projects in various classes. The CS professors have asked me to come up with a way to track a user's active time on the machine. For example, in the event that at the end of the semester little Timmy is failing and his mom is making a fuss, the professors want to be able to say that Timmy was only active for 37 minutes on the server for the whole semester. Log in time alone is not sufficient, because a user could be logged in and inactive.

I've tried using the w command, but it only gives a user's idle time. I've also tried writing scripts that calculate active by using bash history and the history <user> command, but the timestamps are only logged when the command is executed. In this case active time is defined as the user typing or interacting with the server. What would be ideal is exactly what the w command does with idle time, but for active time.

Any ideas?

3
  • I guess this is a pretty broad task. I roughly know what do you mean, but there is too much options, so I guess it's not feasible this simple way. You can simply measure tty idle, but don't you use X or another graphical interface? Is running a while true ; do echo "*"; done enough to be "active"? Is executing a calculation an idle time? On the other hand running and evaluating traditional Unix accounting might be a lot of extra work to do...
    – d.c.
    Commented Apr 14, 2021 at 20:30
  • Graphing the load averages over time? You will see possibly multiple user's used cpu time. Anything usable there? Other than that? => patch readline() ?
    – Hannu
    Commented Apr 14, 2021 at 20:41
  • Hannu - I could use load time, but typing barely creates any CPU load, and that counts as "active". d.c. - The system has no GUI, and all user interactions are through PuTTY or any SSH client. Just running calculations does count as idle time, since the user isn't actively working on the box. It looks like this is going to be a much bigger pain than its worth. I'll look into some third party applications and see how that goes.
    – Beanstalk
    Commented Apr 15, 2021 at 13:29

0

You must log in to answer this question.

Browse other questions tagged .