• Quick network status of a machine

    netstat is one of the most powerful tools for quickly grabbing the high-level network state of a *nix machine. While it has a variety of uses, from tracking down resource consumption to debugging broader networking issues, there is a great one-liner which can quickly capture a snapshot of the (TCP) network state of a machine:

    $ netstat -tn | awk 'NR>2 {print $6}' | sort | uniq -c | sort -rn
         1618 ESTABLISHED
            4 LAST_ACK
            2 SYN_RECV
            1 TIME_WAIT
            1 CLOSE_WAIT
    

    The output concisely summarizes the number of TCP connections in each connection state. This shows not only the number of simultaneous connections a machine is handling, but can also reveal potentially resource-intensive connection churn. Beyond that, elevated TIME_WAIT and other states may indicate the need to tune kernel settings to get the most out of a machine that hosts high-throughput services.

    NB: You may have to make some slight tweaks to the command, depending on your flavor.