Quem trabalha com administração de servidores Unix/Linux já deve estar mais do que acostumado em utilizar o comando netstat e suas variáveis.
Acontece que infelizmente este comando tem um sério problema de lentidão, só visível em ambientes com mais de 5k conexões simultâneas e não trás tantos detalhes quanto a conexões TCP/IPs e seus estados.
Para isso existe o comando SS, que trás as seguintes informações aos seus usuários:
- All TCP sockets.
- All UDP sockets.
- All established ssh / ftp / http / https connections.
- All local processes connected to X server.
- Filtering by state (such as connected, synchronized, SYN-RECV, SYN-SENT,TIME-WAIT), addresses and ports.
- All the tcp sockets in state FIN-WAIT-1 and much more.
Abaixo segue alguns exemplos quanto a sua utilização:
Task: Display All TCP Sockets
# ss -t -a
Task: Display All UDP Sockets
# ss -u -a
Task: Display All Established SMTP Connections
# ss -o state established '( dport = :smtp or sport = :smtp )'
Task: Display All Established HTTP Connections
# ss -o state established '( dport = :http or sport = :http )'
Task: Find All Local Processes Connected To X Server
# ss -x src /tmp/.X11-unix/*
Task: List All The Tcp Sockets in State FIN-WAIT-1
List all the TCP sockets in state -FIN-WAIT-1 for our httpd to network 202.54.1/24 and look at their timers:
# ss -o state fin-wait-1 '( sport = :http or sport = :https )' dst 202.54.1/24
How Do I Filter Sockets Using TCP States?
The syntax is as follows:
## tcp ipv4 ## ss -4 state FILTER-NAME-HERE ## tcp ipv6 ## ss -6 state FILTER-NAME-HERE
Where FILTER-NAME-HERE can be any one of the following,
- established
- syn-sent
- syn-recv
- fin-wait-1
- fin-wait-2
- time-wait
- closed
- close-wait
- last-ack
- listen
- closing
- all : All of the above states
- connected : All the states except for listen and closed
- synchronized : All the connected states except for syn-sent
- bucket : Show states, which are maintained as minisockets, i.e. time-wait and syn-recv.
- big : Opposite to bucket state.
Mais informações, como também uma comprovação de que o SS é mais rápido do que o netstat no seguinte link.
RT @gustcol: O comando SS ao invés do netstat http://t.co/MogpP8VM #linux #admin
Poh…acho que seria legal você colocar que quem fez o artigo foram os caras do nixCraft ( cujo site você referenciou no link postado), você somente repassou a informação.
DAN — já passei o link e as infos..