how to get file download connections on linux

KoSMoS asked:

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 this active connections via linux terminal.
they are probably tcp packages on port 80.

netstat -an |grep :80 | wc -l

gives me huge number like 6-7k. I dont think that this is correct.

My answer:


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.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.