• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Logging user connections ...

Hi All,

I need a stat for my web application ... I need to know the following: user name, timestamp, some sort of machine ID.

I need to know what the number of distinct users at any time is. ie: if 5 pple log in under user 'bob' then it's till 5 connections ...

I would also like to know what the best way of logging this kind of system would be. I obviously can't just use a simple text file to log all events as there will be sync errors and entries will be mixed up ...

I can not log the entire user activity in one log entry since there are two thing that must take place; first the user logs in to the system then he choses an application, so if I log this as two entries there might be some data from other users inbetween the two log entries. I also can not log the data after the user chose an app as he might log in and wait for 5 minutes before doing anything and I need to have the exact times of log in for both. What might also happen is that the user might log in and log out without opening an application which I'd also like to log.

Any suggestions help on how to do this would be greately appreciated ...
Txs
Peter
0
Pete2003
Asked:
Pete2003
2 Solutions
 
praneethaCommented:
may be you can log your data in this record format

Id - IPAddress- SystemLogin -SystemLogout -applicationLogin- ApplicationLogout-username

so update the record(in database / textfile)...when he logs into application instead of creating a new record...

good luck
0
 
baleeCommented:
I would store this in a database table.

LOG_TABLE
-------------
ID                NUMBER   -- log id (primary key)
ACTION_ID   NUMBER   -- what kind of action the user performed (like 1 - login, 2 - logout, 3 - opened some apps etc. whatever you like to log)
USERNAME   TEXT
IPADDRESS  TEXT        -- some unique identifier with username
TIMESTAMP DATETIME -- when the action happened

Once you have done with this, you only need to implement some logging mechanism into your application (like inserts into this table when the particular events occure).
To get the number of users at a given time interval is:

select count(*) from LOG_TABLE a
where a.timestamp > XXX and a.timestamp < YYY
and a.action_id = 1
and not exists (select 1 from LOG_TABLE b where b.timestamp > XXX and b.timestamp <YYY
and b.action_id =2 and b.ipaddress = a.ipaddress and b.username = a.username)

This hasn't been tested, just an idea. It assumes that there is only one connection from a given IP address with a given username at same time. It also assumes that the action_id = 1 is used for login and 2 is for logout. This way it counts all users who has logged in in the given time interval but hasn't yet logged out.

Hope it helps
0
 
SimonTockerCommented:
All this information is in the IIS logs, ther are plenty of tools out there that will help you interpret them or you could even write some your self.

Dont burden your application with things that already exist and are done in the Kernel much faster than any code we could write.

If this is for business though I would recommend purchasing WebTrends or some other such report generator, thi has complex analysis tools for usage and page flow.
0
 
Pete2003Author Commented:
Simon: I need to have a page in my application administrator which displays all this info .. most of my users (even admins) will not know much about IIS ... (the admins will be managers and applicaition level admins not network pple)
0
 
SimonTockerCommented:
Ah I see,

Ok so you have multiple web apps ? a menu page then you go into the app by the sound of it.

This kind of info needs to be collected at the start page, and for each application, you probably need to persist the info in a database for analysis for some of the info you want and in Application (configure sql session for multiple machines if in a farm/garden), this is to hold the onscreen info.

The number of people loggin in is the kind of info for Application variables, the other stuff needs anaylysis becuase your correct all the particulars are different.

if there are five apps consider 6 Virutal directories and using Session information for each application and writing to the db in the on session start.

You will need a report to pull all the info together, and thats the hard bit but I believe that the configuration will help you write the rest.


0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now