I want to analyze my Debian 9 server's network workload to detect some possible network overloads.
The main metrics I need to analyze are:
- CPS (connections per second)
- Throughput
Is there a way to obtain these metrics from within Linux?
I thought that CPS metric could be somehow obtained through conntrack NEW
connections events but not sure that this would be the most proper way..
Sorry if obvious.
P.S. this server handles not only local traffic, it also forward a lot of traffic.
I think it would be sufficient to describe these metrics' origins based on native Linux API.
Throughput
By the way, the throughput metric in general is something, that is external in relation to the testing object (OS Linux you're talking about). I.e. roughly speaking we have two hosts (e.g. client and server) and testing object between them. We blow the network traffic between client and server and record the (boundary) throughput of testing object (e.g. with iperf).
But from within OS Linux a simple way we can measure throughput is only per interface.
So you can just watch
/proc/net/dev
and calculate the delta of bytes per second:CPS
The same thing is for CPS metric. Basically it is an external measurement. But from within your Linux you can try to calculate it based on the
/proc/net/stat/ip_conntrack
:From
lnstat(8)
man:...
In Linux connection tracking:
So seems that you want to calculate delta
new
per second.Read more:
The sar command that comes with sysstat will do both.
To monitor connections per second sar -n TCP 1
active/s is the outbound TCP connections passive/s is the inbound TCP connections
for UDP sar -n UDP 1
To look at network throughput sar -n DEV (optionally add a 1 to monitor current per/second)