Skip to content

Instantly share code, notes, and snippets.

@vanne02135
Created May 31, 2010 08:13
Show Gist options
  • Save vanne02135/419645 to your computer and use it in GitHub Desktop.
Save vanne02135/419645 to your computer and use it in GitHub Desktop.
Parse apache access logs to show host names and connection times
#!/usr/bin/python
import sys
import socket
line = sys.stdin.readline()
lasthost = ""
while len(line) != 0:
mylist = line.split()
if mylist[0] == lasthost:
line = sys.stdin.readline()
continue
#print mylist
print "%s : %s" % (mylist[3][1:], socket.getfqdn(mylist[0]))
lasthost = mylist[0]
line = sys.stdin.readline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment