![]() | Configuration of the Module MOD_stat |
The purpose of this module is simple statistics. When the module receives a request, it creates an empty, transparent 1*1 pixel GIF image. Any information given by the query string of the request is used in order to update the internal statistics. The data specified in the query string is taken as a (case-sensitive) name. The module stores the hits to these names in a hit list within the WWW server's directory, in an ASCII file. To keep the file small, only a top list of names is kept.
A reference to the statistic is done by placing an image link on the HTML page, on which access should be counted. A reference with the name hit_me could be done by adding this line to the HTML page:
<IMG SRC="/stat?hit_me">
The statistic can be queried via administration section, by showing the module's configuration. Every time, the server shuts down or re-configures, the information is written to a file mod_stat.lst in the WWW server's executable directory. (The information is not written each time access takes place in order to keep the system load and I/O activities at a low level.)
The contents of the file could show something like this:
# Information is stored like this: #The first entry contains the number of hits of the entry, referenced by the name, standing at last (third position). The time stamp, the second data in a line, is a hexadecimal 32 bit number, which represents the seconds since 1970, January 1st, midnight. Normally, you can take this info, store it in a C variable of type time_t and do gmtime(), ctime(), etc. on it.# | | | # | +--- time stamp +--- reference # | as hex-decimal name # | seconds since # +--- number of 1970/01/01 0:00 # hits 2 0x35C8584D index 1 0x35C85724 install 42 0x35C85CB6 config 11 0x35C85A1A a-z 1 0x35C85856 copyrght
Since the module is very easy constructed, source code is included in all distributions of shttpd. You can find it in the file src/samples/mod_stat.c.
| ©. 1998-2000 by Dirk Ohme |