From: "Graham Chiu"
Is it possible to configure Zserver to produce logs with domains rather than just IP addresses?
Not a Zserver patch but a fun util if you like. Parses a file for IP addresses and replaces them with the IP and host names. This would be much faster with threads.
python hosts.py access-log
import re, socket, sys def main(): fp=open(sys.argv[1]) cache={} while 1: line=fp.readline() def func(mo, cache=cache): ip=mo.group(1) host=cache.get(ip,None) if host==None: try: host=`socket.gethostbyaddr(ip)` cache[ip]=host+':'+ip except: cache[ip]=host='Unknown host:'+ip return host line=re.sub('(\d+\.\d+\.\d+\.\d+)',func, line) print line main() --Darrell