Question
I had a brief but challenging time getting TWiki to update the statistics page. It was very frustrating, because it
seemed to be working fine (from the browser point of view), but when I would save a page and re-do the statistics, no change would show up on
WebStatistics. I'm documenting the problem and solution here for others.
- TWiki version: TWiki 01 Feb 2003
- Perl version: v5.6.1 built for i386-linux
- Web server & version: Apache/1.3.27 (Unix) (Red-Hat/Linux)
- Server OS: Linux 2.4.20
- Web browser & version: Mozilla 1.4
- Client OS: Win XP
--
AnthonyRThompson - 22 Jul 2003
Answer
Common suggestions to solve this seemed to be the following:
- Check file permissions: Make sure nobody (or httpd, or whatever the web server runs as) can run the statistics cgi-bin script and write to the WebStatistics.txt and WebStatistics.txt,v files in each web you want to update statistics for (e.g., in the data/Main, data/Sandbox, data/TWiki, data/Know directories); also make sure the directories containing WebStatistics.txt are themselves writable by nobody/httpd/whatever
- Make sure you have logging turned on for the features you want updated with each statistics run: Look at the "doLog" variables in TWiki.cfg (e.g., $doLogTopicSave, $doLogTopicEdit, etc.)
- If you have the statistics script set to run automatically via cron (a good idea, actually), make sure that's not resetting the permissions on the WebStatistics.txt and .txt,v files; this might happen because the cron job will run as your user account, which might re-create the files with write access for only the user, causing a problem if someone tries the "force an update" link on the WebStatistics page since that will run the statistics script as nobody/httpd/whatever
My problem (and solution) was actually far more subtle. To find it, I turned on detailed debugging of logging by setting the $doDebugStatistics in TWiki.cfg to 1 and then re-running the staticstics script. Then I looked in the debug.txt file (in the same place as your log file normally, usually in the data directory) and saw "Invalid log file line" error messages indicating that statistics was unable to determine the userName, opName, or webName (opName apparently refers to the operation, like view or save).
I had modified my TWiki installation to get the user name from a cookie set by the login function of my site. Instead of getting it from the REMOTE_USER variable, I got it from a cookie (briefly: replacing
$theRemoteUser = $query->remote_user() with
$query->cookie('member-email') in all the CGI scripts). Well, that was the source of the problem because my cookie has the user's e-mail address and the problem was the line in the statistics script that defines the pattern to identify the Wiki user:
$intranetUserRegex = qr/[a-z0-9]+/. My user names were in the form athomps_at_adf.org, so both the underscore and period were causing the pattern match on the log line to fail, producing that error. I solved the problem by changing the line to
$intranetUserRegex = qr/[a-z0-9_.]+/, re-running statistics, jumping for joy, and finally going to bed after a much-longer-than-anticipated programming session
--
AnthonyRThompson - 22 Jul 2003
Thanks Anthony for documenting this in detail
--
PeterThoeny - 23 Jul 2003