Stephen John Smoogen
2021-Sep-07 11:53 UTC
[CentOS] Find out which process consumed Network bandwidth
On Mon, 6 Sept 2021 at 14:24, Anand Buddhdev <anandb at ripe.net> wrote:> > On 06/09/2021 19:35, Kaushal Shriyan wrote: > > Hi Kaushal, > > > I am running CentOS Linux release 7.9.2009 (Core). Is there a way to find > > out which process consumed network bandwidth during a specific time period? > > > > For example, the Nginx process consumed how much network traffic on Sept > > 01, 2021. > > As far as I know, such accounting isn't done in a standard CentOS > system, so there's no way to determine such information about a past event. >Agreed. The best at this point is looking at the nginx logs and hope they are set up to show bits transferred or something similar to see what ip addresses and files were being used.> Regards, > Anand > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos-- Stephen J Smoogen. I've seen things you people wouldn't believe. Flame wars in sci.astro.orion. I have seen SPAM filters overload because of Godwin's Law. All those moments will be lost in time... like posts on a BBS... time to shutdown -h now.
Charles Polisher
2021-Sep-14 00:18 UTC
[CentOS] Find out which process consumed Network bandwidth
On Mon, 6 Sept 2021 at 14:24, Anand Buddhdev <anandb at ripe.net>>> On 06/09/2021 19:35, Kaushal Shriyan wrote: >> >> Hi Kaushal, >> >>> I am running CentOS Linux release 7.9.2009 (Core). Is there a way to find >>> out which process consumed network bandwidth during a specific time period? >>> >>> For example, the Nginx process consumed how much network traffic on Sept >>> 01, 2021. >> As far as I know, such accounting isn't done in a standard CentOS >> system, so there's no way to determine such information about a past eventKaushal, While you probably can't recover such information for past events, going forward, iptables can help you figure this out. Putting an IPtables rule in the OUTPUT table prior to ACCEPTing the packets can help, e.g.: ??? iptables -A OUTPUT -p tcp -m owner --uid-owner nginx -j ACCEPT because now "iptables -L" will display a count of the packets that matched each rule and the number of bytes. By comparing with the total packets and bytes for a given time period, you can work out the share for nginx. You can also estimate packet and byte counts by IP and port using this method. You could run an hourly cronjob to log the stats. See "man iptables-extensions" and "man iptables". I don't know how this works with firewall-cmd, but I imagine firewalld "just" manages iptables? Good luck!