I have a site with video content (mp4 files).
When people are watching videos, they are downloading video files from my site. I want to know the number of the active connections via the linux terminal. They are probably TCP packets on port 80.
$ netstat -an |grep :80 | wc -l
gives a huge number, ~6-7k. I don’t think that this is correct?
netstat on Linux is obsolete and was replaced by
ss which you should use instead.
Something like this ought to give you what you want:
$ ss -H state established '( sport = :https )' | wc -l 21
This selects connections on port 443 which are currently established, i.e. connected to a remote host, excluding those which are in the process of closing.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.