Apache log munging

Joe Riopel goon12 at gmail.com
Wed Oct 8 20:15:12 CEST 2008


On Wed, Oct 8, 2008 at 1:55 PM, Joe Python <jopython at gmail.com> wrote:
> I want to find the top '100' hosts (sorted in descending order of total
> requests) like follows:
> Is there a fast way to this without scanning the log file many times?

As you encounter a new "host" add it to a dict (or another type of
collection), and if encountered again, use that "host" as the key to
retrieve the dict entry and increment it's request count. You should
only have to read the file once.



More information about the Python-list mailing list