$ netstat -Lan // не работает Current listen queue sizes (qlen/incqlen/maxqlen) Listen Local Address 0/0/128 *.12345 10/0/128 *.80 0/0/128 *.8080 

https://www.nginx.com/resources/admin-guide/serving-static-content/#optimize

  • In the example of the output of 10/0/128 you 10/0/128 number 10 that is not what you are asking? (the number of arrivals, but not yet established (ie, accept () was not called for them) connections) - avp
  • @avp example I understand, but I do not know which team to get such a conclusion. - user208916
  • @Hipster on the link in your question, the example is carried out on a machine with one of the BSD systems, where there is support for the -L option, surely you try (I should describe where you try in the question) on one of the GNU / Linux systems. - Hellseher

3 answers 3

My experiments have shown what to call
ss -la | grep ss -la | grep your-port | grep LISTEN | grep LISTEN

Then the number in the Recv-Q field shows the number of received connections for which the server has not yet made the accept() call.

By the way, the maximum length of the queue of pending connections is shown in the Send-Q field of this socket. In other words, this is the number that we pass to the second argument to listen() .

    The iprout2 package is preferred on modern GNU / Linux

     ~# ss -la -a, --all Display all sockets. -l, --listening Display listening sockets. 

    UPD

    The netstat -L option is present only in * BSD Unix'ax in * Linux versions, this option is not available. Alternative to this is Recv-Q and Send-Q

    Recv-q

    Installed: the number of bytes not copied by the user program connected to this socket.

    Expected: From kernel version 2.6.18, this column contains sync values ​​(syn backlog)

    Send-q

    Set: the number of bytes NOT received by the remote machine.

    Expected: since version 2.6.18 of the kernel, this column contains the maximum sync size (syn backlog)

    If the values ​​are 0, this means that your application works fine at both ends of the connection and the network between them (OK).

    Actual instantaneous values ​​may differ from 0, but you cannot track them.

    Translation -> https://stackoverflow.com/questions/36466744/use-of-recv-q-and-send-q

    Links

    • In my opinion ss does not display such information. I only see the columns: Netid State, Recv-Q, Send-Q, Local Address: Port, Peer Address: Port. - user208916
    • @Hipster updated the answer - Hellseher
    • No, as far as I understand the columns Recv-Q and Send-Q are not the number of connections in the incoming and outgoing queue, but the number of bytes. In the NGINX documentation, they counted the number of connections. - user208916
    • @Hipster There is a typo in the example (according to your link) the netstat program does not have the option -L there is an option -l, listnening (it is not in Ubuntu 12.16 and Fedora 27) then they tried to show the number of "listening" connections for Nginx, as display commands ss -la , netstat -lan - Hellseher
    • Probably a typo, but still how the queues look? Or how to convert them from bytes to pieces? - user208916 pm

    probably implied tcp connections in the listen state

    you can get a list of them, for example, using the lsof program (an example of output is shown):

     $ sudo lsof -n -itcp -stcp:listen COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 725 root 3u IPv4 104540750 0t0 TCP *:ssh (LISTEN) sshd 725 root 4u IPv6 104540752 0t0 TCP *:ssh (LISTEN) dnsmasq 1969 nobody 6u IPv4 22700 0t0 TCP 192.168.1.1:domain (LISTEN) adb 8882 user 6u IPv4 31077050 0t0 TCP 127.0.0.1:5037 (LISTEN) qemu-syst 10337 libvirt-qemu 17u IPv4 70173191 0t0 TCP 127.0.0.1:5900 (LISTEN) exim4 10685 Debian-exim 3u IPv4 27902129 0t0 TCP 127.0.0.1:smtp (LISTEN) exim4 10685 Debian-exim 4u IPv6 27902130 0t0 TCP [::1]:smtp (LISTEN) cupsd 17961 root 9u IPv6 111981277 0t0 TCP [::1]:ipp (LISTEN) cupsd 17961 root 10u IPv4 111981278 0t0 TCP 127.0.0.1:ipp (LISTEN) 

    to select only the sockets created by a process running from a file with a name beginning, for example, with exim characters, you must add the option -c имя and option -a (a logical "and" in relation to the options):

     $ sudo lsof -n -itcp -stcp:listen -c exim -a COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME exim4 10685 Debian-exim 3u IPv4 27902129 0t0 TCP 127.0.0.1:smtp (LISTEN) exim4 10685 Debian-exim 4u IPv6 27902130 0t0 TCP [::1]:smtp (LISTEN) 

    an exact match with the name can be specified using a regular expression (see $ man lsof ):

     $ sudo lsof -n -itcp -stcp:listen -c '/^exim4$/' -a ... 

    to calculate the number of lines, you can use the wc program with the -l option, after removing the first line, for example, the tail program with the -n +2 option:

     $ sudo lsof -n -itcp -stcp:listen -c exim -a | tail -n +2 | wc -l 2 

    almost a similar question: How to view current SSH connections?