Forum OpenACS Development: Re: Get number of visitors currently browsing the site

Posted by Lars Pind on
Hi Jay

If you look at packages/acs-tcl/tcl/whos-online-procs.tcl, you'll find this comment:

# TODO: Record the IP address from [ad_conn peeraddr]

My plan was to use this to add exactly this feature, but I didn't have time.

If you'd implement this for us, that would be fantastic!


Posted by Tilmann Singer on
In my experience uniqueness of the ip address is very unreliable. There are providers where all accesses appear to come from the same ip address, others where the address of a single user changes from request to request. I wouldn't use it it for anything besides vague estimates.
Posted by Lars Pind on
Yes, IP is unreliable. Any better suggestions?

Session_id, maybe?


Posted by Bruno Mattarollo on

I guess that the problem with session_id is that it will also count the spiders, etc (I mean, everything accessing the site).

Something like:

set ten_min_ago [expr [ns_time] - (10*60)]
set sql_query "select count(distinct session_id) 
    as result from sec_session_properties where last_hit > :ten_min_ago"
db_1row select_sessions $sql_query
should give you some sessions. The only issue that I see is that, at least in OpenACS 4.6.3 (that's what we are using at the moment) you don't have an index on sec_session_properties(last_hit) so this query is quite inefficient (but I am not sure than adding an index is also a good solution, this table is touched a lot -for every hit, right?-).

Just my 2 cents,


Posted by Jade Rubick on
Perhaps we could cache the results every minute, and average them or something? The number doesn't have to be 100% accurate, but it should give a general idea of how many people are using the site.
Posted by Joel Aufrecht on
I tried Bruno's query and find that I get 0 sessions even if there is an active member session.