diff --git a/waccess b/waccess index 78236a6..bb9bb7f 100755 --- a/waccess +++ b/waccess @@ -1,6 +1,6 @@ #!/usr/bin/env python # waccess - Copyright (c) 2001,2002, TundraWare Inc., All Rights Reserved -# $Id: waccess,v 1.63 2002/09/02 18:33:28 tundra Exp $ +# $Id: waccess,v 1.64 2002/09/02 19:04:17 tundra Exp $ # # Look for selected strings passed on the command line in the http access log. @@ -36,6 +36,11 @@ REVERSE_CACHE = {} +# This table keeps track of how many unique IPs access each +# search key. + +UNIQUE_IP = {} + ########## # Function Defintions @@ -103,6 +108,7 @@ matched = {} for a in args: matched[a] = 0 + UNIQUE_IP[a] = [] total = 0 @@ -135,25 +141,19 @@ MATCHED = FALSE for a in args: if record.count(a): - i = 0 - revname = "" matched[a] += 1 MATCHED = TRUE + # Save if new IP address encountered + if not UNIQUE_IP[a].count(IPADR): + UNIQUE_IP[a].append(IPADR) - - # But only display the matching record once, regardless of how many + # only display the matching record once, regardless of how many # matching substrings are found. if MATCHED: if REVERSE: revname = IPReverse(IPADR) - else: - # Even if we're not doing reverse lookups, use the cache data - # structure to keep track of how many unique IPs we encounter - REVERSE_CACHE[IPADR] = IPADR - - if SHOW: print DATESTAMP, " " * (19 - len(DATESTAMP)), \ IPADR, " " * (15 - len(IPADR)), \ @@ -165,4 +165,4 @@ f.close() print "\nProcessed %d Total Records.\n" % (total,) for a in args: - print "%s%s=> %d Accesses from %s Unique IPs" % (a, (15-len(a))*" ", matched[a], len(REVERSE_CACHE)) + print "%s%s=> %d Accesses from %s Unique IPs" % (a, (20-len(a))*" ", matched[a], len(UNIQUE_IP[a]))