You are not logged in.

#1 2007-12-20 20:03:42

creatorx
Member
Registered: 2005-09-14
Posts: 26

Monitoring system activity

I need to write an application (probably in java) which will run in the background and wait for a user to login.  When the users logins it monitor the applications he/she runs and whenever a logoff is detected it stop monitor application usage.  In other words I need to know when the user logs in, starts an application, and logoff.  So my question is, how is it possible to know this in linux/unix. 

Thanks in advance for your time.

Offline

#2 2008-01-16 00:28:32

AbacusMonkey
Member
Registered: 2007-11-01
Posts: 7

Re: Monitoring system activity

Is there not already logging daemons running that log this activity? Shouldn't this information be in /var/log somewhere?

Offline

#3 2008-01-16 08:16:14

mico
Member
From: Slovenia
Registered: 2004-02-08
Posts: 247

Re: Monitoring system activity

Login and logoff times are in /var/log/wtmp which is a binary file. You can browse it with last. See source for last if you need to read /var/log/wtmp yourself instead of executing an external program.

Your application could watch /var/log/wtmp for changes. When a change is detected, see who logged in (or stop monitoring the user that logged off). If you need something quick & dirty, you could just as well write everything in a bash script and use ps at regular intervals to see which processes that user is running.

Offline

Board footer

Powered by FluxBB