Contents that posted a long time ago may be obsolete and may not reflect my current opinion.
It’s been a while maintaining the proxy services for my work friends who are in Beijing office. These days I tried to collect some basic metrics like online IP addresses and its connections. And I found a very simple way to do it with only netstat
and several text process tools.
For instance, I would like to get the clients info connected to port 443
:
netstat -ntu \ # Collect network statistics and very detailed information |
The final shell script looks like:
netstat -ntu | grep -v LISTEN | awk '{print $4, $5}' | grep -E '^[0-9\.]+:443' | cut -d' ' -f2 | cut -d: -f1 | sort | uniq -c |
And also the results:
8 180.xx.xx.74 |