November 12, 2005
Counter restoration

Well, this is a fairly useless update, but I had fun with it. I've kept a counter on some of my pages since I first put up web pages. However, the code that I use to maintain and display the counter (I found it years ago and I don't even remember where) has a minor problem. I am guessing that this problem occurs when two people try to access the counter at essentially the same time. I think that when this happens one of the processes cannot get to the file used to track the counter data (because it is being used by the other process). The one which was denied access interprets the error as indicating that the file doesn't exist and so it recreates it, thereby resetting all my counters back to zero.

This happened again just recently. However, I was not without recourse. I have a cron job which backs up that counter file every night. I could have simply copied an older copy of the file back into the production file name, but I wasn't satisfied with that. This was not the first time this has happened and I decided I would search through my archive of counter files and put together a new counter file which accumulates the totals from all the different files over the past three years (about 1000 files), recovering the counters that had been lost in the past.

So I ftped the files over to my home computer in order to be able to work with them more easily. Then I wrote a program which could read each of the files. Then, as the program reads the files it identifies all the different counters tracked in each file (since a single file is used to track all of the different pages) and recognize when the counters got reset. Then it totals up the highest values found for each page (the last values recorded before the counters were reset each time) and writes out a new data file with these new totals.

Using this little utility I've now restored my counters and recovered years worth of statistics. And so, I am now approaching 10,000 hits on my home page (not to mention nearly 8000 hits on one of my sokoban pages). Plus, if this glitch occurs again, I won't have to process so much data to recover the counters, because current backups will reflect the counts from early 2002.

OK, so nobody else cares. But it was interesting and I'm happy to have restored some evidence of my time blogging. Of course, the fact that I've gotten fewer hits in more than 2.5 years than some folks get everyday is irrelevent. Isn't it?

Posted by JoKeR at November 12, 2005 04:20 AM | TrackBack
Comments
Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?