1 # -*- tab-width: 4 -*- ;; Emacs
2 # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM
3 ############################################################ IDENT(1)
5 # $Title: dwatch(8) module for dtrace_udp(4) $
6 # $Copyright: 2014-2018 Devin Teske. All rights reserved. $
9 ############################################################ DESCRIPTION
11 # Display local/remote UDP addresses/ports and bytes sent/received for UDP I/O
13 ############################################################ PROBE
16 udp) : ${PROBE:=udp:::send, udp:::receive} ;;
17 *) : ${PROBE:=udp:::${PROFILE#udp-}}
20 ############################################################ ACTIONS
33 $PROBE /* probe ID $ID */
40 this->recv = probename == "receive" ? 1 : 0;
41 this->flow = this->recv ? "<-" : "->";
46 this->local = this->recv ? args[2]->ip_daddr : args[2]->ip_saddr;
47 this->remote = this->recv ? args[2]->ip_saddr : args[2]->ip_daddr;
52 this->length = (uint16_t)args[4]->udp_length;
53 this->lport = this->recv ? args[4]->udp_dport : args[4]->udp_sport;
54 this->rport = this->recv ? args[4]->udp_sport : args[4]->udp_dport;
59 this->local6 = strstr(this->local, ":") != NULL ? 1 : 0;
60 this->remote6 = strstr(this->remote, ":") != NULL ? 1 : 0;
61 this->local = strjoin(strjoin(this->local6 ? "[" : "",
62 this->local), this->local6 ? "]" : "");
63 this->remote = strjoin(strjoin(this->remote6 ? "[" : "",
64 this->remote), this->remote6 ? "]" : "");
70 ############################################################ EVENT DETAILS
72 if [ ! "$CUSTOM_DETAILS" ]; then
75 * Print network I/O details
77 printf("%s:%u %s %s:%u %d byte%s",
78 this->local, this->lport,
80 this->remote, this->rport,
82 this->length == 1 ? "" : "s");
84 EVENT_DETAILS=$( cat <&9 )
87 ################################################################################
89 ################################################################################