This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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)))
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]