This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
tcp connects script
- From: Hien Nguyen <hien at us dot ibm dot com>
- To: SystemTAP <systemtap at sources dot redhat dot com>
- Date: Wed, 07 Sep 2005 11:02:16 -0700
- Subject: tcp connects script
The attached script monitors the tcp connection to the machine, it will
pritn out the execname, pid and local port. To test this script
stap -g tcp_connections
then from another machine start an ssh session on the above machine. The
out put should looks like this
sshd [2185] 22
:
It also demontrates how to pass a struct pointer to an embeded function.
Hien.
%{
#include <net/tcp.h>
#include <net/ip.h>
%}
function get_local_port:long(sk)
%{
unsigned long ptr = (unsigned long) THIS->sk;
struct inet_sock *inet = (struct inet_sock *) ptr;
THIS->__retvalue = (long long) inet->num;
%}
probe kernel.function("tcp_accept") {
print(execname()." [".string(pid())."] ".string(get_local_port($sk)))
}