Solved

Logging user connections ...

Posted on 2004-09-22
6
218 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

822 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