Last active
November 25, 2015 21:29
-
-
Save claytantor/3e4b709662ed84bbd48c to your computer and use it in GitHub Desktop.
Ever wanted to know what ports are being attempted to bind to, because there are port conflicts?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sbin/dtrace -s | |
syscall::bind:entry | |
/execname == "java"/ | |
{ | |
self->t = timestamp; | |
this->socks = (struct sockaddr*)copyin(arg1, arg2); | |
this->hport = (uint_t)this->socks->sa_data[0]; | |
this->lport = (uint_t)this->socks->sa_data[1]; | |
this->hport <<= 8; | |
this->port = this->hport + this->lport; | |
self->port = this->port; | |
self->ipaddr1 = this->socks->sa_data[2]; | |
self->ipaddr2 = this->socks->sa_data[3]; | |
self->ipaddr3 = this->socks->sa_data[4]; | |
self->ipaddr4 = this->socks->sa_data[5]; | |
this->socks = 0; | |
this->lport = 0; | |
this->hport = 0; | |
this->port = 0; | |
printf( "%d: bind( %d.%d.%d.%d, %d ) call\n", timestamp, self->ipaddr1, self->ipaddr2, self->ipaddr3, self->ipaddr4, self->port ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment