xref: /onnv-gate/usr/src/cmd/dtrace/demo/tcp/tcpbytesstat.d (revision 12507:501806a754d2)
1*12507SAlan.Maguire@Sun.COM #!/usr/sbin/dtrace -s
2*12507SAlan.Maguire@Sun.COM /*
3*12507SAlan.Maguire@Sun.COM  * CDDL HEADER START
4*12507SAlan.Maguire@Sun.COM  *
5*12507SAlan.Maguire@Sun.COM  * The contents of this file are subject to the terms of the
6*12507SAlan.Maguire@Sun.COM  * Common Development and Distribution License (the "License").
7*12507SAlan.Maguire@Sun.COM  * You may not use this file except in compliance with the License.
8*12507SAlan.Maguire@Sun.COM  *
9*12507SAlan.Maguire@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*12507SAlan.Maguire@Sun.COM  * or http://www.opensolaris.org/os/licensing.
11*12507SAlan.Maguire@Sun.COM  * See the License for the specific language governing permissions
12*12507SAlan.Maguire@Sun.COM  * and limitations under the License.
13*12507SAlan.Maguire@Sun.COM  *
14*12507SAlan.Maguire@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
15*12507SAlan.Maguire@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*12507SAlan.Maguire@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
17*12507SAlan.Maguire@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
18*12507SAlan.Maguire@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
19*12507SAlan.Maguire@Sun.COM  *
20*12507SAlan.Maguire@Sun.COM  * CDDL HEADER END
21*12507SAlan.Maguire@Sun.COM  */
22*12507SAlan.Maguire@Sun.COM /*
23*12507SAlan.Maguire@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*12507SAlan.Maguire@Sun.COM  */
25*12507SAlan.Maguire@Sun.COM 
26*12507SAlan.Maguire@Sun.COM #pragma D option quiet
27*12507SAlan.Maguire@Sun.COM 
28*12507SAlan.Maguire@Sun.COM tcp:::receive
29*12507SAlan.Maguire@Sun.COM {
30*12507SAlan.Maguire@Sun.COM 	@bytes[args[2]->ip_saddr, args[4]->tcp_dport] =
31*12507SAlan.Maguire@Sun.COM 	    sum(args[2]->ip_plength - args[4]->tcp_offset);
32*12507SAlan.Maguire@Sun.COM }
33*12507SAlan.Maguire@Sun.COM 
34*12507SAlan.Maguire@Sun.COM tcp:::send
35*12507SAlan.Maguire@Sun.COM {
36*12507SAlan.Maguire@Sun.COM 	@bytes[args[2]->ip_daddr, args[4]->tcp_sport] =
37*12507SAlan.Maguire@Sun.COM 	    sum(args[2]->ip_plength - args[4]->tcp_offset);
38*12507SAlan.Maguire@Sun.COM }
39*12507SAlan.Maguire@Sun.COM 
40*12507SAlan.Maguire@Sun.COM profile:::tick-1sec
41*12507SAlan.Maguire@Sun.COM {
42*12507SAlan.Maguire@Sun.COM 	printf("\n   %-32s %16s\n", "HOST", "BYTES/s");
43*12507SAlan.Maguire@Sun.COM 	printa("   %-32s %@16d\n", @bytes);
44*12507SAlan.Maguire@Sun.COM 	trunc(@bytes);
45*12507SAlan.Maguire@Sun.COM }
46