Log connections to program
Posted
by
Zac
on Server Fault
See other posts from Server Fault
or by Zac
Published on 2012-10-06T07:06:55Z
Indexed on
2012/10/06
9:39 UTC
Read the original article
Hit count: 220
Besides for using iptables to log incoming connections..
Is there a way to log established inbound connections to a service that you don't have the source to (suppose the service doesn't log stuff like this on its own)? What I'm wanting to do is gather some information based on who's connecting to be able to tell things like what times of the day the service is being used the most, where in the world the main user base is, etc.
I am aware I can use netstat
and just hook it up to a cron script, but that might not be accurate, since the script could only run as frequently as a minute.
Here is what I am thinking right now:
- Write a program that constantly polls
netstat
, looking for established connections that didn't appear in the previous poll. This idea seems like such a waste of cpu time though, since there may not be a new connection.. - Write a wrapper program that accepts inbound connections on whatever port the service runs on, but then I wouldn't know how to pass that connection along to the real service.
Edit: Just occurred to me that this question might be better for stackoverflow, though I am not certain. Sorry if this is the wrong place.
© Server Fault or respective owner