diff --git a/waccess b/waccess index f4d879e..d456ae0 100755 --- a/waccess +++ b/waccess @@ -1,6 +1,6 @@ #!/usr/bin/env python # waccess - Copyright (c) 2001, TundraWare Inc., All Rights Reserved -# $Id: waccess,v 1.3 2002/08/30 21:52:07 tundra Exp $ +# $Id: waccess,v 1.4 2002/08/30 22:17:13 tundra Exp $ # # Look for selected strings passed on the command line in the http access log. @@ -21,9 +21,15 @@ TRUE = not FALSE ########## -# Constants +# Constants & Tables ########## +# List of IP addesses to ignore. Records with IP addresses found +# in this list will be ignored entirely. The addresses here may +# be partial IP quads. + +IGNORED = ["127.0", "192.168.0."] + ########## # Function Defintions @@ -75,33 +81,43 @@ for record in f.read().splitlines(): total += 1 - # Check each log record for a match with any command line argument + fields = record.split() - MATCHED = FALSE - for a in args: - if record.count(a): - fields = record.split() - i = 0 - revname = "" - matched[a] += 1 - MATCHED = TRUE + # See if this is an IP address to ignore + + PROCESS = TRUE + for ignoreIP in IGNORED: + if fields[0].startswith(ignoreIP): + PROCESS = FALSE + + if PROCESS: + + # Check each log record for a match with any command line argument + + MATCHED = FALSE + for a in args: + if record.count(a): + i = 0 + revname = "" + matched[a] += 1 + MATCHED = TRUE - # But only display the matching record once, regardless of how many - # matching substrings are found. + # But only display the matching record once, regardless of how many + # matching substrings are found. - if MATCHED: - if REVERSE: - try: - revname = socket.gethostbyaddr(fields[0])[0] - except: - revname = "NO REVERSE RESOLUTION" + if MATCHED: + if REVERSE: + try: + revname = socket.gethostbyaddr(fields[0])[0] + except: + revname = "NO REVERSE RESOLUTION" - if SHOW: - print fields[3][1:], " " * (19 - len(fields[3][1:])), \ - fields[0], " " * (15 - len(fields[0])), \ - revname[-(35+1):], " " * (35 - len(revname)), \ - fields[5], " " * (8 - len(fields[5])), fields[6] + if SHOW: + print fields[3][1:], " " * (19 - len(fields[3][1:])), \ + fields[0], " " * (15 - len(fields[0])), \ + revname[-(35+1):], " " * (35 - len(revname)), \ + fields[5], " " * (8 - len(fields[5])), fields[6]