I want to log all network traffic on a Mac OS X server (like tcpdump does), but including the ID of the process that is responsible. Using lsof only gives me the current connections, not the past ones.
Is there a way to do this?
Sadly, the best way to do this (tcpsnoop, which uses DTrace to do exactly what you describe) does not work on the Mac OS X implementation of dtrace. You'd need some kind of application firewall (Little Snitch for example) but that's more of a desktop / single user thing than something you want running on your server.
This seems like an odd requirement actually, are you trying to make an intrusion detection system, or just figure out what is causing network access?