/* * Author: Kais Belgaied * Modified: Andrew Gabriel - Converted to use TCP and UDP providers for build 142 onwards */ #pragma D option quiet #pragma D option dynvarsize=128m dtrace:::BEGIN { printf("Tracing... Hit Ctrl-C to end.\n"); tstamp = timestamp; } fbt:sockfs:socket_sendmsg:entry, fbt:sockfs:socket_recvmsg:entry /args[2] != NULL/ /* struct uio */ { self->uio = args[2]; /* struct uio */ self->uio_resid = self->uio->uio_resid; /* residual count */ } udp:::send /self->uio != NULL/ { self->addr = args[2]->ip_daddr; self->dst_port = args[4]->udp_dport; /* destination port*/ self->proto = "UDP"; } tcp:::send /self->uio / { self->addr = args[2]->ip_daddr; self->dst_port = args[4]->tcp_dport; /* destination port*/ self->proto = "TCP"; } /* * Aggregate the results */ fbt:sockfs:socket_sendmsg:return /self->uio != NULL && self->addr != NULL && self->proto != NULL/ { /* Aggregate the results, converting bytes to bits */ @rw[execname, zonename, self->proto, self->addr, self->dst_port] = sum((self->uio_resid - self->uio->uio_resid)*8); self->uid = 0; self->uio_resid = 0; self->addr = 0; } fbt:sockfs:socket_sendmsg:return { /* reset the thread-local variables */ self->uid = 0; self->uio_resid = 0; } dtrace:::END { printf("%-20s %-10s %-10s %-15s %5s %15s\n", "Process", "Zone", "Protocol", "Destination", "Port", "Bits\n"); printa("%-20s %-10s %-10s %-15s %5d %@15u\n", @rw); printf("\nTrace ran for %d seconds\n", (timestamp - tstamp)/1000000000); }