Check the socket status in Linux:
CAT/proc/NET/sockstat # (IPv4)
Sockets: used 137 TCP: inuse 49 orphan 0 TW 3272 alloc 52 mem 46udp: inuse 1 mem 0raw: inuse 0 frag: inuse 0 memory 0
Note:
Sockets: used: Total number of used protocol sockets
TCP: inuse: number of TCP sockets in use (Listening. The value is ≤netstat-lnt | grep ^ TCP | WC-l
TCP: orphan: number of TCP connections without a master (not in any process) (useless, number of TCP sockets to be destroyed)
TCP: TW: number of TCP connections waiting to be disabled. The value is equal to netstat-ant | grep time_wait | WC-l
TCP: alloc (allocated): number of TCP sockets allocated (established and applied to sk_buff. The value is equal to netstat-ant | grep ^ TCP | WC-l
TCP: Mem: Socket buffer usage (Unit unknown. In SCP measurement, when the speed is 4803.9kb/s: the value is 11. In netstat-ant, the corresponding port 22's Recv-q = 0, send-Q ≈ 400)
UDP: inuse: number of UDP sockets in use
Raw:
Frag: number of IP segments used
For IPv6, see CAT/proc/NET/sockstat6.
Tcp6: inuse 3udp6: inuse 0raw6: inuse 0 frag6: inuse 0 memory 0
With these values, you can easily calculate the current number of TCP requests and perform related monitoring.