Nasser Heidari

2010-04-22

Too many connections in TIME_WAIT state

Filed under: Linux — Nasser Heidari @ 16:25

Applications that handle a huge number of TCP connections, either as a server, or as a client, will often see a large number of sockets in TIME_WAIT state.
The sockets in TIME_WAIT can be seen with the “netstat -epn –tcp ” command.
If the number of TIME_WAIT sockets gets too large, your address space will be exhausted, causing a disruption of TCP traffic.
If you try a little Googling, you may be find tcp_fin_timeout option .
Do not be confused by the /proc/sys/net/ipv4/tcp_fin_timeout config item. The FIN TIMEOUT is not the same as the TIMEWAIT length.

You can force the kernel to reuse the TIME_WAIT buckets though, by setting the /proc/sys/net/ipv4/tcp_tw_recycle entry to 1. I have tested this, and it works: very few TIME_WAIT entries will be present when using this setting.

# echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
or
add net.ipv4.tcp_tw_recycle = 1 to /etc/sysctl.conf .

Socket state counter

Filed under: Linux — Nasser Heidari @ 16:10

# netstat -an | awk '/^tcp/ {A[$(NF)]++} END {for (I in A) {printf "%5d %s\n", A[I], I}}'

1 LAST_ACK
16 LISTEN
2 SYN_RECV
5 CLOSE_WAIT
26 ESTABLISHED
1 FIN_WAIT1
2 SYN_SENT
4 CLOSING
18 TIME_WAIT

2010-04-04

Obtain the HP Server Model information and Serial Number

Filed under: freebsd,Linux — Nasser Heidari @ 09:44

To do this, first install dmidecode , in FreeBSD you can install it easily:

# pkg_add -r dmidecode

then try this:

# dmidecode -s chassis-serial-number
# dmidecode -s system-product-name

FreeBSD: You can find all installed Hard Drives using this way:

# df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/da0s1a 10154158 263394 9078432 3% /
devfs 1 1 0 100% /dev
/dev/da0s1e 5077038 86 4670790 0% /tmp
/dev/da0s1f 99246150 18245382 73061076 20% /usr
/dev/da0s1d 20308398 2714302 15969426 15% /var

# egrep ‘da[0-9]’ /var/run/dmesg.boot

Hitting this command will show lots of information about your hardware by :

# sysctl hw | less