commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Sometimes apache will get stuck in an established state where you can't get a list of the connecting IP's from mod_status... not a good thing when you need to ban an abusive ip.
There are 12 alternatives - vote for the best!
Where COMMAND is the process(es) name. I prefer to get all states but you may add ESTABLISHED in the grep regex.
lsof -c apache2 | egrep -o 'TCP.*ESTABLISHED.*$'
-nP flags are optional and UDP is irrelevant for established connections
Similar but using the process id:
lsof -nP -p PID | egrep -o '(TCP|UDP).*$'
If you can do better, submit your command here.
You must be signed in to comment.