On 3/5/2016 4:47 AM, skeletor wrote:
> Hello.
> Is any method to obtain next stats: number of
> TIME_WAIT,SYN_RCVD,LAST_ACK,FIN_WAIT_2 not from count every time from
> `netstat -an | grep TIME_WAIT| wc -l` ?
> Netstat -s only shows tcpCurrEstab from my requires. May be dtrace can
> help?
Dtrace triggers on events. What events are you interested in? State
transitions? Unfortunately, there's no one function where TCP state is
changed in the kernel. It mostly happens in tcp`tcp_input_data (the
first argument to that function is the conn_t, and the conn_tcp member
of that structure has the tcp_t. The tcp_state field is the one of
interest, so you could (possibly) look at the state going in and coming
out to check for transitions. There are many other functions (e.g.,
tcp_do_connect) that also make these sorts of state changes.
If you're interested in a summary of current status, I'd suggest
something like this:
% netstat -P tcp -n | awk '/^[0-9]/ && NF>6 {print $7}' | sort | uniq -c
--
James Carlson 42.703N 71.076W <[email protected]>
-------------------------------------------
dtrace-discuss
Archives: https://www.listbox.com/member/archive/184261/=now
RSS Feed: https://www.listbox.com/member/archive/rss/184261/25769126-e243886f
Modify Your Subscription:
https://www.listbox.com/member/?member_id=25769126&id_secret=25769126-8d47a7b2
Powered by Listbox: http://www.listbox.com