#!/usr/bin/python import cgi import apachelog def main(): refdict = {} pageview = 0 uniqhosts = {} infile = file("/var/log/apache2/shingetsu.access.log") logdata = apachelog.read_today(infile) for row in logdata: try: addr = row[0] query = row[4] pageview += 1 uniqhosts[addr] = True except IndexError: pass print "pageview: %d" % pageview print "uniqhosts: %d" % len(uniqhosts) if __name__ == "__main__": main()