Solved

Logging user connections ...

Posted on 2004-09-22
6
214 Views
Last Modified: 2010-04-15
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
Comment
Question by:Pete2003
6 Comments
 
LVL 15

Expert Comment

by:praneetha
ID: 12123206
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
 
LVL 1

Accepted Solution

by:
balee earned 250 total points
ID: 12123584
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
 
LVL 2

Expert Comment

by:SimonTocker
ID: 12131044
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
 

Author Comment

by:Pete2003
ID: 12131224
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
 
LVL 2

Assisted Solution

by:SimonTocker
SimonTocker earned 250 total points
ID: 12131281
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now