Is it possible to configure Zserver to produce logs with domains rather than just IP addresses? Also, it would be nice to have the date/time being local rather than GMT or whatever appears in the log. ------- Regards, Graham Chiu gchiu<at>compkarori.co.nz http://www.compkarori.com/dynamo - The Homebuilt Dynamo http://www.compkarori.com/dbase - The dBase bulletin
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
In article <042a01bf6091$affc3890$0100a8c0@rochester.rr.com>, Darrell <dgallion@rochester.rr.com> writes
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
Hi Darrell, I tried this out but all I got was just lots of scrolling text. I don't read python so guess I invoked it incorrectly. However, I managed to cobble together a script in Rebol ( www.rebol.com ) that does what I needed. It should work on any of the umpteen platforms that Rebol supports. Rebol [ Title: "web log resolver" File: %logresolve.r Author: "Graham Chiu" Email: gchiu@compkarori.co.nz Date: [ 17-Jan-2000 ] Rights: "GNU" Version: 0.1 Purpose: { changes a web server log in standard/extended format so that IP addresses are resolved to domain names. } ] dns-cache: make block! 1000 newlog: make string! 10000 weblog: read/lines %z2.log foreach line weblog [ url: first parse line none remainder: find line " - - " domain: select dns-cache url if ( domain == none ) [ domain: read join dns:// url if ( domain == none ) [ domain: "unresolved" ] append dns-cache url append dns-cache domain ] append newlog join domain [ remainder newline ] prin "." ] write/lines %new.log newlog ------- Regards, Graham Chiu gchiu<at>compkarori.co.nz http://www.compkarori.com/dynamo - The Homebuilt Dynamo http://www.compkarori.com/dbase - The dBase bulletin
participants (2)
-
Darrell -
Graham Chiu