3 * tcpstat.d - print TCP statistics. Uses DTrace.
5 * This prints TCP statistics every second, retrieved from the MIB provider.
7 * $Id: tcpstat.d 3 2007-08-01 10:50:08Z brendan $
12 * TCP_out TCP bytes sent
13 * TCP_outRe TCP bytes retransmitted
14 * TCP_in TCP bytes received
15 * TCP_inDup TCP bytes received duplicated
16 * TCP_inUn TCP bytes received out of order
18 * The above TCP statistics are documented in the mib2_tcp struct
19 * in the /usr/include/inet/mib2.h file; and also in the mib provider
20 * chapter of the DTrace Guide, http://docs.sun.com/db/doc/817-6223.
22 * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
26 * The contents of this file are subject to the terms of the
27 * Common Development and Distribution License, Version 1.0 only
28 * (the "License"). You may not use this file except in compliance
31 * You can obtain a copy of the license at Docs/cddl1.txt
32 * or http://www.opensolaris.org/os/licensing.
33 * See the License for the specific language governing permissions
34 * and limitations under the License.
38 * 15-May-2005 Brendan Gregg Created this.
39 * 15-May-2005 " " Last update.
42 #pragma D option quiet
49 TCP_out = 0; TCP_outRe = 0;
50 TCP_in = 0; TCP_inDup = 0; TCP_inUn = 0;
57 profile:::tick-1sec { line--; }
62 printf("%11s %11s %11s %11s %11s\n",
63 "TCP_out", "TCP_outRe", "TCP_in", "TCP_inDup", "TCP_inUn");
71 mib:::tcpOutDataBytes { TCP_out += arg0; }
72 mib:::tcpRetransBytes { TCP_outRe += arg0; }
73 mib:::tcpInDataInorderBytes { TCP_in += arg0; }
74 mib:::tcpInDataDupBytes { TCP_inDup += arg0; }
75 mib:::tcpInDataUnorderBytes { TCP_inUn += arg0; }
82 printf("%11d %11d %11d %11d %11d\n",
83 TCP_out, TCP_outRe, TCP_in, TCP_inDup, TCP_inUn);