Docs ModUserOnline » History » Revision 15
« Previous |
| Next »
Anonymous, 2006-09-08 21:19
:keywords: lighttpd, online user, tracking, unique ips
.. contents:: Table of Contents
Module that tracks users online/active by unique ips (no cookies), includes counting hits, and linking into mod_status (http://trac.lighttpd.net/trac/wiki/Docs%3AModStatus#server-statistics).
Prevously, I made a module in PHP that performed a similar function of tracking online users. At a certain point I realized it to be a bit wasteful with resources, and decided to make the module into Lighttpd.
I started baseing the code off mod_rewrite, using pcre to match patterns to decide whether to track a given page or not. I emailed my code to Jan for review and in hopes of getting it included into one of the branches so everyone can make use of it. Jan replied shortly after with a few suggestions/issues that improved the module considerably (as I am sort of new to Lighttpd internal workings).
My name is Wojciech (nick: Wojtek) and I go by the alias Wojjie online. I run/own http://www.game-monitor.com , which is the site that is currently running this module and the site I made reference to above.
If you wish to contact me directly via email, I can be reached at: firstname.lastname@example.org (please note: I do get alot of spam, so put [mod_useronline] or [lighttpd] in the subject so your email stands out, and just hope my spam filter does not pick it up). Another method to contact me is to get on irc, and idle in Lighttpd's irc channel (irc://irc.freenode.net/lighttpd) where I will most likely be idleing.
enable or disable tracking for given area
Default: 0 [disabled]
Example: useronline.enable = 1
number of seconds till user/ip is no longer considered online
Example: useronline.online_age = 600
number of seconds till user/ip is no longer considered active (note: setting this higher than online_age will give you the same active count as online)
Default: useronline.online_age / 3 = 100
Example: useronline.active_age = 60
max number of ips to track (note: if this limit is hit, the server will not track new users/ips)
Memory Usage: 16 * max_ips (on a 64bit system)
Example: useronline.max_ips = 4096
name to associate to the variables shown in server-statistics (if not set, it will not report)
Example: useronline.status_name = "myWonderfulSite"
When configured properly, you will notice a few new environment variables accessible to you. In PHP you can output the number of online users like so:
<?php echo $_ENV['USERS_ONLINE'] ?>
Here is a current list of environment variables generated by this module:
number of online users (IPs that last hit >= online_age seconds ago)
number of active users (IPs that last hit >= min(online_age, active_age) seconds ago)
number of hits seen by the current ip while being online/active
number of seconds that a user is still considered online (just reports the current setting)
number of seconds that a user is still considered active (just reports the current setting)
max number of ips tracked (just reports the current setting)
site/conditional id, where the tracking data is located (may be used in the future to link)
If useronline.status_name is set, the module will report to status counters that will be displayed in http://trac.lighttpd.net/trac/wiki/Docs%3AModStatus#server-statistics
Example: (using: useronline.status_name = "myWonderfulSite")
The top 4 lines report settings, while the last 2 report the current counters.
You will notice an id number listed, this is the id where the data for that site/conditional is stored. It may be used in the future to link multiple sites/conditonals together to use the same counters, to make it easier to count online users across multiple domains.
Updated by Anonymous over 16 years ago · 15 revisions